tcr/common/src/main/java/common/block/artificial/BlockSkull.java
2025-06-23 10:18:24 +02:00

82 lines
2.4 KiB
Java
Executable file

package common.block.artificial;
import common.block.Block;
import common.block.Rotatable;
import common.block.Material;
import common.entity.Entity;
import common.entity.types.EntityLiving;
import common.init.Items;
import common.item.CheatTab;
import common.item.Item;
import common.item.block.ItemSmallBlock;
import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.properties.Property;
import common.rng.Random;
import common.util.BlockPos;
import common.util.Facing;
import common.world.State;
import common.world.World;
public class BlockSkull extends Block implements Rotatable {
public BlockSkull() {
super(Material.SMALL);
this.setDefaultState(this.getBaseState().withProperty(FACING, Facing.NORTH));
this.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F);
}
public boolean canPlaceBlockAt(World world, BlockPos pos) {
return world.getState(pos).getBlock().getMaterial().isReplaceable() && world.isBlockSolid(pos.down());
}
public State onBlockPlaced(World world, BlockPos pos, Facing face, float hitX, float hitY, float hitZ, EntityLiving placer) {
return this.getState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}
public State getStateFromMeta(int meta) {
return this.getState().withProperty(FACING, Facing.getHorizontal(meta));
}
public int getMetaFromState(State state) {
return state.getValue(FACING).getHorizontalIndex();
}
protected Property[] getProperties() {
return new Property[] {FACING};
}
public Model getModel(ModelProvider provider, String name, State state) {
return provider.getModel("skull_top").add(4, 0, 4, 12, 8, 12)
.d("skull_bottom").u().n("skull_front").s("skull_back").w("skull_right").e("skull_left").rotate(ModelRotation.getNorthRot(state.getValue(FACING)));
}
public boolean isOpaqueCube() {
return false;
}
public boolean isFullCube() {
return false;
}
public Item getItemDropped(State state, Random rand, int fortune) {
return Items.skull;
}
public Item getItem(World worldIn, BlockPos pos) {
return Items.skull;
}
public boolean isXrayVisible() {
return true;
}
public boolean onShot(World world, BlockPos pos, State state, Entity projectile) {
world.destroyBlock(pos, true);
return true;
}
protected Item getItemToRegister() {
return new ItemSmallBlock(this).setDisplay("Schädel").setTab(CheatTab.DECORATION);
}
}