Skip to content

Commit 192e07e

Browse files
authored
1.1.3 not mixin
1 parent 123edbf commit 192e07e

11 files changed

Lines changed: 35 additions & 68 deletions

File tree

src/main/java/survivalblock/atmosphere/atmospheric_api/not_mixin/block/NonRegisterableBlock.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
import net.minecraft.block.Block;
44
import net.minecraft.registry.entry.RegistryEntry;
55
import org.jetbrains.annotations.Nullable;
6+
import survivalblock.atmosphere.atmospheric_api.not_mixin.funny.DangerousAndOrUnstable;
67

78
/**
89
* Instances of {@link net.minecraft.block.Block} that implement this interface will not
910
* have their {@link net.minecraft.registry.entry.RegistryEntry.Reference} created, and as a
1011
* result, will not crash when not registered. This interface is useful for when an instance of
1112
* {@link net.minecraft.block.Block} is needed without actually creating the block in-game.<p>
12-
* This interface is annotated with {@link Deprecated} because of the potential danger, instability,
13+
* This interface is annotated with {@link DangerousAndOrUnstable} because of the potential danger, instability,
1314
* and incompatibility that may arise.
1415
*/
15-
@Deprecated
16+
@DangerousAndOrUnstable
1617
public interface NonRegisterableBlock {
1718

1819
@Nullable
Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
11
package survivalblock.atmosphere.atmospheric_api.not_mixin.compat;
22

33
import net.fabricmc.loader.api.FabricLoader;
4-
import org.objectweb.asm.tree.ClassNode;
5-
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
6-
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
4+
import survivalblock.atmosphere.atmospheric_api.mixin.compat.AtmosphericMixinConfigPlugin;
75

8-
import java.util.List;
9-
import java.util.Set;
10-
11-
public class AtmosphericAPIMixinPlugin implements IMixinConfigPlugin {
12-
13-
@Override
14-
public void onLoad(String mixinPackage) {
15-
}
16-
17-
@Override
18-
public String getRefMapperConfig() {
19-
return null;
20-
}
6+
public class AtmosphericAPIMixinPlugin implements AtmosphericMixinConfigPlugin {
217

228
@Override
239
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
@@ -28,24 +14,4 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
2814
}
2915
return true;
3016
}
31-
32-
@Override
33-
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
34-
35-
}
36-
37-
@Override
38-
public List<String> getMixins() {
39-
return null;
40-
}
41-
42-
@Override
43-
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
44-
45-
}
46-
47-
@Override
48-
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
49-
50-
}
5117
}

src/main/java/survivalblock/atmosphere/atmospheric_api/not_mixin/datafixer/AtmosphericCodecs.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
package survivalblock.atmosphere.atmospheric_api.not_mixin.datafixer;
22

