Spike feature fixes & custom pillars

This commit is contained in:
paulevsGitch 2021-03-19 10:34:46 +03:00
parent 674d80a3de
commit a0829e07ae
17 changed files with 107 additions and 38 deletions

View file

@ -202,5 +202,7 @@ public class MetalMaterial {
TagHelper.addTag(BlockTags.BEACON_BASE_BLOCKS, block); TagHelper.addTag(BlockTags.BEACON_BASE_BLOCKS, block);
TagHelper.addTag(EndTags.IRON_INGOTS, ingot); TagHelper.addTag(EndTags.IRON_INGOTS, ingot);
TagHelper.addTag(ItemTags.BEACON_PAYMENT_ITEMS, ingot); TagHelper.addTag(ItemTags.BEACON_PAYMENT_ITEMS, ingot);
TagHelper.addTag(EndTags.DRAGON_IMMUNE, ore, bars);
} }
} }

View file

@ -98,5 +98,7 @@ public class StoneMaterial {
TagHelper.addTag(BlockTags.SLABS, slab, brick_slab); TagHelper.addTag(BlockTags.SLABS, slab, brick_slab);
TagHelper.addTags(pressure_plate, BlockTags.PRESSURE_PLATES, BlockTags.STONE_PRESSURE_PLATES); TagHelper.addTags(pressure_plate, BlockTags.PRESSURE_PLATES, BlockTags.STONE_PRESSURE_PLATES);
TagHelper.addTag(EndTags.END_STONES, stone); TagHelper.addTag(EndTags.END_STONES, stone);
TagHelper.addTag(EndTags.DRAGON_IMMUNE, stone, stairs, slab, wall);
} }
} }

View file

@ -13,6 +13,8 @@ import net.minecraft.block.Blocks;
import net.minecraft.block.PaneBlock; import net.minecraft.block.PaneBlock;
import net.minecraft.entity.EntityType; import net.minecraft.entity.EntityType;
import net.minecraft.entity.decoration.EndCrystalEntity; import net.minecraft.entity.decoration.EndCrystalEntity;
import net.minecraft.structure.Structure;
import net.minecraft.structure.StructurePlacementData;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.Mutable; import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -22,7 +24,9 @@ import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.EndSpikeFeature; import net.minecraft.world.gen.feature.EndSpikeFeature;
import net.minecraft.world.gen.feature.EndSpikeFeatureConfig; import net.minecraft.world.gen.feature.EndSpikeFeatureConfig;
import ru.betterend.BetterEnd;
import ru.betterend.util.BlocksHelper; import ru.betterend.util.BlocksHelper;
import ru.betterend.util.StructureHelper;
import ru.betterend.world.generator.GeneratorOptions; import ru.betterend.world.generator.GeneratorOptions;
@Mixin(EndSpikeFeature.class) @Mixin(EndSpikeFeature.class)
@ -39,9 +43,50 @@ public class EndSpikeFeatureMixin {
int x = spike.getCenterX(); int x = spike.getCenterX();
int z = spike.getCenterZ(); int z = spike.getCenterZ();
int radius = spike.getRadius(); int radius = spike.getRadius();
int minY = world.getChunk(spike.getCenterX() >> 4, spike.getCenterZ() >> 4).sampleHeightmap(Type.WORLD_SURFACE, spike.getCenterX() & 15, spike.getCenterZ() & 15) - 15; int minY = world.getChunk(x >> 4, z >> 4).sampleHeightmap(Type.WORLD_SURFACE, x & 15, z);
int maxY = minY + spike.getHeight() - 50; int maxY = minY + spike.getHeight() - 30;
if (GeneratorOptions.replacePillars() && be_radiusInRange(radius)) {
radius--;
Structure base = StructureHelper.readStructure(BetterEnd.makeID("pillars/pillar_base_" + radius));
Structure top = StructureHelper.readStructure(BetterEnd.makeID("pillars/pillar_top_" + radius + (spike.isGuarded() ? "_cage" : "")));
BlockPos side = base.getSize();
BlockPos pos1 = new BlockPos(x - (side.getX() >> 1), minY - 3, z - (side.getZ() >> 1));
minY = pos1.getY() + side.getY();
side = top.getSize();
BlockPos pos2 = new BlockPos(x - (side.getX() >> 1), maxY, z - (side.getZ() >> 1));
maxY = pos2.getY();
StructurePlacementData data = new StructurePlacementData();
base.place(world, pos1, data, random);
top.place(world, pos2, data, random);
int r2 = radius * radius + 1;
Mutable mut = new Mutable();
for (int px = -radius; px <= radius; px++) {
mut.setX(x + px);
int x2 = px * px;
for (int pz = -radius; pz <= radius; pz++) {
mut.setZ(z + pz);
int z2 = pz * pz;
if (x2 + z2 <= r2) {
for (int py = minY; py < maxY; py++) {
mut.setY(py);
if (world.getBlockState(mut).getMaterial().isReplaceable()) {
if ((px == radius || px == -radius || pz == radius || pz == -radius) && random.nextInt(24) == 0) {
BlocksHelper.setWithoutUpdate(world, mut, Blocks.CRYING_OBSIDIAN);
}
else {
BlocksHelper.setWithoutUpdate(world, mut, Blocks.OBSIDIAN);
}
}
}
}
}
}
}
else {
minY -= 15;
int r2 = radius * radius + 1; int r2 = radius * radius + 1;
Mutable mut = new Mutable(); Mutable mut = new Mutable();
for (int px = -radius; px <= radius; px++) { for (int px = -radius; px <= radius; px++) {
@ -88,7 +133,12 @@ public class EndSpikeFeatureMixin {
} }
} }
} }
}
info.cancel(); info.cancel();
} }
private boolean be_radiusInRange(int radius) {
return radius > 1 && radius < 6;
}
} }

