Fixed Mixins

This commit is contained in:
Frank 2023-12-19 15:55:30 +01:00
parent abc02da0fe
commit 8c7bf0cac2
19 changed files with 105 additions and 95 deletions

View file

@ -170,7 +170,7 @@ public class EndSlimeEntity extends Slime {
} }
} }
((ISlime) this).entityRemove(reason); ((ISlime) this).be_entityRemove(reason);
} }
@Override @Override

View file

@ -5,5 +5,5 @@ import net.minecraft.world.entity.Entity;
public interface ISlime { public interface ISlime {
void be_setSlimeSize(int size, boolean heal); void be_setSlimeSize(int size, boolean heal);
void entityRemove(Entity.RemovalReason removalReason); void be_entityRemove(Entity.RemovalReason removalReason);
} }

View file

@ -14,6 +14,7 @@ import net.minecraft.world.level.BlockAndTintGetter;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@ -24,22 +25,26 @@ import java.util.Comparator;
@Mixin(BiomeColors.class) @Mixin(BiomeColors.class)
public class BiomeColorsMixin { public class BiomeColorsMixin {
private static final int POISON_COLOR = ColorUtil.color(92, 160, 78); @Unique
private static final int STREAM_COLOR = ColorUtil.color(105, 213, 244); private static final int BE_POISON_COLOR = ColorUtil.color(92, 160, 78);
private static final Point[] OFFSETS; @Unique
private static final boolean HAS_SODIUM; private static final int BE_STREAM_COLOR = ColorUtil.color(105, 213, 244);
@Unique
private static final Point[] BE_OFFSETS;
@Unique
private static final boolean BE_HAS_SODIUM;
@Inject(method = "getAverageWaterColor", at = @At("RETURN"), cancellable = true) @Inject(method = "getAverageWaterColor", at = @At("RETURN"), cancellable = true)
private static void be_getWaterColor(BlockAndTintGetter world, BlockPos pos, CallbackInfoReturnable<Integer> info) { private static void be_getWaterColor(BlockAndTintGetter world, BlockPos pos, CallbackInfoReturnable<Integer> info) {
if (ClientOptions.useSulfurWaterColor()) { if (ClientOptions.useSulfurWaterColor()) {
BlockAndTintGetter view = HAS_SODIUM ? Minecraft.getInstance().level : world; BlockAndTintGetter view = BE_HAS_SODIUM ? Minecraft.getInstance().level : world;
MutableBlockPos mut = new MutableBlockPos(); MutableBlockPos mut = new MutableBlockPos();
mut.setY(pos.getY()); mut.setY(pos.getY());
for (int i = 0; i < OFFSETS.length; i++) { for (int i = 0; i < BE_OFFSETS.length; i++) {
mut.setX(pos.getX() + OFFSETS[i].x); mut.setX(pos.getX() + BE_OFFSETS[i].x);
mut.setZ(pos.getZ() + OFFSETS[i].y); mut.setZ(pos.getZ() + BE_OFFSETS[i].y);
if ((view.getBlockState(mut).is(EndBlocks.BRIMSTONE))) { if ((view.getBlockState(mut).is(EndBlocks.BRIMSTONE))) {
info.setReturnValue(i < 4 ? POISON_COLOR : STREAM_COLOR); info.setReturnValue(i < 4 ? BE_POISON_COLOR : BE_STREAM_COLOR);
return; return;
} }
} }
@ -47,17 +52,17 @@ public class BiomeColorsMixin {
} }
static { static {
HAS_SODIUM = FabricLoader.getInstance().isModLoaded("sodium"); BE_HAS_SODIUM = FabricLoader.getInstance().isModLoaded("sodium");
int index = 0; int index = 0;
OFFSETS = new Point[20]; BE_OFFSETS = new Point[20];
for (int x = -2; x < 3; x++) { for (int x = -2; x < 3; x++) {
for (int z = -2; z < 3; z++) { for (int z = -2; z < 3; z++) {
if ((x != 0 || z != 0) && (Math.abs(x) != 2 || Math.abs(z) != 2)) { if ((x != 0 || z != 0) && (Math.abs(x) != 2 || Math.abs(z) != 2)) {
OFFSETS[index++] = new Point(x, z); BE_OFFSETS[index++] = new Point(x, z);
} }
} }
} }
Arrays.sort(OFFSETS, Comparator.comparingInt(pos -> MHelper.sqr(pos.x) + MHelper.sqr(pos.y))); Arrays.sort(BE_OFFSETS, Comparator.comparingInt(pos -> MHelper.sqr(pos.x) + MHelper.sqr(pos.y)));
} }
} }

View file

@ -17,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(CapeLayer.class) @Mixin(CapeLayer.class)
public class CapeLayerMixin { public class CapeLayerMixin {
@Inject(method = "render", at = @At("HEAD"), cancellable = true) @Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;ILnet/minecraft/client/player/AbstractClientPlayer;FFFFFF)V", at = @At("HEAD"), cancellable = true)
public void be_checkCustomElytra( public void be_checkCustomElytra(
PoseStack poseStack, PoseStack poseStack,
MultiBufferSource multiBufferSource, MultiBufferSource multiBufferSource,

View file

@ -7,6 +7,7 @@ import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.ModifyArg;
@ -22,12 +23,10 @@ public abstract class ModelLoaderMixin {
return loc; return loc;
} }
@Unique
private boolean be_changeModel(ResourceLocation id) { private boolean be_changeModel(ResourceLocation id) {
if (id.getNamespace().equals("minecraft")) { if (id.getNamespace().equals("minecraft")) {
if (id.getPath().contains("chorus") && !id.getPath().contains("custom_")) { return id.getPath().contains("chorus") && !id.getPath().contains("custom_");
return true;
}
return false;
} }
return false; return false;
} }

View file

@ -15,6 +15,7 @@ import net.minecraft.util.RandomSource;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@ -35,39 +36,42 @@ public abstract class MusicTrackerMixin {
@Shadow @Shadow
private int nextSongDelay; private int nextSongDelay;
private static float volume = 1; @Unique
private static float srcVolume = 0; private static float be_volume = 1;
private static long time; @Unique
private static float be_srcVolume = 0;
@Unique
private static long be_time;
@Inject(method = "tick", at = @At("HEAD"), cancellable = true) @Inject(method = "tick", at = @At("HEAD"), cancellable = true)
public void be_onTick(CallbackInfo info) { public void be_onTick(CallbackInfo info) {
if (ClientOptions.blendBiomeMusic()) { if (ClientOptions.blendBiomeMusic()) {
Music musicSound = minecraft.getSituationalMusic(); Music musicSound = minecraft.getSituationalMusic();
if (be_checkNullSound(musicSound) && volume > 0 && be_shouldChangeSound(musicSound) && be_isCorrectBiome()) { if (be_checkNullSound(musicSound) && be_volume > 0 && be_shouldChangeSound(musicSound) && be_isCorrectBiome()) {
if (volume > 0) { if (be_volume > 0) {
if (srcVolume < 0) { if (be_srcVolume < 0) {
srcVolume = currentMusic.getVolume(); be_srcVolume = currentMusic.getVolume();
} }
if (currentMusic instanceof AbstractSoundInstance) { if (currentMusic instanceof AbstractSoundInstance) {
((AbstractSoundInstanceAccessor) currentMusic).setVolume(volume); ((AbstractSoundInstanceAccessor) currentMusic).setVolume(be_volume);
} }
minecraft.getSoundManager() minecraft.getSoundManager()
.updateSourceVolume(currentMusic.getSource(), currentMusic.getVolume() * volume); .updateSourceVolume(currentMusic.getSource(), currentMusic.getVolume() * be_volume);
long t = System.currentTimeMillis(); long t = System.currentTimeMillis();
if (volume == 1 && time == 0) { if (be_volume == 1 && be_time == 0) {
time = t; be_time = t;
} }
float delta = (t - time) * 0.0005F; float delta = (t - be_time) * 0.0005F;
time = t; be_time = t;
volume -= delta; be_volume -= delta;
if (volume < 0) { if (be_volume < 0) {
volume = 0; be_volume = 0;
} }
} }
if (volume == 0) { if (be_volume == 0) {
volume = 1; be_volume = 1;
time = 0; be_time = 0;
srcVolume = -1; be_srcVolume = -1;
this.minecraft.getSoundManager().stop(this.currentMusic); this.minecraft.getSoundManager().stop(this.currentMusic);
this.nextSongDelay = Mth.nextInt(this.random, 0, musicSound.getMinDelay() / 2); this.nextSongDelay = Mth.nextInt(this.random, 0, musicSound.getMinDelay() / 2);
this.currentMusic = null; this.currentMusic = null;
@ -77,11 +81,12 @@ public abstract class MusicTrackerMixin {
} }
info.cancel(); info.cancel();
} else { } else {
volume = 1; be_volume = 1;
} }
} }
} }
@Unique
private boolean be_isCorrectBiome() { private boolean be_isCorrectBiome() {
if (minecraft.level == null) { if (minecraft.level == null) {
return false; return false;
@ -90,6 +95,7 @@ public abstract class MusicTrackerMixin {
.value()) instanceof EndBiome; .value()) instanceof EndBiome;
} }
@Unique
private boolean be_shouldChangeSound(Music musicSound) { private boolean be_shouldChangeSound(Music musicSound) {
return currentMusic != null && !musicSound return currentMusic != null && !musicSound
.getEvent() .getEvent()
@ -98,6 +104,7 @@ public abstract class MusicTrackerMixin {
.equals(this.currentMusic.getLocation()) && musicSound.replaceCurrentMusic(); .equals(this.currentMusic.getLocation()) && musicSound.replaceCurrentMusic();
} }
@Unique
private boolean be_checkNullSound(Music musicSound) { private boolean be_checkNullSound(Music musicSound) {
return musicSound != null && musicSound.getEvent() != null; return musicSound != null && musicSound.getEvent() != null;
} }

View file

@ -23,15 +23,20 @@ import net.minecraft.world.phys.shapes.VoxelShape;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.jetbrains.annotations.NotNull;
@Mixin(value = ChorusFlowerBlock.class, priority = 100) @Mixin(value = ChorusFlowerBlock.class, priority = 100)
public abstract class ChorusFlowerBlockMixin extends Block { public abstract class ChorusFlowerBlockMixin extends Block {
private static final VoxelShape SHAPE_FULL = Block.box(0, 0, 0, 16, 16, 16); @Unique
private static final VoxelShape SHAPE_HALF = Block.box(0, 0, 0, 16, 4, 16); private static final VoxelShape BE_SHAPE_FULL = Block.box(0, 0, 0, 16, 16, 16);
@Unique
private static final VoxelShape BE_SHAPE_HALF = Block.box(0, 0, 0, 16, 4, 16);
public ChorusFlowerBlockMixin(Properties settings) { public ChorusFlowerBlockMixin(Properties settings) {
super(settings); super(settings);
@ -87,9 +92,9 @@ public abstract class ChorusFlowerBlockMixin extends Block {
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { public @NotNull VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
if (GeneratorOptions.changeChorusPlant()) { if (GeneratorOptions.changeChorusPlant()) {
return state.getValue(ChorusFlowerBlock.AGE) == 5 ? SHAPE_HALF : SHAPE_FULL; return state.getValue(ChorusFlowerBlock.AGE) == 5 ? BE_SHAPE_HALF : BE_SHAPE_FULL;
} else { } else {
return super.getShape(state, world, pos, context); return super.getShape(state, world, pos, context);
} }

View file

@ -27,7 +27,7 @@ public abstract class ChorusPlantBlockMixin extends Block {
super(settings); super(settings);
} }
@Inject(method = "getStateForPlacement(Lnet/minecraft/world/item/context/BlockPlaceContext;)Lnet/minecraft/world/level/block/state/BlockState;", at = @At("RETURN"), cancellable = true) @Inject(method = "getStateForPlacement", at = @At("RETURN"), cancellable = true)
private void be_getStateForPlacement(BlockPlaceContext ctx, CallbackInfoReturnable<BlockState> info) { private void be_getStateForPlacement(BlockPlaceContext ctx, CallbackInfoReturnable<BlockState> info) {
BlockPos pos = ctx.getClickedPos(); BlockPos pos = ctx.getClickedPos();
Level world = ctx.getLevel(); Level world = ctx.getLevel();
@ -38,16 +38,14 @@ public abstract class ChorusPlantBlockMixin extends Block {
} }
} }
@Inject(method = "Lnet/minecraft/world/level/block/ChorusPlantBlock;getStateForPlacement" + "(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)" + "Lnet/minecraft/world/level/block/state/BlockState;", at = @At("RETURN"), cancellable = true) @Inject(method = "getStateWithConnections", at = @At("RETURN"), cancellable = true)
private void be_getStateForPlacement( private static void be_getStateWithConnections(
BlockGetter blockGetter, BlockGetter blockGetter, BlockPos blockPos, BlockState blockState, CallbackInfoReturnable<BlockState> cir
BlockPos blockPos,
CallbackInfoReturnable<BlockState> info
) { ) {
BlockState plant = info.getReturnValue(); BlockState plant = cir.getReturnValue();
if (plant.is(Blocks.CHORUS_PLANT) && blockGetter.getBlockState(blockPos.below()) if (plant.is(Blocks.CHORUS_PLANT) && blockGetter.getBlockState(blockPos.below())
.is(CommonBlockTags.END_STONES)) { .is(CommonBlockTags.END_STONES)) {
info.setReturnValue(plant.setValue(BlockStateProperties.DOWN, true)); cir.setReturnValue(plant.setValue(BlockStateProperties.DOWN, true));
} }
} }

View file

@ -20,9 +20,7 @@ public abstract class CraftingMenuMixin {
@Inject(method = "stillValid", at = @At("HEAD"), cancellable = true) @Inject(method = "stillValid", at = @At("HEAD"), cancellable = true)
private void be_stillValid(Player player, CallbackInfoReturnable<Boolean> info) { private void be_stillValid(Player player, CallbackInfoReturnable<Boolean> info) {
if (access.evaluate((world, pos) -> { if (access.evaluate((world, pos) -> world.getBlockState(pos).getBlock() instanceof CraftingTableBlock, true)) {
return world.getBlockState(pos).getBlock() instanceof CraftingTableBlock;
}, true)) {
info.setReturnValue(true); info.setReturnValue(true);
} }
} }

View file

@ -21,6 +21,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.ModifyVariable;
@ -30,6 +31,7 @@ import java.util.Optional;
@Mixin(EndPodiumFeature.class) @Mixin(EndPodiumFeature.class)
public class EndPodiumFeatureMixin { public class EndPodiumFeatureMixin {
@Unique
private static BlockPos be_portalPosition; private static BlockPos be_portalPosition;
@Final @Final
@ -59,11 +61,11 @@ public class EndPodiumFeatureMixin {
} }
} }
@ModifyVariable(method = "place", ordinal = 0, at = @At("HEAD")) @ModifyVariable(method = "place", ordinal = 0, at = @At("HEAD"), argsOnly = true)
private FeaturePlaceContext<NoneFeatureConfiguration> be_setPosOnGround(FeaturePlaceContext<NoneFeatureConfiguration> featurePlaceContext) { private FeaturePlaceContext<NoneFeatureConfiguration> be_setPosOnGround(FeaturePlaceContext<NoneFeatureConfiguration> featurePlaceContext) {
WorldGenLevel world = featurePlaceContext.level(); WorldGenLevel world = featurePlaceContext.level();
BlockPos pos = be_updatePortalPos(world); BlockPos pos = be_updatePortalPos(world);
return new FeaturePlaceContext<NoneFeatureConfiguration>( return new FeaturePlaceContext<>(
Optional.empty(), Optional.empty(),
world, world,
featurePlaceContext.chunkGenerator(), featurePlaceContext.chunkGenerator(),
@ -73,6 +75,7 @@ public class EndPodiumFeatureMixin {
); );
} }
@Unique
private BlockPos be_updatePortalPos(WorldGenLevel world) { private BlockPos be_updatePortalPos(WorldGenLevel world) {
CompoundTag compound = WorldConfig.getRootTag(BetterEnd.MOD_ID).getCompound("portal"); CompoundTag compound = WorldConfig.getRootTag(BetterEnd.MOD_ID).getCompound("portal");
be_portalPosition = NbtUtils.readBlockPos(compound); be_portalPosition = NbtUtils.readBlockPos(compound);

View file

@ -21,6 +21,7 @@ import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.ModifyArg;
@ -40,9 +41,10 @@ public abstract class LivingEntityMixin extends Entity {
@Shadow @Shadow
public abstract AttributeMap getAttributes(); public abstract AttributeMap getAttributes();
private Entity lastAttacker; @Unique
private Entity be_lastAttacker;
@Inject(method = "createLivingAttributes", at = @At("RETURN"), cancellable = true) @Inject(method = "createLivingAttributes", at = @At("RETURN"))
private static void be_addLivingAttributes(CallbackInfoReturnable<AttributeSupplier.Builder> info) { private static void be_addLivingAttributes(CallbackInfoReturnable<AttributeSupplier.Builder> info) {
EndAttributes.addLivingEntityAttributes(info.getReturnValue()); EndAttributes.addLivingEntityAttributes(info.getReturnValue());
} }
@ -75,23 +77,23 @@ public abstract class LivingEntityMixin extends Entity {
@Inject(method = "hurt", at = @At("HEAD")) @Inject(method = "hurt", at = @At("HEAD"))
public void be_hurt(DamageSource source, float amount, CallbackInfoReturnable<Boolean> info) { public void be_hurt(DamageSource source, float amount, CallbackInfoReturnable<Boolean> info) {
this.lastAttacker = source.getEntity(); this.be_lastAttacker = source.getEntity();
} }
@ModifyArg(method = "hurt", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;knockback(DDD)V"), index = 0) @ModifyArg(method = "hurt", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;knockback(DDD)V"), index = 0)
private double be_increaseKnockback(double value, double x, double z) { private double be_increaseKnockback(double value, double x, double z) {
if (lastAttacker != null && lastAttacker instanceof LivingEntity) { if (be_lastAttacker != null && be_lastAttacker instanceof LivingEntity attacker) {
LivingEntity attacker = (LivingEntity) lastAttacker;
value += this.be_getKnockback(attacker.getMainHandItem().getItem()); value += this.be_getKnockback(attacker.getMainHandItem().getItem());
} }
return value; return value;
} }
@Unique
private double be_getKnockback(Item tool) { private double be_getKnockback(Item tool) {
if (tool == null) return 0.0D; if (tool == null) return 0.0D;
Collection<AttributeModifier> modifiers = tool.getDefaultAttributeModifiers(EquipmentSlot.MAINHAND) Collection<AttributeModifier> modifiers = tool.getDefaultAttributeModifiers(EquipmentSlot.MAINHAND)
.get(Attributes.ATTACK_KNOCKBACK); .get(Attributes.ATTACK_KNOCKBACK);
if (modifiers.size() > 0) { if (!modifiers.isEmpty()) {
return modifiers.iterator().next().getAmount(); return modifiers.iterator().next().getAmount();
} }
return 0.0D; return 0.0D;

View file

@ -10,6 +10,7 @@ import net.minecraft.world.level.levelgen.blending.Blender;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@ -18,6 +19,7 @@ import java.util.List;
@Mixin(NoiseChunk.class) @Mixin(NoiseChunk.class)
public class NoiseChunkMixin implements BETargetChecker { public class NoiseChunkMixin implements BETargetChecker {
@Unique
private boolean be_isEndGenerator; private boolean be_isEndGenerator;
@Inject(method = "<init>*", at = @At("TAIL")) @Inject(method = "<init>*", at = @At("TAIL"))
@ -50,7 +52,7 @@ public class NoiseChunkMixin implements BETargetChecker {
@Shadow @Shadow
@Final @Final
private List<NoiseChunk.NoiseInterpolator> interpolators; List<NoiseChunk.NoiseInterpolator> interpolators;
@Inject(method = "fillSlice", at = @At("HEAD"), cancellable = true) @Inject(method = "fillSlice", at = @At("HEAD"), cancellable = true)
private void be_fillSlice(boolean primarySlice, int x, CallbackInfo info) { private void be_fillSlice(boolean primarySlice, int x, CallbackInfo info) {

View file

@ -5,9 +5,11 @@ import org.betterx.betterend.interfaces.BETargetChecker;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
@Mixin(NoiseGeneratorSettings.class) @Mixin(NoiseGeneratorSettings.class)
public class NoiseGeneratorSettingsMixin implements BETargetChecker { public class NoiseGeneratorSettingsMixin implements BETargetChecker {
@Unique
private boolean be_isTargetGenerator; private boolean be_isTargetGenerator;
@Override @Override

View file

@ -17,6 +17,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@ -29,7 +30,8 @@ public abstract class PlayerMixin extends LivingEntity {
super(entityType, level); super(entityType, level);
} }
private static Direction[] horizontal; @Unique
private static Direction[] be_horizontal;
@Inject(method = "findRespawnPositionAndUseSpawnBlock", at = @At(value = "HEAD"), cancellable = true) @Inject(method = "findRespawnPositionAndUseSpawnBlock", at = @At(value = "HEAD"), cancellable = true)
private static void be_findRespawnPositionAndUseSpawnBlock( private static void be_findRespawnPositionAndUseSpawnBlock(
@ -47,17 +49,18 @@ public abstract class PlayerMixin extends LivingEntity {
} }
} }
@Unique
private static Optional<Vec3> be_obeliskRespawnPosition(ServerLevel world, BlockPos pos, BlockState state) { private static Optional<Vec3> be_obeliskRespawnPosition(ServerLevel world, BlockPos pos, BlockState state) {
if (state.getValue(BlockProperties.TRIPLE_SHAPE) == TripleShape.TOP) { if (state.getValue(BlockProperties.TRIPLE_SHAPE) == TripleShape.TOP) {
pos = pos.below(2); pos = pos.below(2);
} else if (state.getValue(BlockProperties.TRIPLE_SHAPE) == TripleShape.MIDDLE) { } else if (state.getValue(BlockProperties.TRIPLE_SHAPE) == TripleShape.MIDDLE) {
pos = pos.below(); pos = pos.below();
} }
if (horizontal == null) { if (be_horizontal == null) {
horizontal = BlocksHelper.makeHorizontal(); be_horizontal = BlocksHelper.makeHorizontal();
} }
MHelper.shuffle(horizontal, world.getRandom()); MHelper.shuffle(be_horizontal, world.getRandom());
for (Direction dir : horizontal) { for (Direction dir : be_horizontal) {
BlockPos p = pos.relative(dir); BlockPos p = pos.relative(dir);
BlockState state2 = world.getBlockState(p); BlockState state2 = world.getBlockState(p);
if (!state2.blocksMotion() && state2.getCollisionShape(world, pos).isEmpty()) { if (!state2.blocksMotion() && state2.getCollisionShape(world, pos).isEmpty()) {

View file

@ -16,6 +16,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.progress.ChunkProgressListener; import net.minecraft.server.level.progress.ChunkProgressListener;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.RandomSequences; import net.minecraft.world.RandomSequences;
import net.minecraft.world.level.CustomSpawner;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
@ -38,13 +39,6 @@ import java.util.function.Supplier;
@Mixin(ServerLevel.class) @Mixin(ServerLevel.class)
public abstract class ServerLevelMixin extends Level { public abstract class ServerLevelMixin extends Level {
private final static List<ResourceKey<DimensionType>> BE_TEST_DIMENSIONS = List.of(
BuiltinDimensionTypes.OVERWORLD,
BuiltinDimensionTypes.OVERWORLD_CAVES,
BuiltinDimensionTypes.NETHER
);
protected ServerLevelMixin( protected ServerLevelMixin(
WritableLevelData writableLevelData, WritableLevelData writableLevelData,
ResourceKey<Level> resourceKey, ResourceKey<Level> resourceKey,
@ -74,12 +68,12 @@ public abstract class ServerLevelMixin extends Level {
Executor executor, Executor executor,
LevelStorageAccess levelStorageAccess, LevelStorageAccess levelStorageAccess,
ServerLevelData serverLevelData, ServerLevelData serverLevelData,
ResourceKey resourceKey, ResourceKey<Level> resourceKey,
LevelStem levelStem, LevelStem levelStem,
ChunkProgressListener chunkProgressListener, ChunkProgressListener chunkProgressListener,
boolean bl, boolean bl,
long seed, long seed,
List list, List<CustomSpawner> list,
boolean bl2, boolean bl2,
RandomSequences randomSequences, RandomSequences randomSequences,
CallbackInfo ci CallbackInfo ci
@ -93,7 +87,7 @@ public abstract class ServerLevelMixin extends Level {
TerrainGenerator.makeObsidianPlatform(serverLevel, info); TerrainGenerator.makeObsidianPlatform(serverLevel, info);
} }
@ModifyArg(method = "tickChunk", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;setBlockAndUpdate(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z")) @ModifyArg(method = "tickPrecipitation", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerLevel;setBlockAndUpdate(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)Z"))
private BlockState be_modifyTickState(BlockPos pos, BlockState state) { private BlockState be_modifyTickState(BlockPos pos, BlockState state) {
if (state.is(Blocks.ICE)) { if (state.is(Blocks.ICE)) {
ResourceLocation biome = BiomeAPI.getBiomeID(getBiome(pos)); ResourceLocation biome = BiomeAPI.getBiomeID(getBiome(pos));

View file

@ -26,7 +26,7 @@ public abstract class SlimeMixin extends Entity implements ISlime {
} }
@Override @Override
public void entityRemove(Entity.RemovalReason removalReason) { public void be_entityRemove(Entity.RemovalReason removalReason) {
super.remove(removalReason); super.remove(removalReason);
} }
} }

View file

@ -26,6 +26,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlac
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@ -106,7 +107,7 @@ public class SpikeFeatureMixin {
if (x2 + z2 <= r2) { if (x2 + z2 <= r2) {
for (int py = minY; py < maxY; py++) { for (int py = minY; py < maxY; py++) {
mut.setY(py); mut.setY(py);
if (world.getBlockState(mut).canBeReplaced()){ if (world.getBlockState(mut).canBeReplaced()) {
if ((px == radius || px == -radius || pz == radius || pz == -radius) && random.nextInt( if ((px == radius || px == -radius || pz == radius || pz == -radius) && random.nextInt(
24) == 0) { 24) == 0) {
BlocksHelper.setWithoutUpdate(world, mut, Blocks.CRYING_OBSIDIAN); BlocksHelper.setWithoutUpdate(world, mut, Blocks.CRYING_OBSIDIAN);
@ -131,7 +132,7 @@ public class SpikeFeatureMixin {
if (x2 + z2 <= r2) { if (x2 + z2 <= r2) {
for (int py = minY; py < maxY; py++) { for (int py = minY; py < maxY; py++) {
mut.setY(py); mut.setY(py);
if (world.getBlockState(mut).canBeReplaced()){ if (world.getBlockState(mut).canBeReplaced()) {
BlocksHelper.setWithoutUpdate(world, mut, Blocks.OBSIDIAN); BlocksHelper.setWithoutUpdate(world, mut, Blocks.OBSIDIAN);
} }
} }
@ -186,6 +187,7 @@ public class SpikeFeatureMixin {
info.cancel(); info.cancel();
} }
@Unique
private boolean be_radiusInRange(int radius) { private boolean be_radiusInRange(int radius) {
return radius > 1 && radius < 6; return radius > 1 && radius < 6;
} }

View file

@ -23,7 +23,6 @@ public class WorldGenRegionMixin {
ChunkPos cPos = center.getPos(); ChunkPos cPos = center.getPos();
int x = blockPos.getX() >> 4; int x = blockPos.getX() >> 4;
int z = blockPos.getZ() >> 4; int z = blockPos.getZ() >> 4;
WorldGenRegion region = (WorldGenRegion) (Object) this;
info.setReturnValue(Math.abs(x - cPos.x) < 2 && Math.abs(z - cPos.z) < 2); info.setReturnValue(Math.abs(x - cPos.x) < 2 && Math.abs(z - cPos.z) < 2);
} }
} }

View file

@ -3,19 +3,18 @@ package org.betterx.betterend.mixin.common.portal;
import org.betterx.betterend.portal.TravelerState; import org.betterx.betterend.portal.TravelerState;
import org.betterx.betterend.portal.TravelingEntity; import org.betterx.betterend.portal.TravelingEntity;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.portal.PortalInfo;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Entity.class) @Mixin(Entity.class)
public class EntityMixin implements TravelingEntity { public class EntityMixin implements TravelingEntity {
@Unique
private final TravelerState be_travelerState = TravelerState.init((net.minecraft.world.entity.Entity) (Object) this); private final TravelerState be_travelerState = TravelerState.init((net.minecraft.world.entity.Entity) (Object) this);
public TravelerState be_getTravelerState() { public TravelerState be_getTravelerState() {
@ -26,12 +25,4 @@ public class EntityMixin implements TravelingEntity {
void be_handleNetherPortal(CallbackInfo ci) { void be_handleNetherPortal(CallbackInfo ci) {
if (be_travelerState != null) be_travelerState.portalTick(); if (be_travelerState != null) be_travelerState.portalTick();
} }
@Inject(method = "findDimensionEntryPoint", at = @At("HEAD"), cancellable = true)
void be_findDimensionEntryPoint(ServerLevel serverLevel, CallbackInfoReturnable<PortalInfo> cir) {
// if (be_travelerState != null) {
// PortalInfo pi = be_travelerState.findDimensionEntryPoint(serverLevel);
// if (pi != null) cir.setReturnValue(pi);
// }
}
} }