33
import com.mojang.serialization.Codec;
4-
import com.mojang.serialization.DataResult;
5-
import io.netty.buffer.ByteBuf;
6-
import net.minecraft.network.codec.PacketCodec;
7-
import net.minecraft.registry.Registries;
8-
import net.minecraft.registry.Registry;
9-
import net.minecraft.sound.SoundEvent;
10-
import net.minecraft.util.Identifier;
114
import net.minecraft.util.math.Box;
125
import net.minecraft.util.math.Vec3d;
136
import survivalblock.atmosphere.atmospheric_api.not_mixin.funny.BadAtProgramming;
@@ -18,17 +11,11 @@
1811
@SuppressWarnings("unused")
1912
public interface AtmosphericCodecs {
2013

21-
Codec<SoundEvent> SOUND_EVENT_BY_ID = viaRegistry(Registries.SOUND_EVENT);
22-
2314
// a codec for boxes, but I don't know why you would need to use this
2415
// I feel like at this point I'm just making codecs for the sake of making codecs
2516
Codec<Box> BOX = duo(Vec3d.CODEC).xmap(duo -> new Box(duo.getFirst(), duo.getLast()),
2617
box -> new Duo<>(box.getMinPos(), box.getMaxPos()));
2718

28-
static <S> Codec<S> viaRegistry(Registry<S> registry) {
29-
return Identifier.CODEC.xmap(registry::get, registry::getId);
30-
}
31-
3219
@BadAtProgramming
3320
static <E> Codec<Duo<E>> duo(Codec<E> codec) {
3421
return codec.listOf(2, 2).xmap(Duo::new, List::copyOf);

src/main/java/survivalblock/atmosphere/atmospheric_api/not_mixin/datafixer/AtmosphericPacketCodecs.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@SuppressWarnings("unused")
2222
public interface AtmosphericPacketCodecs {
2323

24-
PacketCodec<ByteBuf, SoundEvent> SOUND_EVENT_BY_ID = viaRegistry(Registries.SOUND_EVENT);
24+
PacketCodec<ByteBuf, SoundEvent> SOUND_EVENT_BY_ID = viaId(Registries.SOUND_EVENT);
2525

2626
PacketCodec<ByteBuf, Vec3d> VEC3D = new PacketCodec<>() {
2727
public Vec3d decode(ByteBuf byteBuf) {
@@ -39,7 +39,7 @@ public void encode(ByteBuf byteBuf, Vec3d vec3d) {
3939
.xmap(vec3ds -> new Box(vec3ds.getFirst(), vec3ds.getSecond()),
4040
box -> new Duo<>(box.getMinPos(), box.getMaxPos()));
4141

42-
static <V> PacketCodec<ByteBuf, V> viaRegistry(Registry<V> registry) {
42+
static <V> PacketCodec<ByteBuf, V> viaId(Registry<V> registry) {
4343
return Identifier.PACKET_CODEC.xmap(registry::get, registry::getId);
4444
}
4545

src/main/java/survivalblock/atmosphere/atmospheric_api/not_mixin/datagen/RegistryEntryLookupContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import org.jetbrains.annotations.Nullable;
66
import survivalblock.atmosphere.atmospheric_api.not_mixin.funny.IsThisEvenNecessary;
77

8-
@IsThisEvenNecessary(IsThisEvenNecessary.LevelsOfUnnecessity.PROBABLY_NOT)
8+
@IsThisEvenNecessary(IsThisEvenNecessary.Levels.PROBABLY_NOT)
99
@SuppressWarnings("unused")
1010
public class RegistryEntryLookupContainer {
1111

src/main/java/survivalblock/atmosphere/atmospheric_api/not_mixin/funny/IsThisEvenNecessary.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
@Retention(RetentionPolicy.SOURCE)
88
public @interface IsThisEvenNecessary {
99

10-
LevelsOfUnnecessity value() default LevelsOfUnnecessity.NORMAL;
10+
Levels value() default Levels.NORMAL;
1111

1212
@SuppressWarnings("unused")
13-
enum LevelsOfUnnecessity {
13+
enum Levels {
1414
NORMAL,
1515
PROBABLY_NOT,
1616
BASCIALLY_DEPRECATED,

src/main/java/survivalblock/atmosphere/atmospheric_api/not_mixin/item/ItemOfUndying.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,43 @@
33
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
44
import net.minecraft.advancement.criterion.UsedTotemCriterion;
55
import net.minecraft.entity.LivingEntity;
6+
import net.minecraft.entity.damage.DamageSource;
67
import net.minecraft.item.ItemStack;
78
import net.minecraft.server.network.ServerPlayerEntity;
89

910
@SuppressWarnings("unused")
1011
public interface ItemOfUndying {
1112

12-
default boolean canUse(LivingEntity living, ItemStack stack) {
13+
default boolean canUse(LivingEntity living, ItemStack stack, DamageSource source) {
1314
return true;
1415
}
1516

16-
default boolean shouldSendPacket(LivingEntity living, ItemStack stack) {
17+
default boolean shouldSendPacket(LivingEntity living, ItemStack stack, DamageSource source) {
1718
return false;
1819
}
1920

20-
default ItemStackOfUndyingS2CPayload getPacket(LivingEntity living, ItemStack stack) {
21+
default ItemStackOfUndyingS2CPayload getPacket(LivingEntity living, ItemStack stack, DamageSource source) {
2122
return new ItemStackOfUndyingS2CPayload(stack, living.getId());
2223
}
2324

24-
default boolean shouldDecrementOnDeathCancel(LivingEntity living, ItemStack stack, int amount) {
25+
default boolean shouldDecrementOnDeathCancel(LivingEntity living, ItemStack stack, int amount, DamageSource source) {
2526
return true;
2627
}
2728

28-
default boolean shouldIncrementStatAndTriggerCriteria(LivingEntity living, ItemStack stack) {
29+
default boolean shouldIncrementStatAndTriggerCriteria(LivingEntity living, ItemStack stack, DamageSource source) {
2930
return true;
3031
}
3132

3233
// probably not a great idea to pass an Operation here
33-
default void triggerCriterion(UsedTotemCriterion instance, ServerPlayerEntity player, ItemStack stack, Operation<Void> original) {
34+
default void triggerCriterion(UsedTotemCriterion instance, ServerPlayerEntity player, ItemStack stack, Operation<Void> original, DamageSource source) {
3435
original.call(instance, player, stack);
3536
}
3637

37-
default boolean shouldEmitGameEvent(LivingEntity living, ItemStack stack) {
38+
default boolean shouldEmitGameEvent(LivingEntity living, ItemStack stack, DamageSource source) {
3839
return true;
3940
}
4041

41-
default void activate(LivingEntity living, ItemStack stack) {
42+
default void activate(LivingEntity living, ItemStack stack, DamageSource source) {
4243
living.setHealth(1.0F);
4344
living.clearStatusEffects();
4445
}

src/main/java/survivalblock/atmosphere/atmospheric_api/not_mixin/item/ItemStackOfUndyingS2CPayload.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public record SoundEventHolder(boolean shouldPlaySound, Optional<SoundEvent> sou
8383

8484
public static final PacketCodec<RegistryByteBuf, SoundEventHolder> PACKET_CODEC = PacketCodec.tuple(
8585
PacketCodecs.BOOL, (holder) -> holder.shouldPlaySound,
86-
AtmosphericPacketCodecs.SOUND_EVENT_BY_ID.collect(PacketCodecs::optional), (holder) -> holder.soundEvent, // alternatively, use the PacketCodec in the SoundEvent class
86+
SoundEvent.PACKET_CODEC.collect(PacketCodecs::optional), (holder) -> holder.soundEvent, // alternatively, use the PacketCodec in the SoundEvent class
8787
PacketCodecs.FLOAT, (holder) -> holder.volume,
8888
PacketCodecs.FLOAT, (holder) -> holder.pitch,
8989
PacketCodecs.BOOL, (holder) -> holder.useDistance,

src/main/java/survivalblock/atmosphere/atmospheric_api/not_mixin/render/overlay/client/AtmosphericOverlayRegistryImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ public final class AtmosphericOverlayRegistryImpl {
1919

2020
public static void register(OverlayHolder overlayHolder) {
2121
OVERLAY_HOLDERS.add(overlayHolder);
22+
OVERLAY_HOLDERS.sort(null);
2223
}
2324
}

src/main/java/survivalblock/atmosphere/atmospheric_api/not_mixin/render/overlay/client/OverlayHolder.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,25 @@
55
import net.minecraft.util.Identifier;
66
import org.jetbrains.annotations.NotNull;
77

8+
import java.util.Comparator;
89
import java.util.function.BiFunction;
910

10-
public class OverlayHolder {
11+
public class OverlayHolder implements Comparable<OverlayHolder> {
1112

1213
protected final Identifier texture;
1314
protected final BiFunction<MinecraftClient, ClientPlayerEntity, Float> opacityProvider;
1415
protected final boolean bypassable;
16+
protected final int priority;
1517

1618
public OverlayHolder(Identifier texture, BiFunction<MinecraftClient, ClientPlayerEntity, Float> opacityProvider, boolean bypassable) {
19+
this(texture, opacityProvider, bypassable, 1000);
20+
}
21+
22+
public OverlayHolder(Identifier texture, BiFunction<MinecraftClient, ClientPlayerEntity, Float> opacityProvider, boolean bypassable, int priority) {
1723
this.texture = texture;
1824
this.opacityProvider = opacityProvider;
1925
this.bypassable = bypassable;
26+
this.priority = priority;
2027
}
2128

2229
public Identifier getTexture() {
@@ -30,4 +37,8 @@ public boolean isBypassable() {
3037
public Float getOpacity(@NotNull MinecraftClient client, @NotNull ClientPlayerEntity player) {
3138
return this.opacityProvider.apply(client, player);
3239
}
40+
@Override
41+
public int compareTo(@NotNull OverlayHolder other) {
42+
return other.priority - this.priority;
43+
}
3344
}

0 commit comments

Comments
 (0)