diff --git a/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java b/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java index 361e16a5..c17e5e26 100644 --- a/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java +++ b/src/main/java/ru/betterend/mixin/common/ChorusFlowerBlockMixin.java @@ -41,7 +41,7 @@ public abstract class ChorusFlowerBlockMixin extends Block { private ChorusPlantBlock plantBlock; @Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true) - private void canPlace(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable info) { + private void beCanPlace(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable info) { if (world.getBlockState(pos.down()).isOf(BlockRegistry.CHORUS_NYLIUM)) { info.setReturnValue(true); info.cancel(); @@ -49,7 +49,7 @@ public abstract class ChorusFlowerBlockMixin extends Block { } @Inject(method = "randomTick", at = @At("HEAD"), cancellable = true) - private void onTick(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo info) { + private void beOnTick(BlockState state, ServerWorld world, BlockPos pos, Random random, CallbackInfo info) { if (world.getBlockState(pos.down()).isIn(BlockTagRegistry.END_GROUND)) { BlockPos up = pos.up(); if (world.isAir(up) && up.getY() < 256) { diff --git a/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java b/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java index 323c8ca0..52dc1f08 100644 --- a/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java +++ b/src/main/java/ru/betterend/mixin/common/ChorusPlantBlockMixin.java @@ -6,6 +6,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import net.minecraft.block.AbstractBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -19,15 +20,24 @@ import ru.betterend.registry.BlockRegistry; import ru.betterend.registry.BlockTagRegistry; import ru.betterend.util.BlocksHelper; -@Mixin(ChorusPlantBlock.class) -public class ChorusPlantBlockMixin { +@Mixin(value = ChorusPlantBlock.class, priority = 500) +public abstract class ChorusPlantBlockMixin extends Block { + public ChorusPlantBlockMixin(Settings settings) { + super(settings); + } + + @Inject(method = "*", at = @At("TAIL")) + private void beOnInit(AbstractBlock.Settings settings, CallbackInfo info) { + this.setDefaultState(this.getDefaultState().with(BlocksHelper.ROOTS, false)); + } + @Inject(method = "appendProperties", at = @At("TAIL")) - private void addProperties(StateManager.Builder builder, CallbackInfo info) { + private void beAddProperties(StateManager.Builder builder, CallbackInfo info) { builder.add(BlocksHelper.ROOTS); } @Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true) - private void canPlace(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable info) { + private void beCanPlace(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable info) { if (world.getBlockState(pos.down()).isOf(BlockRegistry.CHORUS_NYLIUM)) { info.setReturnValue(true); info.cancel(); @@ -35,7 +45,7 @@ public class ChorusPlantBlockMixin { } @Inject(method = "withConnectionProperties", at = @At("RETURN"), cancellable = true) - private void withConnectionProperties(BlockView world, BlockPos pos, CallbackInfoReturnable info) { + private void beConnectionProperties(BlockView world, BlockPos pos, CallbackInfoReturnable info) { BlockState plant = info.getReturnValue(); if (plant.isOf(Blocks.CHORUS_PLANT)) { if (!plant.get(Properties.DOWN) && world.getBlockState(pos.down()).isIn(BlockTagRegistry.END_GROUND)) { diff --git a/src/main/java/ru/betterend/mixin/common/ChunkSerializerMixin.java b/src/main/java/ru/betterend/mixin/common/ChunkSerializerMixin.java deleted file mode 100644 index 7464cf6e..00000000 --- a/src/main/java/ru/betterend/mixin/common/ChunkSerializerMixin.java +++ /dev/null @@ -1,46 +0,0 @@ -package ru.betterend.mixin.common; - -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - -import it.unimi.dsi.fastutil.longs.LongSet; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.LongArrayTag; -import net.minecraft.structure.StructureStart; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.ChunkSerializer; -import net.minecraft.world.gen.feature.StructureFeature; - -@Mixin(ChunkSerializer.class) -public class ChunkSerializerMixin { - @Overwrite - private static CompoundTag writeStructures(ChunkPos pos, Map, StructureStart> structureStarts, Map, LongSet> structureReferences) { - CompoundTag tagResult = new CompoundTag(); - CompoundTag tagStarts = new CompoundTag(); - Iterator, StructureStart>> startsIterator = structureStarts.entrySet().iterator(); - - while (startsIterator.hasNext()) { - Entry, StructureStart> start = startsIterator.next(); - tagStarts.put((start.getKey()).getName(), (start.getValue()).toTag(pos.x, pos.z)); - } - - tagResult.put("Starts", tagStarts); - CompoundTag tagReferences = new CompoundTag(); - Iterator, LongSet>> refIterator = structureReferences.entrySet().iterator(); - - while (refIterator.hasNext()) { - Entry, LongSet> feature = refIterator.next(); - // Structures sometimes can be null - if (feature.getKey() != null) { - tagReferences.put((feature.getKey()).getName(), new LongArrayTag(feature.getValue())); - } - } - - tagResult.put("References", tagReferences); - return tagResult; - } -} diff --git a/src/main/java/ru/betterend/mixin/common/RecipeManagerMixin.java b/src/main/java/ru/betterend/mixin/common/RecipeManagerMixin.java index a9b86254..0528bc52 100644 --- a/src/main/java/ru/betterend/mixin/common/RecipeManagerMixin.java +++ b/src/main/java/ru/betterend/mixin/common/RecipeManagerMixin.java @@ -32,7 +32,7 @@ public class RecipeManagerMixin { private Map, Map>> recipes; @Inject(method = "apply", at = @At(value = "RETURN")) - private void setRecipes(Map map, ResourceManager resourceManager, Profiler profiler, CallbackInfo info) { + private void beSetRecipes(Map map, ResourceManager resourceManager, Profiler profiler, CallbackInfo info) { recipes = EndRecipeManager.getMap(recipes); } diff --git a/src/main/java/ru/betterend/registry/FeatureRegistry.java b/src/main/java/ru/betterend/registry/FeatureRegistry.java index 2db82809..5151d2f8 100644 --- a/src/main/java/ru/betterend/registry/FeatureRegistry.java +++ b/src/main/java/ru/betterend/registry/FeatureRegistry.java @@ -73,7 +73,11 @@ public class FeatureRegistry { if (path.equals("end_highlands") || path.equals("end_midlands") || path.equals("small_end_islands")) { int pos = GenerationStep.Feature.VEGETAL_DECORATION.ordinal(); if (pos < features.size()) { - features.get(pos).clear(); + List>> list = features.get(pos); + // If only chorus plants are enabled + if (list.size() < 2) { + features.get(pos).clear(); + } } } } diff --git a/src/main/resources/betterend.mixins.common.json b/src/main/resources/betterend.mixins.common.json index 46a6421f..02dd7497 100644 --- a/src/main/resources/betterend.mixins.common.json +++ b/src/main/resources/betterend.mixins.common.json @@ -13,7 +13,6 @@ "ChorusFlowerBlockMixin", "ChorusPlantBlockMixin", "RecipeManagerAccessor", - "ChunkSerializerMixin", "MinecraftServerMixin", "TagGroupLoaderMixin", "EndermanEntityMixin",