Terrain tag
This commit is contained in:
parent
ce568b4204
commit
293b0b4448
4 changed files with 29 additions and 13 deletions
|
@ -18,7 +18,6 @@ import net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView;
|
||||||
import net.fabricmc.fabric.api.renderer.v1.mesh.QuadEmitter;
|
import net.fabricmc.fabric.api.renderer.v1.mesh.QuadEmitter;
|
||||||
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
|
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
|
||||||
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
|
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.render.model.BakedModel;
|
import net.minecraft.client.render.model.BakedModel;
|
||||||
import net.minecraft.client.render.model.BakedQuad;
|
import net.minecraft.client.render.model.BakedQuad;
|
||||||
|
@ -31,16 +30,11 @@ import net.minecraft.client.render.model.json.ModelTransformation;
|
||||||
import net.minecraft.client.texture.Sprite;
|
import net.minecraft.client.texture.Sprite;
|
||||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||||
import net.minecraft.client.util.SpriteIdentifier;
|
import net.minecraft.client.util.SpriteIdentifier;
|
||||||
import net.minecraft.client.util.math.Vector3f;
|
|
||||||
import net.minecraft.client.util.math.Vector4f;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.Matrix4f;
|
|
||||||
import net.minecraft.util.math.Quaternion;
|
|
||||||
import net.minecraft.world.BlockRenderView;
|
import net.minecraft.world.BlockRenderView;
|
||||||
|
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
|
|
||||||
public class BaseBlockModel implements UnbakedModel, BakedModel, FabricBakedModel {
|
public class BaseBlockModel implements UnbakedModel, BakedModel, FabricBakedModel {
|
||||||
|
|
|
@ -5,11 +5,16 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.tag.BlockTags;
|
import net.minecraft.tag.BlockTags;
|
||||||
import net.minecraft.tag.Tag;
|
import net.minecraft.tag.Tag;
|
||||||
import net.minecraft.tag.Tag.Identified;
|
import net.minecraft.tag.Tag.Identified;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
import net.minecraft.world.biome.Biome.Category;
|
||||||
|
import net.minecraft.world.gen.surfacebuilder.SurfaceConfig;
|
||||||
import ru.betterend.BetterEnd;
|
import ru.betterend.BetterEnd;
|
||||||
import ru.betterend.util.TagHelper;
|
import ru.betterend.util.TagHelper;
|
||||||
|
|
||||||
public class BlockTagRegistry {
|
public class BlockTagRegistry {
|
||||||
public static final Tag.Identified<Block> END_GROUND = makeTag("end_ground");
|
public static final Tag.Identified<Block> END_GROUND = makeTag("end_ground");
|
||||||
|
public static final Tag.Identified<Block> GEN_TERRAIN = makeTag("gen_terrain");
|
||||||
|
|
||||||
private static Tag.Identified<Block> makeTag(String name) {
|
private static Tag.Identified<Block> makeTag(String name) {
|
||||||
return (Identified<Block>) TagRegistry.block(BetterEnd.makeID(name));
|
return (Identified<Block>) TagRegistry.block(BetterEnd.makeID(name));
|
||||||
|
@ -19,4 +24,16 @@ public class BlockTagRegistry {
|
||||||
TagHelper.addTag(END_GROUND, BlockRegistry.END_MOSS, BlockRegistry.END_MYCELIUM, BlockRegistry.ENDER_ORE);
|
TagHelper.addTag(END_GROUND, BlockRegistry.END_MOSS, BlockRegistry.END_MYCELIUM, BlockRegistry.ENDER_ORE);
|
||||||
TagHelper.addTag(BlockTags.NYLIUM, BlockRegistry.END_MOSS, BlockRegistry.END_MYCELIUM, BlockRegistry.ENDER_ORE);
|
TagHelper.addTag(BlockTags.NYLIUM, BlockRegistry.END_MOSS, BlockRegistry.END_MYCELIUM, BlockRegistry.ENDER_ORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addTerrainTags(Registry<Biome> biomeRegistry) {
|
||||||
|
END_GROUND.values().forEach((block) -> {
|
||||||
|
TagHelper.addTag(GEN_TERRAIN, block);
|
||||||
|
});
|
||||||
|
biomeRegistry.forEach((biome) -> {
|
||||||
|
if (biome.getCategory() == Category.THEEND) {
|
||||||
|
SurfaceConfig config = biome.getGenerationSettings().getSurfaceConfig();
|
||||||
|
TagHelper.addTag(GEN_TERRAIN, config.getTopMaterial().getBlock(), config.getUnderMaterial().getBlock());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ 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.DefaultFeatureConfig;
|
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||||
import ru.betterend.blocks.BlockEndLily;
|
import ru.betterend.blocks.BlockEndLily;
|
||||||
import ru.betterend.blocks.BlockEndLilySeed;
|
|
||||||
import ru.betterend.blocks.BlockProperties.TripleShape;
|
import ru.betterend.blocks.BlockProperties.TripleShape;
|
||||||
import ru.betterend.noise.OpenSimplexNoise;
|
import ru.betterend.noise.OpenSimplexNoise;
|
||||||
import ru.betterend.registry.BlockRegistry;
|
import ru.betterend.registry.BlockRegistry;
|
||||||
|
@ -110,11 +109,11 @@ public class EndLakeFeature extends DefaultFeature {
|
||||||
r *= r;
|
r *= r;
|
||||||
if (x2 + z2 <= r) {
|
if (x2 + z2 <= r) {
|
||||||
state = world.getBlockState(POS);
|
state = world.getBlockState(POS);
|
||||||
if (state.isIn(BlockTagRegistry.END_GROUND)) {
|
if (state.isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||||
BlocksHelper.setWithoutUpdate(world, POS, AIR);
|
BlocksHelper.setWithoutUpdate(world, POS, AIR);
|
||||||
}
|
}
|
||||||
pos = POS.down();
|
pos = POS.down();
|
||||||
if (world.getBlockState(pos).isIn(BlockTagRegistry.END_GROUND)) {
|
if (world.getBlockState(pos).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||||
state = world.getBiome(pos).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
state = world.getBiome(pos).getGenerationSettings().getSurfaceConfig().getTopMaterial();
|
||||||
if (y > waterLevel + 1)
|
if (y > waterLevel + 1)
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, state);
|
BlocksHelper.setWithoutUpdate(world, pos, state);
|
||||||
|
@ -156,14 +155,14 @@ public class EndLakeFeature extends DefaultFeature {
|
||||||
rb *= rb;
|
rb *= rb;
|
||||||
if (y2 + x2 + z2 <= r) {
|
if (y2 + x2 + z2 <= r) {
|
||||||
state = world.getBlockState(POS);
|
state = world.getBlockState(POS);
|
||||||
if (state.isIn(BlockTagRegistry.END_GROUND) || state.getBlock() == BlockRegistry.ENDSTONE_DUST) {
|
if (state.isIn(BlockTagRegistry.GEN_TERRAIN) || state.getBlock() == BlockRegistry.ENDSTONE_DUST) {
|
||||||
BlocksHelper.setWithoutUpdate(world, POS, y < waterLevel ? WATER : AIR);
|
BlocksHelper.setWithoutUpdate(world, POS, y < waterLevel ? WATER : AIR);
|
||||||
if (y == waterLevel - 1) {
|
if (y == waterLevel - 1) {
|
||||||
world.getFluidTickScheduler().schedule(POS, WATER.getFluidState().getFluid(), 0);
|
world.getFluidTickScheduler().schedule(POS, WATER.getFluidState().getFluid(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pos = POS.down();
|
pos = POS.down();
|
||||||
if (world.getBlockState(pos).getBlock().isIn(BlockTagRegistry.END_GROUND))
|
if (world.getBlockState(pos).getBlock().isIn(BlockTagRegistry.GEN_TERRAIN))
|
||||||
{
|
{
|
||||||
BlocksHelper.setWithoutUpdate(world, POS.down(), BlockRegistry.ENDSTONE_DUST.getDefaultState());
|
BlocksHelper.setWithoutUpdate(world, POS.down(), BlockRegistry.ENDSTONE_DUST.getDefaultState());
|
||||||
if (y < waterLevel - 1 && random.nextInt(3) == 0 && ((x + z) & 1) == 0) {
|
if (y < waterLevel - 1 && random.nextInt(3) == 0 && ((x + z) & 1) == 0) {
|
||||||
|
@ -182,8 +181,8 @@ public class EndLakeFeature extends DefaultFeature {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pos = POS.up();
|
pos = POS.up();
|
||||||
if (world.getBlockState(pos).isIn(BlockTagRegistry.END_GROUND)) {
|
if (world.getBlockState(pos).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||||
while (world.getBlockState(pos).isIn(BlockTagRegistry.END_GROUND)) {
|
while (world.getBlockState(pos).isIn(BlockTagRegistry.GEN_TERRAIN)) {
|
||||||
BlocksHelper.setWithoutUpdate(world, pos, pos.getY() < waterLevel ? WATER : AIR);
|
BlocksHelper.setWithoutUpdate(world, pos, pos.getY() < waterLevel ? WATER : AIR);
|
||||||
if (y == waterLevel - 1) {
|
if (y == waterLevel - 1) {
|
||||||
world.getFluidTickScheduler().schedule(POS, WATER.getFluidState().getFluid(), 0);
|
world.getFluidTickScheduler().schedule(POS, WATER.getFluidState().getFluid(), 0);
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"replace": "false",
|
||||||
|
"values": [
|
||||||
|
"minecraft:end_stone"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue