move banner blocks to new clkaases

This commit is contained in:
Sen 2025-06-01 14:54:13 +02:00
parent ee3bf79c4c
commit bda91dac26
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
5 changed files with 127 additions and 115 deletions

View file

@ -1,6 +1,5 @@
package common.block.tile;
import common.block.Block;
import common.block.BlockContainer;
import common.block.Material;
import common.entity.npc.EntityNPC;
@ -8,7 +7,6 @@ import common.init.Items;
import common.item.Item;
import common.item.ItemStack;
import common.model.Transforms;
import common.properties.IProperty;
import common.properties.PropertyDirection;
import common.properties.PropertyInteger;
import common.rng.Random;
@ -19,7 +17,6 @@ import common.util.BlockPos;
import common.util.BoundingBox;
import common.util.Facing;
import common.world.IBlockAccess;
import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
@ -165,111 +162,4 @@ public class BlockBanner extends BlockContainer
public Transforms getTransform() {
return Transforms.BANNER;
}
public static class BlockBannerHanging extends BlockBanner
{
public BlockBannerHanging()
{
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
}
public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos)
{
Facing enumfacing = (Facing)worldIn.getState(pos).getValue(FACING);
float f = 0.0F;
float f1 = 0.78125F;
float f2 = 0.0F;
float f3 = 1.0F;
float f4 = 0.125F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
switch (enumfacing)
{
case NORTH:
default:
this.setBlockBounds(f2, f, 1.0F - f4, f3, f1, 1.0F);
break;
case SOUTH:
this.setBlockBounds(f2, f, 0.0F, f3, f1, f4);
break;
case WEST:
this.setBlockBounds(1.0F - f4, f, f2, 1.0F, f1, f3);
break;
case EAST:
this.setBlockBounds(0.0F, f, f2, f4, f1, f3);
}
}
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
Facing enumfacing = (Facing)state.getValue(FACING);
if (!worldIn.getState(pos.offset(enumfacing.getOpposite())).getBlock().getMaterial().isSolid())
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
}
public State getStateFromMeta(int meta)
{
Facing enumfacing = Facing.getFront(meta);
if (enumfacing.getAxis() == Facing.Axis.Y)
{
enumfacing = Facing.NORTH;
}
return this.getState().withProperty(FACING, enumfacing);
}
public int getMetaFromState(State state)
{
return ((Facing)state.getValue(FACING)).getIndex();
}
protected IProperty[] getProperties()
{
return new IProperty[] {FACING};
}
}
public static class BlockBannerStanding extends BlockBanner
{
public BlockBannerStanding()
{
this.setDefaultState(this.getBaseState().withProperty(ROTATION, Integer.valueOf(0)));
}
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
if (!worldIn.getState(pos.down()).getBlock().getMaterial().isSolid())
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
}
public State getStateFromMeta(int meta)
{
return this.getState().withProperty(ROTATION, Integer.valueOf(meta));
}
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(ROTATION)).intValue();
}
protected IProperty[] getProperties()
{
return new IProperty[] {ROTATION};
}
}
}

View file

@ -0,0 +1,82 @@
package common.block.tile;
import common.block.Block;
import common.properties.IProperty;
import common.util.BlockPos;
import common.util.Facing;
import common.world.IWorldAccess;
import common.world.State;
import common.world.World;
public class BlockBannerHanging extends BlockBanner
{
public BlockBannerHanging()
{
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
}
public void setBlockBoundsBasedOnState(IWorldAccess worldIn, BlockPos pos)
{
Facing enumfacing = (Facing)worldIn.getState(pos).getValue(FACING);
float f = 0.0F;
float f1 = 0.78125F;
float f2 = 0.0F;
float f3 = 1.0F;
float f4 = 0.125F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
switch (enumfacing)
{
case NORTH:
default:
this.setBlockBounds(f2, f, 1.0F - f4, f3, f1, 1.0F);
break;
case SOUTH:
this.setBlockBounds(f2, f, 0.0F, f3, f1, f4);
break;
case WEST:
this.setBlockBounds(1.0F - f4, f, f2, 1.0F, f1, f3);
break;
case EAST:
this.setBlockBounds(0.0F, f, f2, f4, f1, f3);
}
}
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
Facing enumfacing = (Facing)state.getValue(FACING);
if (!worldIn.getState(pos.offset(enumfacing.getOpposite())).getBlock().getMaterial().isSolid())
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
}
public State getStateFromMeta(int meta)
{
Facing enumfacing = Facing.getFront(meta);
if (enumfacing.getAxis() == Facing.Axis.Y)
{
enumfacing = Facing.NORTH;
}
return this.getState().withProperty(FACING, enumfacing);
}
public int getMetaFromState(State state)
{
return ((Facing)state.getValue(FACING)).getIndex();
}
protected IProperty[] getProperties()
{
return new IProperty[] {FACING};
}
}

View file

@ -0,0 +1,41 @@
package common.block.tile;
import common.block.Block;
import common.properties.IProperty;
import common.util.BlockPos;
import common.world.State;
import common.world.World;
public class BlockBannerStanding extends BlockBanner
{
public BlockBannerStanding()
{
this.setDefaultState(this.getBaseState().withProperty(ROTATION, Integer.valueOf(0)));
}
public void onNeighborBlockChange(World worldIn, BlockPos pos, State state, Block neighborBlock)
{
if (!worldIn.getState(pos.down()).getBlock().getMaterial().isSolid())
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
}
public State getStateFromMeta(int meta)
{
return this.getState().withProperty(ROTATION, Integer.valueOf(meta));
}
public int getMetaFromState(State state)
{
return ((Integer)state.getValue(ROTATION)).intValue();
}
protected IProperty[] getProperties()
{
return new IProperty[] {ROTATION};
}
}

View file

@ -120,7 +120,8 @@ import common.block.tech.BlockTripWire;
import common.block.tech.BlockTripWireHook;
import common.block.tech.BlockWarpChest;
import common.block.tech.BlockWorkbench;
import common.block.tile.BlockBanner;
import common.block.tile.BlockBannerHanging;
import common.block.tile.BlockBannerStanding;
import common.block.tile.BlockSkull;
import common.block.tile.BlockStandingSign;
import common.block.tile.BlockWallSign;
@ -488,9 +489,9 @@ public abstract class BlockRegistry {
registerBlock(313, "wall_sign",
(new BlockWallSign()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Schild"));
registerBlock(314, "banner",
(new BlockBanner.BlockBannerStanding()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Banner"));
(new BlockBannerStanding()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Banner"));
registerBlock(315, "wall_banner",
(new BlockBanner.BlockBannerHanging()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Banner"));
(new BlockBannerHanging()).setHardness(1.0F).setStepSound(SoundType.WOOD).setDisplay("Banner"));
registerBlock(390, "portal",
(new BlockPortal()).setHardness(0.0F).setStepSound(SoundType.GLASS).setLightLevel(0.75F).setDisplay("Portal"));

View file

@ -14,8 +14,6 @@ import common.block.liquid.*;
import common.block.natural.*;
import common.block.tech.*;
import common.block.tile.*;
import common.block.tile.BlockBanner.BlockBannerHanging;
import common.block.tile.BlockBanner.BlockBannerStanding;
import common.collect.Lists;
import common.collect.Sets;
import common.util.Util;