Fixed Mixins
This commit is contained in:
parent
abc02da0fe
commit
8c7bf0cac2
19 changed files with 105 additions and 95 deletions
|
@ -170,7 +170,7 @@ public class EndSlimeEntity extends Slime {
|
|||
}
|
||||
}
|
||||
|
||||
((ISlime) this).entityRemove(reason);
|
||||
((ISlime) this).be_entityRemove(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,5 +5,5 @@ import net.minecraft.world.entity.Entity;
|
|||
public interface ISlime {
|
||||
void be_setSlimeSize(int size, boolean heal);
|
||||
|
||||
void entityRemove(Entity.RemovalReason removalReason);
|
||||
void be_entityRemove(Entity.RemovalReason removalReason);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.world.level.BlockAndTintGetter;
|
|||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
@ -24,22 +25,26 @@ import java.util.Comparator;
|
|||
|
||||
@Mixin(BiomeColors.class)
|
||||
public class BiomeColorsMixin {
|
||||
private static final int POISON_COLOR = ColorUtil.color(92, 160, 78);
|
||||
private static final int STREAM_COLOR = ColorUtil.color(105, 213, 244);
|
||||
private static final Point[] OFFSETS;
|
||||
private static final boolean HAS_SODIUM;
|
||||
@Unique
|
||||
private static final int BE_POISON_COLOR = ColorUtil.color(92, 160, 78);
|
||||
@Unique
|
||||
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)
|
||||
private static void be_getWaterColor(BlockAndTintGetter world, BlockPos pos, CallbackInfoReturnable<Integer> info) {
|
||||
if (ClientOptions.useSulfurWaterColor()) {
|
||||
BlockAndTintGetter view = HAS_SODIUM ? Minecraft.getInstance().level : world;
|
||||
BlockAndTintGetter view = BE_HAS_SODIUM ? Minecraft.getInstance().level : world;
|
||||
MutableBlockPos mut = new MutableBlockPos();
|
||||
mut.setY(pos.getY());
|
||||
for (int i = 0; i < OFFSETS.length; i++) {
|
||||
mut.setX(pos.getX() + OFFSETS[i].x);
|
||||
mut.setZ(pos.getZ() + OFFSETS[i].y);
|
||||
for (int i = 0; i < BE_OFFSETS.length; i++) {
|
||||
mut.setX(pos.getX() + BE_OFFSETS[i].x);
|
||||
mut.setZ(pos.getZ() + BE_OFFSETS[i].y);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -47,17 +52,17 @@ public class BiomeColorsMixin {
|
|||
}
|
||||
|
||||
static {
|
||||
HAS_SODIUM = FabricLoader.getInstance().isModLoaded("sodium");
|
||||
BE_HAS_SODIUM = FabricLoader.getInstance().isModLoaded("sodium");
|
||||
|
||||
int index = 0;
|
||||
OFFSETS = new Point[20];
|
||||
BE_OFFSETS = new Point[20];
|
||||
for (int x = -2; x < 3; x++) {
|
||||
for (int z = -2; z < 3; z++) {
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
@Mixin(CapeLayer.class)
|
||||
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(
|
||||
PoseStack poseStack,
|
||||
MultiBufferSource multiBufferSource,
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.minecraft.client.resources.model.ModelBakery;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
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.ModifyArg;
|
||||
|
||||
|
@ -22,12 +23,10 @@ public abstract class ModelLoaderMixin {
|
|||
return loc;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean be_changeModel(ResourceLocation id) {
|
||||
if (id.getNamespace().equals("minecraft")) {
|
||||
if (id.getPath().contains("chorus") && !id.getPath().contains("custom_")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return id.getPath().contains("chorus") && !id.getPath().contains("custom_");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.util.RandomSource;
|
|||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
@ -35,39 +36,42 @@ public abstract class MusicTrackerMixin {
|
|||
@Shadow
|
||||
private int nextSongDelay;
|
||||
|
||||
private static float volume = 1;
|
||||
private static float srcVolume = 0;
|
||||
private static long time;
|
||||
@Unique
|
||||
private static float be_volume = 1;
|
||||
@Unique
|
||||
private static float be_srcVolume = 0;
|
||||
@Unique
|
||||
private static long be_time;
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
|
||||
public void be_onTick(CallbackInfo info) {
|
||||
if (ClientOptions.blendBiomeMusic()) {
|
||||
Music musicSound = minecraft.getSituationalMusic();
|
||||
if (be_checkNullSound(musicSound) && volume > 0 && be_shouldChangeSound(musicSound) && be_isCorrectBiome()) {
|
||||
if (volume > 0) {
|
||||
if (srcVolume < 0) {
|
||||
srcVolume = currentMusic.getVolume();
|
||||
if (be_checkNullSound(musicSound) && be_volume > 0 && be_shouldChangeSound(musicSound) && be_isCorrectBiome()) {
|
||||
if (be_volume > 0) {
|
||||
if (be_srcVolume < 0) {
|
||||
be_srcVolume = currentMusic.getVolume();
|
||||
}
|
||||
if (currentMusic instanceof AbstractSoundInstance) {
|
||||
((AbstractSoundInstanceAccessor) currentMusic).setVolume(volume);
|
||||
((AbstractSoundInstanceAccessor) currentMusic).setVolume(be_volume);
|
||||
}
|
||||
minecraft.getSoundManager()
|
||||
.updateSourceVolume(currentMusic.getSource(), currentMusic.getVolume() * volume);
|
||||
.updateSourceVolume(currentMusic.getSource(), currentMusic.getVolume() * be_volume);
|
||||
long t = System.currentTimeMillis();
|
||||
if (volume == 1 && time == 0) {
|
||||
time = t;
|
||||
if (be_volume == 1 && be_time == 0) {
|
||||
be_time = t;
|
||||
}
|
||||
float delta = (t - time) * 0.0005F;
|
||||
time = t;
|
||||
volume -= delta;
|
||||
if (volume < 0) {
|
||||
volume = 0;
|
||||
float delta = (t - be_time) * 0.0005F;
|
||||
be_time = t;
|
||||
be_volume -= delta;
|
||||
if (be_volume < 0) {
|
||||
be_volume = 0;
|
||||
}
|
||||
}
|
||||
if (volume == 0) {
|
||||
volume = 1;
|
||||
time = 0;
|
||||
srcVolume = -1;
|
||||
if (be_volume == 0) {
|
||||
be_volume = 1;
|
||||
be_time = 0;
|
||||
be_srcVolume = -1;
|
||||
this.minecraft.getSoundManager().stop(this.currentMusic);
|
||||
this.nextSongDelay = Mth.nextInt(this.random, 0, musicSound.getMinDelay() / 2);
|
||||
this.currentMusic = null;
|
||||
|
@ -77,11 +81,12 @@ public abstract class MusicTrackerMixin {
|
|||
}
|
||||
info.cancel();
|
||||
} else {
|
||||
volume = 1;
|
||||
be_volume = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean be_isCorrectBiome() {
|
||||
if (minecraft.level == null) {
|
||||
return false;
|
||||
|
@ -90,6 +95,7 @@ public abstract class MusicTrackerMixin {
|
|||
.value()) instanceof EndBiome;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean be_shouldChangeSound(Music musicSound) {
|
||||
return currentMusic != null && !musicSound
|
||||
.getEvent()
|
||||
|
@ -98,6 +104,7 @@ public abstract class MusicTrackerMixin {
|
|||
.equals(this.currentMusic.getLocation()) && musicSound.replaceCurrentMusic();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean be_checkNullSound(Music musicSound) {
|
||||
return musicSound != null && musicSound.getEvent() != null;
|
||||
}
|
||||
|
|
|
@ -23,15 +23,20 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
|||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Mixin(value = ChorusFlowerBlock.class, priority = 100)
|
||||
public abstract class ChorusFlowerBlockMixin extends Block {
|
||||
private static final VoxelShape SHAPE_FULL = Block.box(0, 0, 0, 16, 16, 16);
|
||||
private static final VoxelShape SHAPE_HALF = Block.box(0, 0, 0, 16, 4, 16);
|
||||
@Unique
|
||||
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) {
|
||||
super(settings);
|
||||
|
@ -87,9 +92,9 @@ public abstract class ChorusFlowerBlockMixin extends Block {
|
|||
|
||||
@Override
|
||||
@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()) {
|
||||
return state.getValue(ChorusFlowerBlock.AGE) == 5 ? SHAPE_HALF : SHAPE_FULL;
|
||||
return state.getValue(ChorusFlowerBlock.AGE) == 5 ? BE_SHAPE_HALF : BE_SHAPE_FULL;
|
||||
} else {
|
||||
return super.getShape(state, world, pos, context);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ public abstract class ChorusPlantBlockMixin extends Block {
|
|||
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) {
|
||||
BlockPos pos = ctx.getClickedPos();
|
||||
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)
|
||||
private void be_getStateForPlacement(
|
||||
BlockGetter blockGetter,
|
||||
BlockPos blockPos,
|
||||
CallbackInfoReturnable<BlockState> info
|
||||
@Inject(method = "getStateWithConnections", at = @At("RETURN"), cancellable = true)
|
||||
private static void be_getStateWithConnections(
|
||||
BlockGetter blockGetter, BlockPos blockPos, BlockState blockState, CallbackInfoReturnable<BlockState> cir
|
||||
) {
|
||||
BlockState plant = info.getReturnValue();
|
||||
BlockState plant = cir.getReturnValue();
|
||||
if (plant.is(Blocks.CHORUS_PLANT) && blockGetter.getBlockState(blockPos.below())
|
||||
.is(CommonBlockTags.END_STONES)) {
|
||||
info.setReturnValue(plant.setValue(BlockStateProperties.DOWN, true));
|
||||
cir.setReturnValue(plant.setValue(BlockStateProperties.DOWN, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,7 @@ public abstract class CraftingMenuMixin {
|
|||
|
||||
@Inject(method = "stillValid", at = @At("HEAD"), cancellable = true)
|
||||
private void be_stillValid(Player player, CallbackInfoReturnable<Boolean> info) {
|
||||
if (access.evaluate((world, pos) -> {
|
||||
return world.getBlockState(pos).getBlock() instanceof CraftingTableBlock;
|
||||
}, true)) {
|
||||
if (access.evaluate((world, pos) -> world.getBlockState(pos).getBlock() instanceof CraftingTableBlock, true)) {
|
||||
info.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp
|
|||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
|
@ -30,6 +31,7 @@ import java.util.Optional;
|
|||
|
||||
@Mixin(EndPodiumFeature.class)
|
||||
public class EndPodiumFeatureMixin {
|
||||
@Unique
|
||||
private static BlockPos be_portalPosition;
|
||||
|
||||
@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) {
|
||||
WorldGenLevel world = featurePlaceContext.level();
|
||||
BlockPos pos = be_updatePortalPos(world);
|
||||
return new FeaturePlaceContext<NoneFeatureConfiguration>(
|
||||
return new FeaturePlaceContext<>(
|
||||
Optional.empty(),
|
||||
world,
|
||||
featurePlaceContext.chunkGenerator(),
|
||||
|
@ -73,6 +75,7 @@ public class EndPodiumFeatureMixin {
|
|||
);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private BlockPos be_updatePortalPos(WorldGenLevel world) {
|
||||
CompoundTag compound = WorldConfig.getRootTag(BetterEnd.MOD_ID).getCompound("portal");
|
||||
be_portalPosition = NbtUtils.readBlockPos(compound);
|
||||
|
|
|
@ -21,6 +21,7 @@ import net.minecraft.world.level.Level;
|
|||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
@ -40,9 +41,10 @@ public abstract class LivingEntityMixin extends Entity {
|
|||
@Shadow
|
||||
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) {
|
||||
EndAttributes.addLivingEntityAttributes(info.getReturnValue());
|
||||
}
|
||||
|
@ -75,23 +77,23 @@ public abstract class LivingEntityMixin extends Entity {
|
|||
|
||||
@Inject(method = "hurt", at = @At("HEAD"))
|
||||
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)
|
||||
private double be_increaseKnockback(double value, double x, double z) {
|
||||
if (lastAttacker != null && lastAttacker instanceof LivingEntity) {
|
||||
LivingEntity attacker = (LivingEntity) lastAttacker;
|
||||
if (be_lastAttacker != null && be_lastAttacker instanceof LivingEntity attacker) {
|
||||
value += this.be_getKnockback(attacker.getMainHandItem().getItem());
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private double be_getKnockback(Item tool) {
|
||||
if (tool == null) return 0.0D;
|
||||
Collection<AttributeModifier> modifiers = tool.getDefaultAttributeModifiers(EquipmentSlot.MAINHAND)
|
||||
.get(Attributes.ATTACK_KNOCKBACK);
|
||||
if (modifiers.size() > 0) {
|
||||
if (!modifiers.isEmpty()) {
|
||||
return modifiers.iterator().next().getAmount();
|
||||
}
|
||||
return 0.0D;
|
||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.world.level.levelgen.blending.Blender;
|
|||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
@ -18,6 +19,7 @@ import java.util.List;
|
|||
|
||||
@Mixin(NoiseChunk.class)
|
||||
public class NoiseChunkMixin implements BETargetChecker {
|
||||
@Unique
|
||||
private boolean be_isEndGenerator;
|
||||
|
||||
@Inject(method = "<init>*", at = @At("TAIL"))
|
||||
|
@ -50,7 +52,7 @@ public class NoiseChunkMixin implements BETargetChecker {
|
|||
|
||||
@Shadow
|
||||
@Final
|
||||
private List<NoiseChunk.NoiseInterpolator> interpolators;
|
||||
List<NoiseChunk.NoiseInterpolator> interpolators;
|
||||
|
||||
@Inject(method = "fillSlice", at = @At("HEAD"), cancellable = true)
|
||||
private void be_fillSlice(boolean primarySlice, int x, CallbackInfo info) {
|
||||
|
|
|
@ -5,9 +5,11 @@ import org.betterx.betterend.interfaces.BETargetChecker;
|
|||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(NoiseGeneratorSettings.class)
|
||||
public class NoiseGeneratorSettingsMixin implements BETargetChecker {
|
||||
@Unique
|
||||
private boolean be_isTargetGenerator;
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
@ -29,7 +30,8 @@ public abstract class PlayerMixin extends LivingEntity {
|
|||
super(entityType, level);
|
||||
}
|
||||
|
||||
private static Direction[] horizontal;
|
||||
@Unique
|
||||
private static Direction[] be_horizontal;
|
||||
|
||||
@Inject(method = "findRespawnPositionAndUseSpawnBlock", at = @At(value = "HEAD"), cancellable = true)
|
||||
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) {
|
||||
if (state.getValue(BlockProperties.TRIPLE_SHAPE) == TripleShape.TOP) {
|
||||
pos = pos.below(2);
|
||||
} else if (state.getValue(BlockProperties.TRIPLE_SHAPE) == TripleShape.MIDDLE) {
|
||||
pos = pos.below();
|
||||
}
|
||||
if (horizontal == null) {
|
||||
horizontal = BlocksHelper.makeHorizontal();
|
||||
if (be_horizontal == null) {
|
||||
be_horizontal = BlocksHelper.makeHorizontal();
|
||||
}
|
||||
MHelper.shuffle(horizontal, world.getRandom());
|
||||
for (Direction dir : horizontal) {
|
||||
MHelper.shuffle(be_horizontal, world.getRandom());
|
||||
for (Direction dir : be_horizontal) {
|
||||
BlockPos p = pos.relative(dir);
|
||||
BlockState state2 = world.getBlockState(p);
|
||||
if (!state2.blocksMotion() && state2.getCollisionShape(world, pos).isEmpty()) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.server.level.ServerLevel;
|
|||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.RandomSequences;
|
||||
import net.minecraft.world.level.CustomSpawner;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
@ -38,13 +39,6 @@ import java.util.function.Supplier;
|
|||
|
||||
@Mixin(ServerLevel.class)
|
||||
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(
|
||||
WritableLevelData writableLevelData,
|
||||
ResourceKey<Level> resourceKey,
|
||||
|
@ -74,12 +68,12 @@ public abstract class ServerLevelMixin extends Level {
|
|||
Executor executor,
|
||||
LevelStorageAccess levelStorageAccess,
|
||||
ServerLevelData serverLevelData,
|
||||
ResourceKey resourceKey,
|
||||
ResourceKey<Level> resourceKey,
|
||||
LevelStem levelStem,
|
||||
ChunkProgressListener chunkProgressListener,
|
||||
boolean bl,
|
||||
long seed,
|
||||
List list,
|
||||
List<CustomSpawner> list,
|
||||
boolean bl2,
|
||||
RandomSequences randomSequences,
|
||||
CallbackInfo ci
|
||||
|
@ -93,7 +87,7 @@ public abstract class ServerLevelMixin extends Level {
|
|||
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) {
|
||||
if (state.is(Blocks.ICE)) {
|
||||
ResourceLocation biome = BiomeAPI.getBiomeID(getBiome(pos));
|
||||
|
|
|
@ -26,7 +26,7 @@ public abstract class SlimeMixin extends Entity implements ISlime {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void entityRemove(Entity.RemovalReason removalReason) {
|
||||
public void be_entityRemove(Entity.RemovalReason removalReason) {
|
||||
super.remove(removalReason);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlac
|
|||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
@ -186,6 +187,7 @@ public class SpikeFeatureMixin {
|
|||
info.cancel();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean be_radiusInRange(int radius) {
|
||||
return radius > 1 && radius < 6;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ public class WorldGenRegionMixin {
|
|||
ChunkPos cPos = center.getPos();
|
||||
int x = blockPos.getX() >> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,19 +3,18 @@ package org.betterx.betterend.mixin.common.portal;
|
|||
import org.betterx.betterend.portal.TravelerState;
|
||||
import org.betterx.betterend.portal.TravelingEntity;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.portal.PortalInfo;
|
||||
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public class EntityMixin implements TravelingEntity {
|
||||
|
||||
@Unique
|
||||
private final TravelerState be_travelerState = TravelerState.init((net.minecraft.world.entity.Entity) (Object) this);
|
||||
|
||||
public TravelerState be_getTravelerState() {
|
||||
|
@ -26,12 +25,4 @@ public class EntityMixin implements TravelingEntity {
|
|||
void be_handleNetherPortal(CallbackInfo ci) {
|
||||
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);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue