initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
93
java/src/game/item/ItemSign.java
Executable file
93
java/src/game/item/ItemSign.java
Executable file
|
@ -0,0 +1,93 @@
|
|||
package game.item;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.block.Block;
|
||||
import game.block.BlockStandingSign;
|
||||
import game.block.BlockWallSign;
|
||||
import game.entity.npc.EntityNPC;
|
||||
import game.init.Blocks;
|
||||
import game.tileentity.TileEntity;
|
||||
import game.tileentity.TileEntitySign;
|
||||
import game.world.BlockPos;
|
||||
import game.world.Facing;
|
||||
import game.world.World;
|
||||
|
||||
public class ItemSign extends Item
|
||||
{
|
||||
public ItemSign()
|
||||
{
|
||||
this.setTab(CheatTab.tabDeco);
|
||||
}
|
||||
|
||||
public Block getBlock()
|
||||
{
|
||||
return Blocks.sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a Block is right-clicked with this Item
|
||||
*/
|
||||
public boolean onItemUse(ItemStack stack, EntityNPC playerIn, World worldIn, BlockPos pos, Facing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (side == Facing.DOWN)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!worldIn.getState(pos).getBlock().getMaterial().isSolid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = pos.offset(side);
|
||||
|
||||
if (!playerIn.canPlayerEdit(pos, side, stack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!Blocks.sign.canPlaceBlockAt(worldIn, pos))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (worldIn.client)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (side == Facing.UP)
|
||||
{
|
||||
int i = ExtMath.floord((double)((playerIn.rotYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
|
||||
worldIn.setState(pos, Blocks.sign.getState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
worldIn.setState(pos, Blocks.wall_sign.getState().withProperty(BlockWallSign.FACING, side), 3);
|
||||
}
|
||||
|
||||
--stack.stackSize;
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
|
||||
if (tileentity instanceof TileEntitySign && !ItemBlock.setTileEntityNBT(worldIn, playerIn, pos, stack))
|
||||
{
|
||||
playerIn.openEditSign((TileEntitySign)tileentity);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public Set<String> getValidTags() {
|
||||
// return Sets.newHashSet("BlockEntityTag");
|
||||
// }
|
||||
//
|
||||
// protected boolean validateNbt(NBTTagCompound tag) {
|
||||
// if(tag.hasKey("BlockEntityTag")) {
|
||||
// if(!tag.hasKey("BlockEntityTag", 10)) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue