use of net.minecraft.item.ItemSword in project kull by Sxmurai.
the class ItemInWorldManager method tryHarvestBlock.
/**
* Attempts to harvest a block
*/
public boolean tryHarvestBlock(BlockPos pos) {
if (this.gameType.isCreative() && this.thisPlayerMP.getHeldItem() != null && this.thisPlayerMP.getHeldItem().getItem() instanceof ItemSword) {
return false;
} else {
IBlockState iblockstate = this.theWorld.getBlockState(pos);
TileEntity tileentity = this.theWorld.getTileEntity(pos);
if (this.gameType.isAdventure()) {
if (this.gameType == WorldSettings.GameType.SPECTATOR) {
return false;
}
if (!this.thisPlayerMP.isAllowEdit()) {
ItemStack itemstack = this.thisPlayerMP.getCurrentEquippedItem();
if (itemstack == null) {
return false;
}
if (!itemstack.canDestroy(iblockstate.getBlock())) {
return false;
}
}
}
this.theWorld.playAuxSFXAtEntity(this.thisPlayerMP, 2001, pos, Block.getStateId(iblockstate));
boolean flag1 = this.removeBlock(pos);
if (this.isCreative()) {
this.thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(this.theWorld, pos));
} else {
ItemStack itemstack1 = this.thisPlayerMP.getCurrentEquippedItem();
boolean flag = this.thisPlayerMP.canHarvestBlock(iblockstate.getBlock());
if (itemstack1 != null) {
itemstack1.onBlockDestroyed(this.theWorld, iblockstate.getBlock(), pos, this.thisPlayerMP);
if (itemstack1.stackSize == 0) {
this.thisPlayerMP.destroyCurrentEquippedItem();
}
}
if (flag1 && flag) {
iblockstate.getBlock().harvestBlock(this.theWorld, this.thisPlayerMP, pos, iblockstate, tileentity);
}
}
return flag1;
}
}
use of net.minecraft.item.ItemSword in project UtilityClient2 by Utility-Client.
the class PlayerControllerMP method onPlayerDestroyBlock.
/**
* Called when a player completes the destruction of a block
*/
public boolean onPlayerDestroyBlock(BlockPos pos, EnumFacing side) {
if (this.currentGameType.isAdventure()) {
if (this.currentGameType == WorldSettings.GameType.SPECTATOR) {
return false;
}
if (!this.mc.thePlayer.isAllowEdit()) {
Block block = this.mc.theWorld.getBlockState(pos).getBlock();
ItemStack itemstack = this.mc.thePlayer.getCurrentEquippedItem();
if (itemstack == null) {
return false;
}
if (!itemstack.canDestroy(block)) {
return false;
}
}
}
if (this.currentGameType.isCreative() && this.mc.thePlayer.getHeldItem() != null && this.mc.thePlayer.getHeldItem().getItem() instanceof ItemSword) {
return false;
} else {
World world = this.mc.theWorld;
IBlockState iblockstate = world.getBlockState(pos);
Block block1 = iblockstate.getBlock();
if (block1.getMaterial() == Material.air) {
return false;
} else {
world.playAuxSFX(2001, pos, Block.getStateId(iblockstate));
boolean flag = world.setBlockToAir(pos);
if (flag) {
block1.onBlockDestroyedByPlayer(world, pos, iblockstate);
}
this.currentBlock = new BlockPos(this.currentBlock.getX(), -1, this.currentBlock.getZ());
if (!this.currentGameType.isCreative()) {
ItemStack itemstack1 = this.mc.thePlayer.getCurrentEquippedItem();
if (itemstack1 != null) {
itemstack1.onBlockDestroyed(world, block1, pos, this.mc.thePlayer);
if (itemstack1.stackSize == 0) {
this.mc.thePlayer.destroyCurrentEquippedItem();
}
}
}
return flag;
}
}
}
use of net.minecraft.item.ItemSword in project UtilityClient2 by Utility-Client.
the class ItemInWorldManager method tryHarvestBlock.
/**
* Attempts to harvest a block
*/
public boolean tryHarvestBlock(BlockPos pos) {
if (this.gameType.isCreative() && this.thisPlayerMP.getHeldItem() != null && this.thisPlayerMP.getHeldItem().getItem() instanceof ItemSword) {
return false;
} else {
IBlockState iblockstate = this.theWorld.getBlockState(pos);
TileEntity tileentity = this.theWorld.getTileEntity(pos);
if (this.gameType.isAdventure()) {
if (this.gameType == WorldSettings.GameType.SPECTATOR) {
return false;
}
if (!this.thisPlayerMP.isAllowEdit()) {
ItemStack itemstack = this.thisPlayerMP.getCurrentEquippedItem();
if (itemstack == null) {
return false;
}
if (!itemstack.canDestroy(iblockstate.getBlock())) {
return false;
}
}
}
this.theWorld.playAuxSFXAtEntity(this.thisPlayerMP, 2001, pos, Block.getStateId(iblockstate));
boolean flag1 = this.removeBlock(pos);
if (this.isCreative()) {
this.thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(this.theWorld, pos));
} else {
ItemStack itemstack1 = this.thisPlayerMP.getCurrentEquippedItem();
boolean flag = this.thisPlayerMP.canHarvestBlock(iblockstate.getBlock());
if (itemstack1 != null) {
itemstack1.onBlockDestroyed(this.theWorld, iblockstate.getBlock(), pos, this.thisPlayerMP);
if (itemstack1.stackSize == 0) {
this.thisPlayerMP.destroyCurrentEquippedItem();
}
}
if (flag1 && flag) {
iblockstate.getBlock().harvestBlock(this.theWorld, this.thisPlayerMP, pos, iblockstate, tileentity);
}
}
return flag1;
}
}
use of net.minecraft.item.ItemSword in project Almura by AlmuraDev.
the class MixinTileEntityFurnace method getItemBurnTime.
/**
* @author Dockter - Mike Howe
* @reason Add additional fuel blocks
*/
// TODO: migrate this to a targetted injection vs. Override.
@Overwrite
public static int getItemBurnTime(ItemStack stack) {
if (stack.isEmpty()) {
return 0;
} else {
Item item = stack.getItem();
// Almura: additional blocks for fuel
if (item == Item.getItemFromBlock(Blocks.MAGMA)) {
return 12500;
}
Block charcoalBlock = Block.getBlockFromName("almura:horizontal/building/charcoalblock");
if (charcoalBlock != null && item == Item.getItemFromBlock(charcoalBlock)) {
return 10000;
}
if (item.getTranslationKey().length() > 19 && item.getTranslationKey().substring(5, 19).equalsIgnoreCase("almura.sapling")) {
// tile.almura.sapling
return 200;
}
if (item == Item.getItemFromBlock(Blocks.WOODEN_SLAB)) {
return 150;
} else if (item == Item.getItemFromBlock(Blocks.WOOL)) {
return 100;
} else if (item == Item.getItemFromBlock(Blocks.CARPET)) {
return 67;
} else if (item == Item.getItemFromBlock(Blocks.LADDER)) {
return 300;
} else if (item == Item.getItemFromBlock(Blocks.WOODEN_BUTTON)) {
return 100;
} else if (Block.getBlockFromItem(item).getDefaultState().getMaterial() == Material.WOOD) {
return 300;
} else if (item == Item.getItemFromBlock(Blocks.COAL_BLOCK)) {
return 16000;
} else if (item instanceof ItemTool && "WOOD".equals(((ItemTool) item).getToolMaterialName())) {
return 200;
} else if (item instanceof ItemSword && "WOOD".equals(((ItemSword) item).getToolMaterialName())) {
return 200;
} else if (item instanceof ItemHoe && "WOOD".equals(((ItemHoe) item).getMaterialName())) {
return 200;
} else if (item == Items.STICK) {
return 100;
} else if (item != Items.BOW && item != Items.FISHING_ROD) {
if (item == Items.SIGN) {
return 200;
} else if (item == Items.COAL) {
return 1600;
} else if (item == Items.LAVA_BUCKET) {
return 20000;
} else if (item != Item.getItemFromBlock(Blocks.SAPLING) && item != Items.BOWL) {
if (item == Items.BLAZE_ROD) {
return 2400;
} else if (item instanceof ItemDoor && item != Items.IRON_DOOR) {
return 200;
} else {
return item instanceof ItemBoat ? 400 : 0;
}
} else {
return 100;
}
} else {
return 300;
}
}
}
use of net.minecraft.item.ItemSword in project Minechem by iopleke.
the class AugmentedItem method renderOverlay.
@Override
public void renderOverlay(FontRenderer fontRenderer, TextureManager textureManager, ItemStack itemStack, int left, int top, float z) {
RenderHelper.enableBlend();
RenderHelper.setOpacity(1.0F);
textureManager.bindTexture(TextureMap.locationItemsTexture);
ItemStack wrappedItemStack = getWrappedItemStack(itemStack);
if (wrappedItemStack != null) {
Item wrappedItem = wrappedItemStack.getItem();
if (wrappedItem instanceof ItemAxe) {
RenderHelper.drawTexturedRectUV(left, top, z + 10, 16, 16, augmentIcon[AXEICON]);
} else if (wrappedItem instanceof ItemHoe) {
RenderHelper.drawTexturedRectUV(left, top, z + 10, 16, 16, augmentIcon[HOEICON]);
} else if (wrappedItem instanceof ItemPickaxe) {
RenderHelper.drawTexturedRectUV(left, top, z + 10, 16, 16, augmentIcon[PICKICON]);
} else if (wrappedItem instanceof ItemSpade) {
RenderHelper.drawTexturedRectUV(left, top, z + 10, 16, 16, augmentIcon[SHOVELICON]);
} else if (wrappedItem instanceof ItemSword) {
RenderHelper.drawTexturedRectUV(left, top, z + 10, 16, 16, augmentIcon[SWORDICON]);
} else {
RenderHelper.drawTexturedRectUV(left, top, z + 10, 16, 16, augmentIcon[DEFAULTICON]);
}
}
RenderHelper.resetOpacity();
RenderHelper.disableBlend();
}
Aggregations