View file

@ -39,6 +39,7 @@ public class EndTags {
public static final Tag.Identified<Block> PEDESTALS = makeBlockTag("pedestal"); public static final Tag.Identified<Block> PEDESTALS = makeBlockTag("pedestal");
public static final Tag.Identified<Block> BLOCK_CHEST = makeCommonBlockTag("chest"); public static final Tag.Identified<Block> BLOCK_CHEST = makeCommonBlockTag("chest");
public static final Tag.Identified<Block> END_STONES = makeCommonBlockTag("end_stones"); public static final Tag.Identified<Block> END_STONES = makeCommonBlockTag("end_stones");
public static final Tag.Identified<Block> DRAGON_IMMUNE = getMCBlockTag("dragon_immune");
// Item Tags // Item Tags
public static final Tag.Identified<Item> ITEM_CHEST = makeCommonItemTag("chest"); public static final Tag.Identified<Item> ITEM_CHEST = makeCommonItemTag("chest");
@ -70,6 +71,12 @@ public class EndTags {
return tag == null ? (Identified<Item>) TagRegistry.item(id) : (Identified<Item>) tag; return tag == null ? (Identified<Item>) TagRegistry.item(id) : (Identified<Item>) tag;
} }
public static Tag.Identified<Block> getMCBlockTag(String name) {
Identifier id = new Identifier(name);
Tag<Block> tag = BlockTags.getTagGroup().getTag(id);
return tag == null ? (Identified<Block>) TagRegistry.block(id) : (Identified<Block>) tag;
}
public static void register() { public static void register() {
addSurfaceBlock(Blocks.END_STONE); addSurfaceBlock(Blocks.END_STONE);
addSurfaceBlock(EndBlocks.THALLASIUM.ore); addSurfaceBlock(EndBlocks.THALLASIUM.ore);
@ -117,6 +124,8 @@ public class EndTags {
TagHelper.addTag(BlockTags.BEACON_BASE_BLOCKS, EndBlocks.AETERNIUM_BLOCK); TagHelper.addTag(BlockTags.BEACON_BASE_BLOCKS, EndBlocks.AETERNIUM_BLOCK);
TagHelper.addTag(ItemTags.BEACON_PAYMENT_ITEMS, EndItems.AETERNIUM_INGOT); TagHelper.addTag(ItemTags.BEACON_PAYMENT_ITEMS, EndItems.AETERNIUM_INGOT);
TagHelper.addTag(EndTags.DRAGON_IMMUNE, EndBlocks.ENDER_ORE);
} }
public static void addSurfaceBlock(Block block) { public static void addSurfaceBlock(Block block) {

View file

@ -25,6 +25,7 @@ public class GeneratorOptions {
private static BlockPos spawn; private static BlockPos spawn;
private static BlockPos portal = BlockPos.ORIGIN; private static BlockPos portal = BlockPos.ORIGIN;
private static boolean replacePortal; private static boolean replacePortal;
private static boolean replacePillars;
public static void init() { public static void init() {
biomeSizeLand = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeLand", 256); biomeSizeLand = Configs.GENERATOR_CONFIG.getInt("biomeMap", "biomeSizeLand", 256);
@ -50,6 +51,7 @@ public class GeneratorOptions {
Configs.GENERATOR_CONFIG.getInt("spawn.point", "z", 0) Configs.GENERATOR_CONFIG.getInt("spawn.point", "z", 0)
); );
replacePortal = Configs.GENERATOR_CONFIG.getBooleanRoot("customEndPortal", true); replacePortal = Configs.GENERATOR_CONFIG.getBooleanRoot("customEndPortal", true);
replacePillars = Configs.GENERATOR_CONFIG.getBooleanRoot("customObsidianSpikes", true);
} }
public static int getBiomeSizeLand() { public static int getBiomeSizeLand() {
@ -123,4 +125,8 @@ public class GeneratorOptions {
public static boolean replacePortal() { public static boolean replacePortal() {
return replacePortal; return replacePortal;
} }
public static boolean replacePillars() {
return replacePillars;
}
} }