2018-09-13 12:03:28 -04:00
|
|
|
package noppes.npcs.blocks;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.init.Blocks;
|
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
|
import net.minecraft.util.ChatComponentTranslation;
|
|
|
|
|
import net.minecraft.util.MathHelper;
|
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
import noppes.npcs.blocks.tiles.TileBanner;
|
|
|
|
|
import noppes.npcs.blocks.tiles.TileSign;
|
2025-02-20 21:40:39 -05:00
|
|
|
import noppes.npcs.blocks.tiles.TileVariant;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2023-01-12 21:33:06 -05:00
|
|
|
import java.util.List;
|
|
|
|
|
|
2025-03-12 20:12:01 -04:00
|
|
|
public class BlockSign extends BlockRotated {
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2025-03-12 20:12:01 -04:00
|
|
|
public BlockSign() {
|
2018-09-13 12:03:28 -04:00
|
|
|
super(Blocks.planks);
|
2025-03-12 20:12:01 -04:00
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
2025-02-13 03:12:46 -05:00
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
|
|
|
|
|
int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
|
2018-09-13 12:03:28 -04:00
|
|
|
l %= 4;
|
|
|
|
|
TileSign tile = (TileSign) par1World.getTileEntity(par2, par3, par4);
|
2025-03-12 20:12:01 -04:00
|
|
|
tile.rotation = l;
|
|
|
|
|
tile.time = System.currentTimeMillis();
|
|
|
|
|
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2);
|
|
|
|
|
if (par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote)
|
|
|
|
|
((EntityPlayer) par5EntityLivingBase).addChatComponentMessage(new ChatComponentTranslation("availability.editIcon"));
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
2025-02-13 03:12:46 -05:00
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
|
|
|
|
TileBanner tile = (TileBanner) world.getTileEntity(x, y, z);
|
|
|
|
|
return tile.canEdit();
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|
2025-02-13 03:12:46 -05:00
|
|
|
|
|
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
2018-09-13 12:03:28 -04:00
|
|
|
par3List.add(new ItemStack(par1, 1, 0));
|
|
|
|
|
par3List.add(new ItemStack(par1, 1, 1));
|
|
|
|
|
par3List.add(new ItemStack(par1, 1, 2));
|
|
|
|
|
par3List.add(new ItemStack(par1, 1, 3));
|
|
|
|
|
par3List.add(new ItemStack(par1, 1, 4));
|
|
|
|
|
par3List.add(new ItemStack(par1, 1, 5));
|
|
|
|
|
}
|
2025-02-13 03:12:46 -05:00
|
|
|
|
|
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
|
|
|
|
|
TileEntity tileentity = world.getTileEntity(x, y, z);
|
|
|
|
|
if (!(tileentity instanceof TileVariant)) {
|
|
|
|
|
super.setBlockBoundsBasedOnState(world, x, y, z);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
TileVariant tile = (TileVariant) tileentity;
|
|
|
|
|
if (tile.rotation % 2 == 1)
|
2018-09-13 12:03:28 -04:00
|
|
|
setBlockBounds(0, 0.3f, 0.3f, 1, 1, 0.7f);
|
2025-03-12 20:12:01 -04:00
|
|
|
else
|
2018-09-13 12:03:28 -04:00
|
|
|
setBlockBounds(0.3f, 0.3f, 0, 0.7f, 1, 1);
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-13 03:12:46 -05:00
|
|
|
@Override
|
2025-03-12 20:12:01 -04:00
|
|
|
public int damageDropped(int par1) {
|
2018-09-13 12:03:28 -04:00
|
|
|
return par1;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-12 20:12:01 -04:00
|
|
|
@Override
|
|
|
|
|
public TileEntity createNewTileEntity(World var1, int var2) {
|
|
|
|
|
return new TileSign();
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|