From 60175b242528b7dc61e009fdfe04f59505a75d88 Mon Sep 17 00:00:00 2001 From: paulevsGitch Date: Mon, 3 May 2021 22:12:20 +0300 Subject: [PATCH 1/2] Recipe fixes --- src/main/java/ru/betterend/recipe/CraftingRecipes.java | 2 +- src/main/java/ru/betterend/registry/EndTags.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/ru/betterend/recipe/CraftingRecipes.java b/src/main/java/ru/betterend/recipe/CraftingRecipes.java index 288fd16e..d3642184 100644 --- a/src/main/java/ru/betterend/recipe/CraftingRecipes.java +++ b/src/main/java/ru/betterend/recipe/CraftingRecipes.java @@ -202,7 +202,7 @@ public class CraftingRecipes { GridRecipe.make("tag_smith_table", Blocks.SMITHING_TABLE).setShape("II", "##", "##").addMaterial('#', ItemTags.PLANKS).addMaterial('I', EndTags.IRON_INGOTS).build(); GridRecipe.make("tag_cauldron", Blocks.CAULDRON).setShape("I I", "I I", "III").addMaterial('I', EndTags.IRON_INGOTS).build(); GridRecipe.make("tag_hopper", Blocks.HOPPER).setShape("I I", "ICI", " I ").addMaterial('I', EndTags.IRON_INGOTS).addMaterial('C', EndTags.ITEM_CHEST).build(); - GridRecipe.make("tag_piston", Blocks.PISTON).setShape("WWW", "CIC", "CDC").addMaterial('I', EndTags.IRON_INGOTS).addMaterial('D', Items.REDSTONE).addMaterial('C', Items.COBBLESTONE).build(); + GridRecipe.make("tag_piston", Blocks.PISTON).setShape("WWW", "CIC", "CDC").addMaterial('I', EndTags.IRON_INGOTS).addMaterial('D', Items.REDSTONE).addMaterial('C', Items.COBBLESTONE).addMaterial('W', ItemTags.PLANKS).build(); GridRecipe.make("tag_rail", Blocks.RAIL).setShape("I I", "ISI", "I I").addMaterial('I', EndTags.IRON_INGOTS).addMaterial('S', Items.STICK).build(); GridRecipe.make("tag_stonecutter", Blocks.STONECUTTER).setShape(" I ", "SSS").addMaterial('I', EndTags.IRON_INGOTS).addMaterial('S', Items.STONE).build(); diff --git a/src/main/java/ru/betterend/registry/EndTags.java b/src/main/java/ru/betterend/registry/EndTags.java index 92aaedb5..a429015b 100644 --- a/src/main/java/ru/betterend/registry/EndTags.java +++ b/src/main/java/ru/betterend/registry/EndTags.java @@ -151,7 +151,7 @@ public class EndTags { TagHelper.addTag(EndTags.DRAGON_IMMUNE, EndBlocks.ENDER_ORE, EndBlocks.ETERNAL_PEDESTAL, EndBlocks.FLAVOLITE_RUNED_ETERNAL, EndBlocks.FLAVOLITE_RUNED); TagHelper.addTag(EndTags.IRON_INGOTS, Items.IRON_INGOT); - TagHelper.addTag(EndTags.IRON_INGOTS, EndBlocks.TERMINITE.ingot); + TagHelper.addTag(EndTags.IRON_INGOTS, EndBlocks.THALLASIUM.ingot); } public static void addSurfaceBlock(Block block) { From 53268ec8c8ef89c8cc5997ed43c28b57843838ff Mon Sep 17 00:00:00 2001 From: paulevsGitch Date: Mon, 3 May 2021 22:53:27 +0300 Subject: [PATCH 2/2] Dragon respawning fix --- .../mixin/common/EndDragonFightMixin.java | 87 +++++++++++++++++++ .../mixin/common/EndPodiumFeatureMixin.java | 5 +- .../ObsidianPillarBasementFeature.java | 13 +-- .../features/EternalPortalStructure.java | 6 +- .../resources/betterend.mixins.common.json | 1 + 5 files changed, 98 insertions(+), 14 deletions(-) create mode 100644 src/main/java/ru/betterend/mixin/common/EndDragonFightMixin.java diff --git a/src/main/java/ru/betterend/mixin/common/EndDragonFightMixin.java b/src/main/java/ru/betterend/mixin/common/EndDragonFightMixin.java new file mode 100644 index 00000000..dc2e8229 --- /dev/null +++ b/src/main/java/ru/betterend/mixin/common/EndDragonFightMixin.java @@ -0,0 +1,87 @@ +package ru.betterend.mixin.common; + +import java.util.List; + +import org.apache.logging.log4j.Logger; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.google.common.collect.Lists; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.boss.enderdragon.EndCrystal; +import net.minecraft.world.level.block.state.pattern.BlockPattern; +import net.minecraft.world.level.dimension.end.DragonRespawnAnimation; +import net.minecraft.world.level.dimension.end.EndDragonFight; +import net.minecraft.world.phys.AABB; +import ru.betterend.util.BlocksHelper; +import ru.betterend.world.generator.GeneratorOptions; + +@Mixin(EndDragonFight.class) +public class EndDragonFightMixin { + @Shadow + private DragonRespawnAnimation respawnStage; + @Shadow + private boolean dragonKilled; + @Shadow + private BlockPos portalLocation; + @Final + @Shadow + private static Logger LOGGER; + @Final + @Shadow + private ServerLevel level; + + @Shadow + private BlockPattern.BlockPatternMatch findExitPortal() { + return null; + } + + @Shadow + private void spawnExitPortal(boolean bl) {} + + @Shadow + private void respawnDragon(List list) {} + + @Inject(method = "tryRespawn", at = @At("HEAD"), cancellable = true) + private void be_tryRespawnDragon(CallbackInfo info) { + if (GeneratorOptions.replacePortal() && GeneratorOptions.hasDragonFights() && this.dragonKilled && this.respawnStage == null) { + BlockPos blockPos = this.portalLocation; + if (blockPos == null) { + LOGGER.debug("Tried to respawn, but need to find the portal first."); + BlockPattern.BlockPatternMatch blockPatternMatch = this.findExitPortal(); + if (blockPatternMatch == null) { + LOGGER.debug("Couldn't find a portal, so we made one."); + this.spawnExitPortal(true); + } + else { + LOGGER.debug("Found the exit portal & temporarily using it."); + } + + blockPos = this.portalLocation; + } + + List crystals = Lists.newArrayList(); + BlockPos center = blockPos.above(2); + for (Direction dir : BlocksHelper.HORIZONTAL) { + List crystalList = this.level.getEntitiesOfClass(EndCrystal.class, new AABB(center.relative(dir, 3))); + if (crystalList.isEmpty()) { + info.cancel(); + return; + } + + crystals.addAll(crystalList); + } + + LOGGER.debug("Found all crystals, respawning dragon."); + this.respawnDragon(crystals); + info.cancel(); + } + } +} diff --git a/src/main/java/ru/betterend/mixin/common/EndPodiumFeatureMixin.java b/src/main/java/ru/betterend/mixin/common/EndPodiumFeatureMixin.java index e96ded09..33a1ebc6 100644 --- a/src/main/java/ru/betterend/mixin/common/EndPodiumFeatureMixin.java +++ b/src/main/java/ru/betterend/mixin/common/EndPodiumFeatureMixin.java @@ -14,6 +14,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.nbt.NbtUtils; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.levelgen.Heightmap.Types; import net.minecraft.world.level.levelgen.feature.EndPodiumFeature; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; @@ -40,7 +41,7 @@ public class EndPodiumFeatureMixin { blockPos = be_updatePos(blockPos, world); StructureTemplate structure = StructureHelper.readStructure(BetterEnd.makeID(active ? "portal/end_portal_active" : "portal/end_portal_inactive")); BlockPos size = structure.getSize(); - blockPos = blockPos.offset(-(size.getX() >> 1), -3, -(size.getZ() >> 1)); + blockPos = blockPos.offset(-(size.getX() >> 1), -1, -(size.getZ() >> 1)); structure.placeInWorldChunk(world, blockPos, new StructurePlaceSettings(), random); info.setReturnValue(true); info.cancel(); @@ -56,7 +57,7 @@ public class EndPodiumFeatureMixin { if (GeneratorOptions.useNewGenerator()) { BlockPos pos = GeneratorOptions.getPortalPos(); if (pos.equals(BlockPos.ZERO)) { - int y = world.getChunk(blockPos).getHeight(Types.WORLD_SURFACE, blockPos.getX(), blockPos.getZ()); + int y = world.getChunk(0, 0, ChunkStatus.FULL).getHeight(Types.WORLD_SURFACE, blockPos.getX(), blockPos.getZ()); if (y < 1) { y = 65; } diff --git a/src/main/java/ru/betterend/world/features/terrain/ObsidianPillarBasementFeature.java b/src/main/java/ru/betterend/world/features/terrain/ObsidianPillarBasementFeature.java index 66d1bc3d..91826d46 100644 --- a/src/main/java/ru/betterend/world/features/terrain/ObsidianPillarBasementFeature.java +++ b/src/main/java/ru/betterend/world/features/terrain/ObsidianPillarBasementFeature.java @@ -26,18 +26,15 @@ import ru.betterend.world.features.DefaultFeature; public class ObsidianPillarBasementFeature extends DefaultFeature { @Override - public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, - NoneFeatureConfiguration config) { - pos = getPosOnSurface(world, - new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16))); + public boolean place(WorldGenLevel world, ChunkGenerator chunkGenerator, Random random, BlockPos pos, NoneFeatureConfiguration config) { + pos = getPosOnSurface(world, new BlockPos(pos.getX() + random.nextInt(16), pos.getY(), pos.getZ() + random.nextInt(16))); if (!world.getBlockState(pos.below(5)).is(EndTags.GEN_TERRAIN)) { return false; } float height = MHelper.randRange(10F, 35F, random); float radius = MHelper.randRange(2F, 5F, random); - SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F) - .setBlock(Blocks.OBSIDIAN); + SDF pillar = new SDFCappedCone().setRadius1(radius).setRadius2(radius).setHeight(height * 0.5F).setBlock(Blocks.OBSIDIAN); pillar = new SDFTranslate().setTranslate(0, height * 0.5F - 3, 0).setSource(pillar); SDF cut = new SDFFlatland().setBlock(Blocks.OBSIDIAN); OpenSimplexNoise noise = new OpenSimplexNoise(random.nextLong()); @@ -52,7 +49,6 @@ public class ObsidianPillarBasementFeature extends DefaultFeature { vec = MHelper.randomHorizontal(random); angle = random.nextFloat() * 0.2F; pillar = new SDFRotation().setRotation(vec, angle).setSource(pillar); - BlockState mossy = EndBlocks.MOSSY_OBSIDIAN.defaultBlockState(); pillar.addPostProcess((info) -> { if (info.getStateUp().isAir() && random.nextFloat() > 0.1F) { @@ -60,8 +56,7 @@ public class ObsidianPillarBasementFeature extends DefaultFeature { } return info.getState(); }).setReplaceFunction((state) -> { - return state.getMaterial().isReplaceable() || state.is(EndTags.GEN_TERRAIN) - || state.getMaterial().equals(Material.PLANT); + return state.getMaterial().isReplaceable() || state.is(EndTags.GEN_TERRAIN) || state.getMaterial().equals(Material.PLANT); }).fillRecursive(world, pos); return true; diff --git a/src/main/java/ru/betterend/world/structures/features/EternalPortalStructure.java b/src/main/java/ru/betterend/world/structures/features/EternalPortalStructure.java index 5cb3dcc9..aa59776a 100644 --- a/src/main/java/ru/betterend/world/structures/features/EternalPortalStructure.java +++ b/src/main/java/ru/betterend/world/structures/features/EternalPortalStructure.java @@ -27,9 +27,9 @@ public class EternalPortalStructure extends FeatureBaseStructure { @Override protected boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, WorldgenRandom chunkRandom, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, NoneFeatureConfiguration featureConfig) { - long x = chunkPos.x; - long z = chunkPos.z; - if (x * x + z * z < 10000) { + long x = (long) chunkPos.x * (long) chunkPos.x; + long z = (long) chunkPos.z * (long) chunkPos.z; + if (x + z < 1024L) { return false; } if (chunkGenerator.getBaseHeight((chunkX << 4) | 8, (chunkZ << 4) | 8, Heightmap.Types.WORLD_SURFACE_WG) < 10) { diff --git a/src/main/resources/betterend.mixins.common.json b/src/main/resources/betterend.mixins.common.json index 1225e6e1..9fdf89ad 100644 --- a/src/main/resources/betterend.mixins.common.json +++ b/src/main/resources/betterend.mixins.common.json @@ -18,6 +18,7 @@ "RecipeManagerAccessor", "EnchantmentMenuMixin", "MinecraftServerMixin", + "EndDragonFightMixin", "BlockBehaviourMixin", "DimensionTypeMixin", "RecipeManagerMixin",