Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package assets.betterdefense.common;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockBed;
- import net.minecraft.client.renderer.texture.IconRegister;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityList;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemBed;
- import net.minecraft.item.ItemBlock;
- import net.minecraft.item.ItemStack;
- import net.minecraft.potion.Potion;
- import net.minecraft.potion.PotionEffect;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.util.DamageSource;
- import net.minecraft.util.MathHelper;
- import net.minecraft.world.World;
- public class BedPlacer extends Item
- {
- public BedPlacer(int par1) {
- super(par1);
- this.setCreativeTab(BetterDefense.TabBetterDefense);
- }
- public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
- {
- if (par3World.isRemote)
- {
- return true;
- }
- else if (par7 != 1)
- {
- return false;
- }
- else
- {
- ++par5;
- My_Bed MyBed = (My_Bed)BetterDefense.MyBed;
- int i1 = MathHelper.floor_double((double)(par2EntityPlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
- byte b0 = 0;
- byte b1 = 0;
- if (i1 == 0)
- {
- b1 = 1;
- }
- if (i1 == 1)
- {
- b0 = -1;
- }
- if (i1 == 2)
- {
- b1 = -1;
- }
- if (i1 == 3)
- {
- b0 = 1;
- }
- if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) && par2EntityPlayer.canPlayerEdit(par4 + b0, par5, par6 + b1, par7, par1ItemStack))
- {
- if (par3World.getBlockId(par4, par5 - 1, par6) == Block.grass.blockID)
- {
- par3World.setBlock(par4, par5, par6, MyBed.blockID, i1, 3);
- if (par3World.getBlockId(par4, par5, par6) == MyBed.blockID)
- {
- par3World.setBlock(par4 + b0, par5, par6 + b1, MyBed.blockID, i1 + 8, 3);
- }
- --par1ItemStack.stackSize;
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- }
- @Override
- public void registerIcons(IconRegister par1IconRegister)
- {
- this.itemIcon = par1IconRegister.registerIcon("betterdefense:W.I.P");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement