@Override public float work() { if (WorkUtils.isDisabled(this.getBlockType())) return 0; List<BlockPos> blockPosList = BlockUtils.getBlockPosInAABB(getWorkingArea()); for (BlockPos pos : blockPosList) { if (this.world.isAirBlock(pos)) { ItemStack stack = getFirstStackHasBlock(); if (stack.isEmpty()) return 0; if (this.world.isAirBlock(pos)) { FakePlayer player = IndustrialForegoing.getFakePlayer(this.world); player.setHeldItem(EnumHand.MAIN_HAND, stack); EnumActionResult result = ForgeHooks.onPlaceItemIntoWorld(stack, player, world, pos, EnumFacing.UP, 0, 0, 0, EnumHand.MAIN_HAND); return result == EnumActionResult.SUCCESS ? 1 : 0; } } } return 0; }
private List<ITextComponent> resizeContent(List<String> lines) { List<ITextComponent> ret = new ArrayList<ITextComponent>(); for (String line : lines) { if (line == null) { ret.add(null); continue; } ITextComponent chat = ForgeHooks.newChatWithLinks(line, false); ret.addAll(GuiUtilRenderComponents.splitText(chat, this.listWidth-8, GuiModList.this.fontRendererObj, false, true)); } return ret; }
public BreakEvent(World world, BlockPos pos, IBlockState state, EntityPlayer player) { super(world, pos, state); this.player = player; if (state == null || !ForgeHooks.canHarvestBlock(state.getBlock(), player, world, pos) || // Handle empty block or player unable to break block scenario (state.getBlock().canSilkHarvest(world, pos, world.getBlockState(pos), player) && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) > 0)) // If the block is being silk harvested, the exp dropped is 0 { this.exp = 0; } else { int bonusLevel = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, player.getHeldItemMainhand()); this.exp = state.getBlock().getExpDrop(state, world, pos, bonusLevel); } }
@Override public void onClickAir(PossessivePlayer possessivePlayer, EntityPlayer player) { RayTraceResult result = ForgeHooks.rayTraceEyes(player, 64); if (result != null && result.typeOfHit != RayTraceResult.Type.MISS) { if (result.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos pos = result.getBlockPos().offset(result.sideHit); player.setPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); } else { Entity entityHit = result.entityHit; player.setPosition(entityHit.posX, entityHit.posY, entityHit.posZ); } if (!player.capabilities.isCreativeMode) { player.attackEntityFrom(DamageSource.fall, 4.0F); } player.worldObj.playSound(null, player.prevPosX, player.prevPosY, player.prevPosZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, player.getSoundCategory(), 1.0F, 1.0F); player.worldObj.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, player.getSoundCategory(), 1.0F, 1.0F); } }
@Override protected void jump() { this.motionY = 0.48D / WorldUtil.getGravityFactor(this); if (this.motionY < 0.28D) this.motionY = 0.28D; if (this.isPotionActive(Potion.jump)) { this.motionY += (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F; } if (this.isSprinting()) { float f = this.rotationYaw * 0.017453292F; this.motionX -= MathHelper.sin(f) * 0.2F; this.motionZ += MathHelper.cos(f) * 0.2F; } this.isAirBorne = true; ForgeHooks.onLivingJump(this); }
@Override protected void jump() { this.motionY = 0.52D / WorldUtil.getGravityFactor(this); if (this.motionY < 0.26D) this.motionY = 0.26D; if (this.isPotionActive(Potion.jump)) { this.motionY += (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F; } if (this.isSprinting()) { float f = this.rotationYaw * 0.017453292F; this.motionX -= MathHelper.sin(f) * 0.2F; this.motionZ += MathHelper.cos(f) * 0.2F; } this.isAirBorne = true; ForgeHooks.onLivingJump(this); }
@Override protected void jump() { this.motionY = 0.45D / WorldUtil.getGravityFactor(this); if (this.motionY < 0.22D) this.motionY = 0.22D; if (this.isPotionActive(Potion.jump)) { this.motionY += (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F; } if (this.isSprinting()) { float f = this.rotationYaw * 0.017453292F; this.motionX -= MathHelper.sin(f) * 0.2F; this.motionZ += MathHelper.cos(f) * 0.2F; } this.isAirBorne = true; ForgeHooks.onLivingJump(this); }
@Override protected void jump() { this.motionY = 0.48D / WorldUtil.getGravityFactor(this); if (this.motionY < 0.24D) this.motionY = 0.24D; if (this.isPotionActive(Potion.jump)) { this.motionY += (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F; } if (this.isSprinting()) { float f = this.rotationYaw * 0.017453292F; this.motionX -= MathHelper.sin(f) * 0.2F; this.motionZ += MathHelper.cos(f) * 0.2F; } this.isAirBorne = true; ForgeHooks.onLivingJump(this); }
@Override protected void jump() { this.motionY = 0.45D / WorldUtil.getGravityFactor(this); if (this.motionY < 0.24D) this.motionY = 0.24D; if (this.isPotionActive(Potion.jump)) { this.motionY += (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F; } if (this.isSprinting()) { float f = this.rotationYaw * 0.017453292F; this.motionX -= MathHelper.sin(f) * 0.2F; this.motionZ += MathHelper.cos(f) * 0.2F; } this.isAirBorne = true; ForgeHooks.onLivingJump(this); }
protected void damageEntity(DamageSource p_70665_1_, float p_70665_2_) { ; ; ; if (!isEntityInvulnerable()) { p_70665_2_ = ForgeHooks.onLivingHurt(this, p_70665_1_, p_70665_2_); if (p_70665_2_ <= 0.0F) { return; } p_70665_2_ = applyArmorCalculations(p_70665_1_, p_70665_2_); p_70665_2_ = applyPotionDamageCalculations(p_70665_1_, p_70665_2_); float f1 = p_70665_2_; p_70665_2_ = Math.max(p_70665_2_ - getAbsorptionAmount(), 0.0F); setAbsorptionAmount(getAbsorptionAmount() - (f1 - p_70665_2_)); if (p_70665_2_ != 0.0F) { float f2 = getHealth(); setHealth(f2 - p_70665_2_); func_110142_aN().func_94547_a(p_70665_1_, f2, p_70665_2_); setAbsorptionAmount(getAbsorptionAmount() - p_70665_2_); } } }
@Override public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) { NonNullList<ItemStack> ret = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY); for (int i = 0; i < ret.size(); i++) { if(i == pickSlot){ ItemStack pick = inv.getStackInSlot(i); int current = pick.getItemDamage(); int count = ItemStackTools.getStackSize(output); if(count > 0)pick.setItemDamage(current+count); if(pick.getItemDamage() < pick.getMaxDamage()){ inv.setInventorySlotContents(i, ItemStackTools.getEmptyStack()); ret.set(i, pick); } } else ret.set(i, ForgeHooks.getContainerItem(inv.getStackInSlot(i))); } return ret; }
public BreakEvent(int x, int y, int z, World world, Block block, int blockMetadata, EntityPlayer player) { super(x, y, z, world, block, blockMetadata); this.player = player; if (block == null || !ForgeHooks.canHarvestBlock(block, player, blockMetadata) || // Handle empty block or player unable to break block scenario block.canSilkHarvest(world, player, x, y, z, blockMetadata) && EnchantmentHelper.func_77502_d(player)) // If the block is being silk harvested, the exp dropped is 0 { this.exp = 0; } else { int meta = block.func_149643_k(world, x, y, z); int bonusLevel = EnchantmentHelper.func_77517_e(player); this.exp = block.getExpDrop(world, meta, bonusLevel); } }
@Nonnull @Override public NonNullList<ItemStack> getRemainingItems(@Nonnull InventoryCrafting inv) { NonNullList<ItemStack> remainingItems = ForgeHooks.defaultRecipeGetRemainingItems(inv); ItemStack sword; for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack stack = inv.getStackInSlot(i); if (stack.getItem() == Items.GOLDEN_SWORD) { sword = stack.copy(); sword.setItemDamage(sword.getItemDamage() + 1); if (sword.getItemDamage() > sword.getMaxDamage()) sword = null; if (sword != null) { remainingItems.set(i, sword); } break; } } return remainingItems; }
@Override @SuppressWarnings("deprecation") public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if ((this.getStrVsBlock(stack, world.getBlockState(pos)) == this.efficiencyOnProperMaterial || ForgeHooks.isToolEffective(world, pos, stack)) && world.isAirBlock(pos.up())) { if (world.getTileEntity(pos) != null || world.getBlockState(pos).getBlock().getBlockHardness(world.getBlockState(pos), world, pos) == -1.0F) { return EnumActionResult.FAIL; } if (!world.isRemote) { EntityFloatingBlock entity = new EntityFloatingBlock(world, pos, world.getBlockState(pos)); world.spawnEntityInWorld(entity); world.setBlockToAir(pos); } stack.damageItem(4, player); } return EnumActionResult.SUCCESS; }
@Override public ItemStack[] getRemainingItems(InventoryCrafting inventoryCrafting) { final ItemStack[] remainingItems = new ItemStack[inventoryCrafting.getSizeInventory()]; for (int i = 0; i < remainingItems.length; ++i) { final ItemStack itemstack = inventoryCrafting.getStackInSlot(i); if (itemstack != null && itemstack.getItem() instanceof ItemAxe) { remainingItems[i] = damageAxe(itemstack.copy()); } else { remainingItems[i] = ForgeHooks.getContainerItem(itemstack); } } return remainingItems; }
@Override public ItemStack[] getRemainingItems(InventoryCrafting inventoryCrafting) { // Crafting result array final ItemStack[] remainingItems = new ItemStack[inventoryCrafting.getSizeInventory()]; // For each item in the crafting grid... for (int i = 0; i < remainingItems.length; ++i) { // Get the ItemStack final ItemStack itemstack = inventoryCrafting.getStackInSlot(i); // If the ItemStack is in the config for freeLightItems if (itemstack != null && ModConfig.freeLightItems.contains(itemstack.getItem().getRegistryName())) { remainingItems[i] = itemstack.copy(); // Don't consume the item } else { remainingItems[i] = ForgeHooks.getContainerItem(itemstack); // Consume the item } } return remainingItems; }
@Override public ItemStack[] getRemainingItems(InventoryCrafting inventoryCrafting) { // Crafting result array final ItemStack[] remainingItems = new ItemStack[inventoryCrafting.getSizeInventory()]; // For each item in the crafting grid... for (int i = 0; i < remainingItems.length; ++i) { // Get the ItemStack final ItemStack itemstack = inventoryCrafting.getStackInSlot(i); // If the ItemStack is in the config for lightItems if (itemstack != null && ModConfig.lightItems.contains(itemstack.getItem().getRegistryName())) { remainingItems[i] = damageItem(itemstack.copy()); // Leave a damaged lighter in the grid } else { remainingItems[i] = ForgeHooks.getContainerItem(itemstack); // Consume the item } } return remainingItems; }
void setPower(Observation observation) { int power = 0; for (int j = -1; j <= 1; ++j) { for (int k = -1; k <= 1; ++k) { if ((j != 0 || k != 0) && world.isAirBlock(position.add(k, 0, j)) && world.isAirBlock(position.add(k, 1, j))) { power += ForgeHooks.getEnchantPower(world, position.add(k * 2, 0, j * 2)); power += ForgeHooks.getEnchantPower(world, position.add(k * 2, 1, j * 2)); if (k != 0 && j != 0) { power += ForgeHooks.getEnchantPower(world, position.add(k * 2, 0, j)); power += ForgeHooks.getEnchantPower(world, position.add(k * 2, 1, j)); power += ForgeHooks.getEnchantPower(world, position.add(k, 0, j * 2)); power += ForgeHooks.getEnchantPower(world, position.add(k, 1, j * 2)); } } } } observation.power = power; }
@Callback(doc="function(message:string); say some text") public Object[] say(Context context, Arguments arguments) throws Exception{ String message = arguments.checkString(0); if (message.length() > Config.maxMessageLength) message = message.substring(0, Config.maxMessageLength); System.out.println(String.format("say: x=%d, y=%d, z=%d", xCoord, yCoord, zCoord)); List<EntityPlayer> players = worldObj.playerEntities; for (EntityPlayer player : players){ if (player.getDistance(this.xCoord, this.yCoord, this.zCoord) <= radius){ player.addChatMessage(ForgeHooks.newChatWithLinks(message)); } } return new Object[]{}; }
/** * ブロックを破壊します * * @param world world * @param x x座標 * @param y y座標 * @param z z座標 * @param player プレイヤー * @param centerBlock 中心のブロック * @param cX 中心のブロックのx座標 * @param cY 中心のブロックのy座標 * @param cZ 中心のブロックのz座標 * @param toolStack 破壊に使用したツールのItemStack */ private void blockDestroy(World world, int x, int y, int z, EntityPlayerMP player, Block centerBlock, int cX, int cY, int cZ, ItemStack toolStack) { if (!world.isAirBlock(x, y, z)) { Block block = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); if (canDestroyBlock(toolStack, block, meta) && (centerBlock.getBlockHardness(world, cX, cY, cZ) - block.getBlockHardness(world, x, y, z)) <= 3F) { BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z); if (!event.isCanceled()) { block.onBlockHarvested(world, x, y, z, meta, player); if (block.removedByPlayer(world, player, x, y, z, false)) { block.onBlockDestroyedByPlayer(world, x, y, z, meta); block.harvestBlock(world, player, x, y, z, meta); } if (!world.isRemote) { player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); } } } } }
/** * Handles right clicking of an item */ public EnumActionResult processRightClick(ItemStack stack, EnumHand hand) { if (getSettler().getCooldownTracker().hasCooldown(stack.getItem())) { return EnumActionResult.PASS; } else { EnumActionResult eventResult = ForgeHooks.onItemRightClick(getSettler().getFakePlayerImplementation(), hand); if (eventResult != null) { return eventResult; } int stackSize = stack.getCount(); int meta = stack.getMetadata(); ActionResult<ItemStack> result = stack.useItemRightClick(getWorld(), getSettler().getFakePlayerImplementation(), hand); ItemStack newStack = result.getResult(); if (newStack == stack && newStack.getCount() == stackSize && newStack.getMaxItemUseDuration() <= 0 && newStack.getMetadata() == meta) { return result.getType(); } else { getSettler().setHeldItem(hand, newStack); if (newStack.isEmpty()) { getSettler().setHeldItem(hand, ItemStack.EMPTY); ForgeEventFactory.onPlayerDestroyItem(getSettler().getFakePlayerImplementation(), newStack, hand); } } return result.getType(); } }
public BreakEvent(int x, int y, int z, World world, Block block, int blockMetadata, EntityPlayer player) { super(x, y, z, world, block, blockMetadata); this.player = player; if (block == null || !ForgeHooks.canHarvestBlock(block, player, blockMetadata) || // Handle empty block or player unable to break block scenario block.canSilkHarvest(world, player, x, y, z, blockMetadata) && EnchantmentHelper.getSilkTouchModifier(player)) // If the block is being silk harvested, the exp dropped is 0 { this.exp = 0; } else { int meta = block.getDamageValue(world, x, y, z); int bonusLevel = EnchantmentHelper.getFortuneModifier(player); this.exp = block.getExpDrop(world, meta, bonusLevel); } }
@Override public void collideWithEntity(Entity entity) { super.collideWithEntity(entity); if (!(entity instanceof EntitySteelSheep)) { if (entity instanceof EntityLivingBase) { ((EntityLivingBase)entity).attackEntityFrom(steelSheep,0.5F); ((EntityLivingBase)entity).motionY = 0.41999998688697815D; if (((EntityLivingBase)entity).isPotionActive(Potion.jump)) { ((EntityLivingBase)entity).motionY += (double)((float)(((EntityLivingBase)entity).getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F); } if (((EntityLivingBase)entity).isSprinting()) { float f = ((EntityLivingBase)entity).rotationYaw * 0.017453292F; ((EntityLivingBase)entity).motionX -= (double)(MathHelper.sin(f) * 0.2F); ((EntityLivingBase)entity).motionZ += (double)(MathHelper.cos(f) * 0.2F); } ((EntityLivingBase)entity).isAirBorne = true; ForgeHooks.onLivingJump(((EntityLivingBase)entity)); } } }
@Override public ItemStack[] getRemainingItems(InventoryCrafting inventoryCrafting) { ItemStack[] aitemstack = new ItemStack[inventoryCrafting.getSizeInventory()]; for (int i = 0; i < aitemstack.length; ++i) { ItemStack itemstack = inventoryCrafting.getStackInSlot(i); if (itemstack != null && itemstack.getItem() == ModItems.knife) { if (itemstack.attemptDamageItem(1, Utils.rand())) { if (--itemstack.stackSize < 1) { itemstack = null; } if (Utils.isClientSide()) { Minecraft.getMinecraft().thePlayer.playSound("random.break", 0.8F, 0.8F + Utils.rand().nextFloat() * 0.4F); } } aitemstack[i] = itemstack == null ? null : itemstack.copy(); } else { aitemstack[i] = ForgeHooks.getContainerItem(itemstack); } } return aitemstack; }
@Override protected void damageEntity(DamageSource damageSource, float amount) { amount = ForgeHooks.onLivingHurt(this, damageSource, amount); if(amount <= 0) { return; } amount = applyArmorCalculations(damageSource, amount); amount = applyPotionDamageCalculations(damageSource, amount); float j = getHealth(); setEnergy(Math.max(0, getEnergy() - (amount*1000))); func_110142_aN().func_94547_a(damageSource, j, amount); }
/** * Send message to sender, automatically check if sender is server or player. * If sender is server (console) remove color codes and proceed. Optionally enable clickable * links in chat messages * * @param sender of the command * @param message to the sender * @param linksEnabled if required disable or enable links */ public static void messageToSender(ICommandSender sender, String message, Boolean linksEnabled) { if (sender instanceof MinecraftServer) { // Sender = Console // IDEA get a better way message = message.replaceAll("§[a-f,0-9]", ""); // message = // EnumChatFormatting.getTextWithoutFormattingCodes(message); } else { // Sender = Player if (linksEnabled) { ((EntityPlayerMP) sender).addChatMessage(ForgeHooks.newChatWithLinks(message)); } else { messageToSender(sender, message); } } }
public void checkBlockBreak(World world, EntityPlayer player, int x, int y, int z, ItemStack stack, float strength, Block originalBlock, int side) { Block breakBlock = world.getBlock(x, y, z); if (this.canHarvestBlock(breakBlock, stack)) { float newStrength = ForgeHooks.blockStrength(breakBlock, player, world, x, y, z); Material material = originalBlock.getMaterial(); if (newStrength > 0f && strength / newStrength <= 10f && breakBlock.getMaterial() == material) { RandomUtils.breakBlock(world, breakBlock, x, y, z, side, player); if ((double) breakBlock.getBlockHardness(world, x, y, z) != 0.0D) { stack.damageItem(1, player); } } } }
public void checkBlockBreak(World world, EntityPlayer player, int x, int y, int z, ItemStack stack, float strength, Block originalBlock, int side) { Block breakBlock = world.getBlock(x, y, z); int metadata = world.getBlockMetadata(x, y, z); if (ForgeHooks.canToolHarvestBlock(breakBlock, metadata, stack)) { float newStrength = ForgeHooks.blockStrength(breakBlock, player, world, x, y, z); if (newStrength > 0f && strength / newStrength <= 10f) { RandomUtils.breakBlock(world, breakBlock, x, y, z, side, player); if ((double) breakBlock.getBlockHardness(world, x, y, z) != 0.0D) { stack.damageItem(1, player); } } } }
public void checkBlockBreak(World world, EntityPlayer player, BlockPos pos, ItemStack stack, float strength, Block originalBlock, EnumFacing side) { IBlockState state = world.getBlockState(pos); Block breakBlock = state.getBlock(); Material material = originalBlock.getMaterial(state); if (breakBlock.getMaterial(state) == material && ForgeHooks.canHarvestBlock(breakBlock, player, world, pos) && stack.canHarvestBlock(state)) { float newStrength = ForgeHooks.blockStrength(state, player, world, pos); if (newStrength > 0f && strength / newStrength <= 10f) { if ((double) breakBlock.getBlockHardness(state, world, pos) != 0.0D) { if (DamageHandler.handleDamage(false, state, stack, player)) { BlockUtils.tryHarvestBlock(world, state, pos, side, player); } } else { BlockUtils.tryHarvestBlock(world, state, pos, side, player); } } } }
private float getEnchantPower() { float power = 0; for (int j = -1; j <= 1; ++j) { for (int k = -1; k <= 1; ++k) { if ((j != 0 || k != 0) && getWorldObj().isAirBlock(xCoord + k, yCoord, zCoord + j) && getWorldObj().isAirBlock(xCoord + k, yCoord + 1, zCoord + j)) { power += ForgeHooks.getEnchantPower(getWorldObj(), xCoord + k * 2, yCoord, zCoord + j * 2); power += ForgeHooks.getEnchantPower(getWorldObj(), xCoord + k * 2, yCoord + 1, zCoord + j * 2); if (k != 0 && j != 0) { power += ForgeHooks.getEnchantPower(getWorldObj(), xCoord + k * 2, yCoord, zCoord + j); power += ForgeHooks.getEnchantPower(getWorldObj(), xCoord + k * 2, yCoord + 1, zCoord + j); power += ForgeHooks.getEnchantPower(getWorldObj(), xCoord + k, yCoord, zCoord + j * 2); power += ForgeHooks.getEnchantPower(getWorldObj(), xCoord + k, yCoord + 1, zCoord + j * 2); } } } } return power; }
/** * Deals damage to the entity. If its a EntityPlayer then will take damage from the armor first and then health * second with the reduced value. Args: damageAmount */ protected void damageEntity(DamageSource par1DamageSource, float par2) { if (!this.isEntityInvulnerable()) { par2 = ForgeHooks.onLivingHurt(this, par1DamageSource, par2); if (par2 <= 0) return; par2 = this.applyArmorCalculations(par1DamageSource, par2); par2 = this.applyPotionDamageCalculations(par1DamageSource, par2); float f1 = par2; par2 = Math.max(par2 - this.getAbsorptionAmount(), 0.0F); this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - par2)); if (par2 != 0.0F) { float f2 = this.getHealth(); this.setHealth(f2 - par2); this.func_110142_aN().func_94547_a(par1DamageSource, f2, par2); this.setAbsorptionAmount(this.getAbsorptionAmount() - par2); } } }
public float getPlayerRelativeBlockHardness(EntityPlayer player, World world, int x, int y, int z) { TileEntity te = world.getTileEntity(x, y, z); if(te instanceof TileEntityPrivate) { TileEntityPrivate tePrivate = (TileEntityPrivate)te; if(!player.getGameProfile().equals(tePrivate.getOwner())) { return -1; } } else if(te instanceof TileEntityPassword) { TileEntityPassword tePass = (TileEntityPassword)te; if(!PrivatizerHelper.checkPassword(player, tePass.getPassword())) { return -1; } } return ForgeHooks.blockStrength(this, player, world, x, y, z); }
public float getPlayerRelativeBlockHardness(EntityPlayer player, World world, int x, int y, int z) { TileEntity te = world.getTileEntity(x, y, z); if(te instanceof TileEntityPrivateChest) { TileEntityPrivateChest tePrivate = (TileEntityPrivateChest)te; if(!player.getGameProfile().equals(tePrivate.getOwner())) { return -1; } } else if(te instanceof TileEntityPassword) { TileEntityPassword tePass = (TileEntityPassword)te; if(!PrivatizerHelper.checkPassword(player, tePass.getPassword())) { return -1; } } return ForgeHooks.blockStrength(this, player, world, x, y, z); }
@SubscribeEvent public void onBreakSpeed(BreakSpeed event) { if (event.block instanceof IBlockCustom) { BlockType type = ((IBlockCustom) event.block).getType(event.metadata); if (type.toolType.isEmpty()) { return; } ItemStack held = event.entityPlayer.getHeldItem(); if (held != null && !held.getItem().getToolClasses(held).contains(type.toolType)) { event.newSpeed = ForgeHooks.canHarvestBlock(event.block, event.entityPlayer, event.metadata) ? 0.3f : 1; } } }
/** * Called when player presses the drop item key */ public EntityItem dropOneItem(boolean par1) { ItemStack stack = inventory.getCurrentItem(); if (stack == null) { return null; } if (stack.getItem().onDroppedByPlayer(stack, this)) { int count = par1 && this.inventory.getCurrentItem() != null ? this.inventory.getCurrentItem().stackSize : 1; return ForgeHooks.onPlayerTossEvent(this, inventory.decrStackSize(inventory.currentItem, count)); } return null; }
@Override public void processCommand(ICommandSender sender, String[] par1String) throws CommandException { if(par1String.length == 0) throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage")); else if(par1String.length == 1){ if(par1String[0].matches("connect")) sender.addChatMessage(new ChatComponentText("[" + EnumChatFormatting.GREEN + "IRC" + EnumChatFormatting.WHITE + "] " + StatCollector.translateToLocal("messages.irc.connected") + " ").appendSibling(ForgeHooks.newChatWithLinks(SCEventHandler.tipsWithLink.get("discord")))); else if(par1String[0].matches("help")) getCommandSenderAsPlayer(sender).inventory.addItemStackToInventory(new ItemStack(SCContent.scManual)); else if(par1String[0].matches("bug")) PlayerUtils.sendMessageEndingWithLink(sender, "SecurityCraft", StatCollector.translateToLocal("messages.bugReport"), "http://goo.gl/forms/kfRpvvQzfl", EnumChatFormatting.GOLD); else throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage")); }else if(par1String.length >= 2){ if(par1String[0].matches("bug")) PlayerUtils.sendMessageEndingWithLink(sender, "SecurityCraft", StatCollector.translateToLocal("messages.bugReport"), "http://goo.gl/forms/kfRpvvQzfl", EnumChatFormatting.GOLD); else throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage")); } else throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage")); }
@Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { if(args.length == 0) throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage")); else if(args.length == 1){ if(args[0].matches("connect")) sender.addChatMessage(new ChatComponentText("[" + EnumChatFormatting.GREEN + "IRC" + EnumChatFormatting.WHITE + "] " + StatCollector.translateToLocal("messages.irc.connected") + " ").appendSibling(ForgeHooks.newChatWithLinks(SCEventHandler.tipsWithLink.get("discord")))); else if(args[0].matches("help")) getCommandSenderAsPlayer(sender).inventory.addItemStackToInventory(new ItemStack(SCContent.scManual)); else if(args[0].matches("bug")) PlayerUtils.sendMessageEndingWithLink(sender, "SecurityCraft", StatCollector.translateToLocal("messages.bugReport"), "http://goo.gl/forms/kfRpvvQzfl", EnumChatFormatting.GOLD); else throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage")); }else if(args.length >= 2){ if(args[0].matches("bug")) PlayerUtils.sendMessageEndingWithLink(sender, "SecurityCraft", StatCollector.translateToLocal("messages.bugReport"), "http://goo.gl/forms/kfRpvvQzfl", EnumChatFormatting.GOLD); else throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage")); } else throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage")); }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if(args.length == 0) throw new WrongUsageException(ClientUtils.localize("messages.command.sc.usage")); else if(args.length == 1){ if(args[0].matches("connect")) sender.sendMessage(new TextComponentString("[" + TextFormatting.GREEN + "IRC" + TextFormatting.WHITE + "] " + ClientUtils.localize("messages.irc.connected") + " ").appendSibling(ForgeHooks.newChatWithLinks(SCEventHandler.tipsWithLink.get("discord")))); else if(args[0].matches("help")) getCommandSenderAsPlayer(sender).inventory.addItemStackToInventory(new ItemStack(SCContent.scManual)); else if(args[0].matches("bug")) PlayerUtils.sendMessageEndingWithLink(sender, "SecurityCraft", ClientUtils.localize("messages.bugReport"), "http://goo.gl/forms/kfRpvvQzfl", TextFormatting.GOLD); else throw new WrongUsageException(ClientUtils.localize("messages.command.sc.usage")); }else if(args.length >= 2){ if(args[0].matches("bug")) PlayerUtils.sendMessageEndingWithLink(sender, "SecurityCraft", ClientUtils.localize("messages.bugReport"), "http://goo.gl/forms/kfRpvvQzfl", TextFormatting.GOLD); else throw new WrongUsageException(ClientUtils.localize("messages.command.sc.usage")); } else throw new WrongUsageException(ClientUtils.localize("messages.command.sc.usage")); }
@Override public void processCommand(ICommandSender sender, String[] par1String) { if(par1String.length == 0) throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage")); else if(par1String.length == 1){ if(par1String[0].matches("connect")) sender.addChatMessage(new ChatComponentText("[" + EnumChatFormatting.GREEN + "IRC" + EnumChatFormatting.WHITE + "] " + StatCollector.translateToLocal("messages.irc.connected") + " ").appendSibling(ForgeHooks.newChatWithLinks(SCEventHandler.tipsWithLink.get("discord")))); else if(par1String[0].matches("help")) getCommandSenderAsPlayer(sender).inventory.addItemStackToInventory(new ItemStack(SCContent.scManual)); else if(par1String[0].matches("bug")) PlayerUtils.sendMessageEndingWithLink(sender, "SecurityCraft", StatCollector.translateToLocal("messages.bugReport"), "http://goo.gl/forms/kfRpvvQzfl", EnumChatFormatting.GOLD); else throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage")); }else if(par1String.length >= 2){ if(par1String[0].matches("bug")) PlayerUtils.sendMessageEndingWithLink(sender, "SecurityCraft", StatCollector.translateToLocal("messages.bugReport"), "http://goo.gl/forms/kfRpvvQzfl", EnumChatFormatting.GOLD); else throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage")); } else throw new WrongUsageException(StatCollector.translateToLocal("messages.command.sc.usage")); }