From 734279ad95c0cdcd3e3403a9a589dc2180e727ab Mon Sep 17 00:00:00 2001 From: Sen Date: Fri, 20 Jun 2025 23:54:12 +0200 Subject: [PATCH] block cleanup #3 --- .../client/renderer/entity/RenderPotion.java | 3 ++- .../client/renderer/entity/RenderTntPrimed.java | 16 +++++----------- .../src/main/java/client/world/WorldClient.java | 6 ++++-- .../java/server/clipboard/ReorderRegistry.java | 9 +++++++-- .../java/server/clipboard/RotationRegistry.java | 7 +++---- .../java/server/worldgen/caves/MapGenCaves.java | 6 +++++- .../worldgen/feature/WorldGenDesertWells.java | 3 +-- .../worldgen/foliage/FeatureDoublePlant.java | 9 ++++----- .../server/worldgen/foliage/WorldGenFlowers.java | 16 ++++++++-------- .../worldgen/foliage/WorldGenTallGrass.java | 8 +++++--- .../worldgen/structure/StructureScattered.java | 8 ++++---- .../worldgen/structure/StructureStronghold.java | 4 ++-- 12 files changed, 50 insertions(+), 45 deletions(-) diff --git a/client/src/main/java/client/renderer/entity/RenderPotion.java b/client/src/main/java/client/renderer/entity/RenderPotion.java index 42567832..0fb4fa68 100755 --- a/client/src/main/java/client/renderer/entity/RenderPotion.java +++ b/client/src/main/java/client/renderer/entity/RenderPotion.java @@ -2,6 +2,7 @@ package client.renderer.entity; import common.entity.projectile.EntityPotion; import common.init.Items; +import common.item.ItemPotion; import common.item.ItemStack; public class RenderPotion extends RenderItemEntity @@ -13,6 +14,6 @@ public class RenderPotion extends RenderItemEntity public ItemStack getStack(EntityPotion entityIn) { - return new ItemStack(this.item, 1, entityIn.getPotionDamage()); + return new ItemStack(ItemPotion.getPotionItem(entityIn.getPotionDamage())); } } diff --git a/client/src/main/java/client/renderer/entity/RenderTntPrimed.java b/client/src/main/java/client/renderer/entity/RenderTntPrimed.java index 616fd3b1..5a8d0ded 100755 --- a/client/src/main/java/client/renderer/entity/RenderTntPrimed.java +++ b/client/src/main/java/client/renderer/entity/RenderTntPrimed.java @@ -6,9 +6,9 @@ import client.Client; import client.renderer.BlockRenderer; import client.renderer.GlState; import client.renderer.texture.TextureMap; -import common.block.tech.BlockTNT; +import common.block.Block; import common.entity.item.EntityTnt; -import common.init.Blocks; +import common.init.BlockRegistry; import common.util.ExtMath; @@ -17,12 +17,8 @@ public class RenderTntPrimed extends Render public RenderTntPrimed(RenderManager renderManagerIn) { super(renderManagerIn); -// this.shadowSize = 0.5F; } - /** - * Renders the desired {@code T} type Entity. - */ public void doRender(EntityTnt entity, double x, double y, double z, float partialTicks) { BlockRenderer blockrendererdispatcher = Client.CLIENT.getBlockRendererDispatcher(); @@ -42,7 +38,8 @@ public class RenderTntPrimed extends Render float f2 = (1.0F - ((float)entity.fuse - partialTicks + 1.0F) / 100.0F) * 0.8F; this.bindEntityTexture(entity); GL11.glTranslatef(-0.5F, -0.5F, 0.5F); - blockrendererdispatcher.renderBlockBrightness(Blocks.tnt.getState().withProperty(BlockTNT.POWER, Integer.valueOf(entity.explosionSize)), entity.getBrightness(partialTicks)); + Block tnt = BlockRegistry.getRegisteredBlock("tnt" + (entity.explosionSize <= 0 || entity.explosionSize >= 8 ? "" : "_" + entity.explosionSize)); + blockrendererdispatcher.renderBlockBrightness(tnt.getState(), entity.getBrightness(partialTicks)); GL11.glTranslatef(0.0F, 0.0F, 1.0F); if (entity.fuse / 5 % 2 == 0) @@ -54,7 +51,7 @@ public class RenderTntPrimed extends Render GlState.color(1.0F, 1.0F, 1.0F, f2); GlState.doPolygonOffset(-3.0F, -3.0F); GlState.enablePolygonOffset(); - blockrendererdispatcher.renderBlockBrightness(Blocks.tnt.getState().withProperty(BlockTNT.POWER, Integer.valueOf(entity.explosionSize)), 1.0F); + blockrendererdispatcher.renderBlockBrightness(tnt.getState(), 1.0F); GlState.doPolygonOffset(0.0F, 0.0F); GlState.disablePolygonOffset(); GlState.color(1.0F, 1.0F, 1.0F, 1.0F); @@ -67,9 +64,6 @@ public class RenderTntPrimed extends Render super.doRender(entity, x, y, z, partialTicks); } - /** - * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. - */ protected String getEntityTexture(EntityTnt entity) { return TextureMap.locationBlocksTexture; diff --git a/client/src/main/java/client/world/WorldClient.java b/client/src/main/java/client/world/WorldClient.java index e1e28f7a..2ba83a93 100755 --- a/client/src/main/java/client/world/WorldClient.java +++ b/client/src/main/java/client/world/WorldClient.java @@ -20,6 +20,7 @@ import common.init.ItemRegistry; import common.init.Items; import common.init.SoundEvent; import common.item.ItemDye; +import common.item.ItemPotion; import common.log.Log; import common.model.ParticleType; import common.rng.Random; @@ -661,13 +662,14 @@ public class WorldClient extends AWorldClient float f1 = 1.0F; float f2 = 1.0F; if((data & 16383) != 0) { - int j1 = Items.potion.getColorFromDamage(data); + ItemPotion potion = ItemPotion.getPotionItem(data); + int j1 = potion.getColorFromDamage(); f = (float)(j1 >> 16 & 255) / 255.0F; f1 = (float)(j1 >> 8 & 255) / 255.0F; f2 = (float)(j1 >> 0 & 255) / 255.0F; enumparticletypes = ParticleType.SPELL; - if (Items.potion.isEffectInstant(data)) + if (potion.isEffectInstant()) { enumparticletypes = ParticleType.SPELL_INSTANT; } diff --git a/server/src/main/java/server/clipboard/ReorderRegistry.java b/server/src/main/java/server/clipboard/ReorderRegistry.java index 3040b082..1a21def8 100755 --- a/server/src/main/java/server/clipboard/ReorderRegistry.java +++ b/server/src/main/java/server/clipboard/ReorderRegistry.java @@ -8,6 +8,7 @@ import java.util.Set; import common.block.Block; import common.block.artificial.BlockBed; import common.block.artificial.BlockDoor; +import common.block.foliage.BlockFlower; import common.color.DyeColor; import common.init.BlockRegistry; import common.init.Blocks; @@ -49,7 +50,9 @@ public abstract class ReorderRegistry { PLACE_LAST.add(Blocks.tallgrass); PLACE_LAST.add(Blocks.deadbush); PLACE_LAST.add(Blocks.piston_head); - PLACE_LAST.add(Blocks.flower); + for(BlockFlower.EnumFlowerType type : BlockFlower.EnumFlowerType.values()) { + PLACE_LAST.add(BlockFlower.getByType(type)); + } PLACE_LAST.add(Blocks.brown_mushroom); PLACE_LAST.add(Blocks.red_mushroom_block); PLACE_LAST.add(Blocks.torch); @@ -138,7 +141,9 @@ public abstract class ReorderRegistry { addAttach(Blocks.piston_head.getStateFromMeta(offset + 1), Facing.DOWN); addCardinals(Blocks.piston_head, offset + 2, offset + 5, offset + 3, offset + 4); } - addAttach(Blocks.flower, Facing.DOWN); + for(BlockFlower.EnumFlowerType type : BlockFlower.EnumFlowerType.values()) { + addAttach(BlockFlower.getByType(type), Facing.DOWN); + } addAttach(Blocks.brown_mushroom, Facing.DOWN); addAttach(Blocks.red_mushroom, Facing.DOWN); for (Block blockId : new Block[] { Blocks.torch, Blocks.redstone_torch, Blocks.unlit_redstone_torch }) { diff --git a/server/src/main/java/server/clipboard/RotationRegistry.java b/server/src/main/java/server/clipboard/RotationRegistry.java index 6716e849..eca88e88 100755 --- a/server/src/main/java/server/clipboard/RotationRegistry.java +++ b/server/src/main/java/server/clipboard/RotationRegistry.java @@ -9,7 +9,6 @@ import common.block.Block; import common.block.BlockRotatedPillar; import common.block.artificial.BlockDoor; import common.block.artificial.BlockPortal; -import common.block.artificial.BlockQuartz; import common.block.foliage.BlockLog; import common.block.tech.BlockLever; import common.block.tech.BlockRail; @@ -76,9 +75,9 @@ public abstract class RotationRegistry { else if(prop == BlockLog.LOG_AXIS) { axis = ((BlockLog.EnumAxis)v).getAxis(); } - else if(prop == BlockQuartz.VARIANT) { - axis = ((BlockQuartz.EnumType)v).getAxis(); - } +// else if(prop == BlockQuartz.VARIANT) { // TODO: fix quartz +// axis = ((BlockQuartz.EnumType)v).getAxis(); +// } else if(prop == BlockLever.FACING) { dv = ((BlockLever.EnumOrientation)v).getFacing().getDirectionVec(); } diff --git a/server/src/main/java/server/worldgen/caves/MapGenCaves.java b/server/src/main/java/server/worldgen/caves/MapGenCaves.java index c3c67d49..3f6a5704 100755 --- a/server/src/main/java/server/worldgen/caves/MapGenCaves.java +++ b/server/src/main/java/server/worldgen/caves/MapGenCaves.java @@ -212,7 +212,11 @@ public class MapGenCaves extends MapGenBase if (iblockstate2.getBlock() == Blocks.sand) { - p_180702_5_.set(j3, j2 + 1, i2, iblockstate2.getValue(BlockSand.VARIANT) == BlockSand.EnumType.RED_SAND ? Blocks.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.ORANGE) : Blocks.sandstone.getState()); //TODO: check! + p_180702_5_.set(j3, j2 + 1, i2, Blocks.sandstone.getState()); //TODO: check! + } + else if (iblockstate2.getBlock() == Blocks.red_sand) + { + p_180702_5_.set(j3, j2 + 1, i2, Blocks.orange_stained_hardened_clay.getState()); //TODO: check! } if (flag1 && p_180702_5_.get(j3, j2 - 1, i2).getBlock() == this.top) diff --git a/server/src/main/java/server/worldgen/feature/WorldGenDesertWells.java b/server/src/main/java/server/worldgen/feature/WorldGenDesertWells.java index 90b06369..9f8b9e41 100755 --- a/server/src/main/java/server/worldgen/feature/WorldGenDesertWells.java +++ b/server/src/main/java/server/worldgen/feature/WorldGenDesertWells.java @@ -1,7 +1,6 @@ package server.worldgen.feature; import common.block.artificial.BlockSlab; -import common.block.natural.BlockSand; import common.init.Blocks; import common.rng.Random; import common.util.BlockPos; @@ -24,7 +23,7 @@ public class WorldGenDesertWells extends FeatureGenerator } State state = worldIn.getState(position); - if (state.getBlock() != Blocks.sand || state.getValue(BlockSand.VARIANT) != BlockSand.EnumType.SAND) + if (state.getBlock() != Blocks.sand) { return false; } diff --git a/server/src/main/java/server/worldgen/foliage/FeatureDoublePlant.java b/server/src/main/java/server/worldgen/foliage/FeatureDoublePlant.java index 548e5845..5c3243e4 100755 --- a/server/src/main/java/server/worldgen/foliage/FeatureDoublePlant.java +++ b/server/src/main/java/server/worldgen/foliage/FeatureDoublePlant.java @@ -1,16 +1,15 @@ package server.worldgen.foliage; import common.block.foliage.BlockDoublePlant; -import common.init.Blocks; import common.rng.Random; import common.util.BlockPos; import server.world.WorldServer; public class FeatureDoublePlant { - private BlockDoublePlant.EnumPlantType type; + private BlockDoublePlant type; - public void setPlantType(BlockDoublePlant.EnumPlantType type) + public void setPlantType(BlockDoublePlant type) { this.type = type; } @@ -23,9 +22,9 @@ public class FeatureDoublePlant { BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8)); - if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 254) && Blocks.double_plant.canPlaceBlockAt(worldIn, blockpos)) + if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 254) && this.type.canPlaceBlockAt(worldIn, blockpos)) { - Blocks.double_plant.placeAt(worldIn, blockpos, this.type, 2); + this.type.placeAt(worldIn, blockpos, 2); flag = true; } } diff --git a/server/src/main/java/server/worldgen/foliage/WorldGenFlowers.java b/server/src/main/java/server/worldgen/foliage/WorldGenFlowers.java index 4bc978c3..d3990ecd 100755 --- a/server/src/main/java/server/worldgen/foliage/WorldGenFlowers.java +++ b/server/src/main/java/server/worldgen/foliage/WorldGenFlowers.java @@ -10,17 +10,17 @@ import server.worldgen.FeatureGenerator; public class WorldGenFlowers extends FeatureGenerator { private BlockFlower flower; - private State field_175915_b; + private State state; - public WorldGenFlowers(BlockFlower p_i45632_1_, BlockFlower.EnumFlowerType p_i45632_2_) + public WorldGenFlowers(BlockFlower block) { - this.setGeneratedBlock(p_i45632_1_, p_i45632_2_); + this.setGeneratedBlock(block); } - public void setGeneratedBlock(BlockFlower p_175914_1_, BlockFlower.EnumFlowerType p_175914_2_) + public void setGeneratedBlock(BlockFlower block) { - this.flower = p_175914_1_; - this.field_175915_b = p_175914_1_.getState().withProperty(p_175914_1_.getTypeProperty(), p_175914_2_); + this.flower = block; + this.state = block.getState(); } public boolean generate(WorldServer worldIn, Random rand, BlockPos position) @@ -29,9 +29,9 @@ public class WorldGenFlowers extends FeatureGenerator { BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8)); - if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 511) && this.flower.canBlockStay(worldIn, blockpos, this.field_175915_b)) + if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 511) && this.flower.canBlockStay(worldIn, blockpos, this.state)) { - worldIn.setState(blockpos, this.field_175915_b, 2); + worldIn.setState(blockpos, this.state, 2); } } diff --git a/server/src/main/java/server/worldgen/foliage/WorldGenTallGrass.java b/server/src/main/java/server/worldgen/foliage/WorldGenTallGrass.java index 81a1d757..e0257bd3 100755 --- a/server/src/main/java/server/worldgen/foliage/WorldGenTallGrass.java +++ b/server/src/main/java/server/worldgen/foliage/WorldGenTallGrass.java @@ -12,11 +12,13 @@ import server.worldgen.FeatureGenerator; public class WorldGenTallGrass extends FeatureGenerator { + private final BlockTallGrass tallGrass; private final State tallGrassState; - public WorldGenTallGrass(BlockTallGrass.EnumType p_i45629_1_) + public WorldGenTallGrass(BlockTallGrass block) { - this.tallGrassState = Blocks.tallgrass.getState().withProperty(BlockTallGrass.TYPE, p_i45629_1_); + this.tallGrass = block; + this.tallGrassState = block.getState(); } public boolean generate(WorldServer worldIn, Random rand, BlockPos position) @@ -32,7 +34,7 @@ public class WorldGenTallGrass extends FeatureGenerator { BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8)); - if (worldIn.isAirBlock(blockpos) && Blocks.tallgrass.canBlockStay(worldIn, blockpos, this.tallGrassState)) + if (worldIn.isAirBlock(blockpos) && this.tallGrass.canBlockStay(worldIn, blockpos, this.tallGrassState)) { worldIn.setState(blockpos, this.tallGrassState, 2); } diff --git a/server/src/main/java/server/worldgen/structure/StructureScattered.java b/server/src/main/java/server/worldgen/structure/StructureScattered.java index 5d2705a2..b4430f92 100755 --- a/server/src/main/java/server/worldgen/structure/StructureScattered.java +++ b/server/src/main/java/server/worldgen/structure/StructureScattered.java @@ -554,9 +554,9 @@ public class StructureScattered this.setBlockState(worldIn, Blocks.mossy_cobblestone.getState(), 8, -3, 5, structureBoundingBoxIn); this.fillWithRandomizedBlocks(worldIn, structureBoundingBoxIn, 9, -1, 1, 9, -1, 5, false, randomIn, junglePyramidsRandomScatteredStones); this.fillWithAir(worldIn, structureBoundingBoxIn, 8, -3, 8, 10, -1, 10); - this.setBlockState(worldIn, Blocks.stonebrick.getStateFromMeta(BlockStoneBrick.CHISELED_META), 8, -2, 11, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.stonebrick.getStateFromMeta(BlockStoneBrick.CHISELED_META), 9, -2, 11, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.stonebrick.getStateFromMeta(BlockStoneBrick.CHISELED_META), 10, -2, 11, structureBoundingBoxIn); + this.setBlockState(worldIn, Blocks.stonebrick_chiseled.getState(), 8, -2, 11, structureBoundingBoxIn); + this.setBlockState(worldIn, Blocks.stonebrick_chiseled.getState(), 9, -2, 11, structureBoundingBoxIn); + this.setBlockState(worldIn, Blocks.stonebrick_chiseled.getState(), 10, -2, 11, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.lever.getStateFromMeta(BlockLever.getMetadataForFacing(Facing.getFront(this.getMetadataWithOffset(Blocks.lever, Facing.NORTH.getIndex())))), 8, -2, 12, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.lever.getStateFromMeta(BlockLever.getMetadataForFacing(Facing.getFront(this.getMetadataWithOffset(Blocks.lever, Facing.NORTH.getIndex())))), 9, -2, 12, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.lever.getStateFromMeta(BlockLever.getMetadataForFacing(Facing.getFront(this.getMetadataWithOffset(Blocks.lever, Facing.NORTH.getIndex())))), 10, -2, 12, structureBoundingBoxIn); @@ -649,7 +649,7 @@ public class StructureScattered this.setBlockState(worldIn, Blocks.air.getState(), 1, 3, 4, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.air.getState(), 5, 3, 4, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.air.getState(), 5, 3, 5, structureBoundingBoxIn); - this.setBlockState(worldIn, Blocks.flower_pot.getState().withProperty(BlockFlowerPot.CONTENTS, 2 + BlockFlower.EnumFlowerType.BLACK_LOTUS.getMeta()), 1, 3, 5, structureBoundingBoxIn); + this.setBlockState(worldIn, Blocks.flowerpot_black_lotus.getState(), 1, 3, 5, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.workbench.getState(), 3, 2, 6, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.cauldron.getState(), 4, 2, 6, structureBoundingBoxIn); this.setBlockState(worldIn, Blocks.oak_fence.getState(), 1, 2, 1, structureBoundingBoxIn); diff --git a/server/src/main/java/server/worldgen/structure/StructureStronghold.java b/server/src/main/java/server/worldgen/structure/StructureStronghold.java index b96c6c4b..ba604729 100755 --- a/server/src/main/java/server/worldgen/structure/StructureStronghold.java +++ b/server/src/main/java/server/worldgen/structure/StructureStronghold.java @@ -1349,11 +1349,11 @@ public class StructureStronghold if (f < 0.2F) { - this.blockstate = Blocks.stonebrick.getStateFromMeta(BlockStoneBrick.CRACKED_META); + this.blockstate = Blocks.stonebrick_cracked.getState(); } else if (f < 0.5F) { - this.blockstate = Blocks.stonebrick.getStateFromMeta(BlockStoneBrick.MOSSY_META); + this.blockstate = Blocks.stonebrick_mossy.getState(); } // else if (f < 0.55F) // {