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 PickleTweaks by BlakeBr0.
the class ReinforcementHandler method onBreakBlock.
@SubscribeEvent
public void onBreakBlock(BlockEvent.BreakEvent event) {
if (event.getPlayer() == null)
return;
ItemStack stack = event.getPlayer().getHeldItemMainhand();
if (stack.isEmpty())
return;
if (!blockBreakTool(stack.getItem()))
return;
if (!isBlockHardEnough(event.getState(), event.getWorld(), event.getPos()))
return;
if (ReinforcementHelper.isReinforced(stack) && stack.isItemDamaged()) {
int extra = ReinforcementHelper.useReinforcement(stack, stack.getItem() instanceof ItemSword ? 2 : 1);
stack.setItemDamage(ReinforcementHelper.getDurability(stack) + extra);
}
}
use of net.minecraft.item.ItemSword in project PickleTweaks by BlakeBr0.
the class ReinforcementRecipe method getReinforcementOutput.
public ItemStack getReinforcementOutput(InventoryCrafting inv) {
ItemStack tool = ItemStack.EMPTY;
boolean foundTool = false;
NonNullList<ItemStack> inputs = NonNullList.<ItemStack>create();
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack slotStack = inv.getStackInSlot(i);
if (slotStack.isEmpty()) {
continue;
}
ItemStack newSlotStack = slotStack.copy();
newSlotStack.setCount(1);
if (!foundTool && newSlotStack.isItemStackDamageable()) {
tool = newSlotStack;
foundTool = true;
continue;
} else {
inputs.add(newSlotStack);
}
}
if (tool.isEmpty()) {
return ItemStack.EMPTY;
}
if (inputs.isEmpty()) {
return ItemStack.EMPTY;
}
if (tool.getItem().hasContainerItem(tool)) {
return ItemStack.EMPTY;
}
if (ModConfig.confBrokenTools && TweakToolBreaking.isBroken(tool, tool.getItem() instanceof ItemSword ? 1 : 0)) {
return ItemStack.EMPTY;
}
if (ReinforcementBlacklist.isBlacklisted(tool.getItem())) {
return ItemStack.EMPTY;
}
int reeCount = 0;
boolean maxed = false;
int currentCount = ReinforcementHelper.getReinforcement(tool);
for (ItemStack mat : inputs) {
if (maxed)
return ItemStack.EMPTY;
if (ReinforcementHelper.isReinforcement(mat)) {
reeCount += ReinforcementHelper.getReinforcementValue(mat);
if ((reeCount + currentCount) > ModConfig.confMaxReinforcement) {
maxed = true;
}
} else {
return ItemStack.EMPTY;
}
}
if (reeCount == 0) {
return ItemStack.EMPTY;
}
ReinforcementHelper.reinforce(tool, reeCount);
return tool;
}
use of net.minecraft.item.ItemSword in project PickleTweaks by BlakeBr0.
the class FeatureSwordInfo method onEntityKilled.
@SubscribeEvent
public void onEntityKilled(LivingDeathEvent event) {
if (!ModConfig.confSwordInfoTooltip) {
return;
}
DamageSource source = event.getSource();
Entity entity = source.getTrueSource();
if (entity != null && entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
ItemStack stack = player.getHeldItemMainhand();
if (!stack.isEmpty() && stack.getItem() instanceof ItemSword) {
NBTTagCompound tag = stack.getOrCreateSubCompound(PickleTweaks.MOD_ID);
tag.setInteger("EnemiesKilled", tag.getInteger("EnemiesKilled") + 1);
}
}
}
use of net.minecraft.item.ItemSword in project BapeClient by BapeDeveloperTeam.
the class Killaura method onTick.
@SubscribeEvent
public void onTick(TickEvent.PlayerTickEvent event) {
float delays = new Random().nextInt(this.cps.getValue().intValue()) + 5;
if (timer.delay(delays * 10)) {
if (Client.nullCheck())
return;
for (Entity object : getEntityList()) {
EntityLivingBase entity;
if (!(object instanceof EntityLivingBase) || !this.check(entity = (EntityLivingBase) object))
continue;
target = entity;
}
if (target == null)
return;
if (AntiBot.isServerBot(target))
return;
if (Teams.isOnSameTeam(target))
return;
// return;
if (target.getHealth() == 0)
return;
assistFaceEntity(target, this.yaw.getValue().floatValue(), this.pitch.getValue().floatValue());
Object[] objects = mc.theWorld.loadedEntityList.stream().filter(entity -> entity instanceof EntityLivingBase && entity != mc.thePlayer && ((EntityLivingBase) entity).getHealth() > 0F && entity.getDistanceToEntity(mc.thePlayer) <= rangeValue.getValue()).sorted(Comparator.comparingDouble(entity -> entity.getDistanceToEntity(mc.thePlayer))).toArray();
if (objects.length > 0)
target = (EntityLivingBase) objects[0];
if (ModuleManager.getModule("Criticals").getState() && Criticals.canJump() && mc.thePlayer.onGround)
mc.thePlayer.jump();
if (this.swing.getValue()) {
mc.thePlayer.swingItem();
}
if (!target.isDead || target.getHealth() <= 0) {
mc.getNetHandler().addToSendQueue(new C02PacketUseEntity(target, C02PacketUseEntity.Action.ATTACK));
}
if ((Boolean) this.autoblock.getValue()) {
if (mc.thePlayer.getCurrentEquippedItem() == null) {
return;
}
if (!(mc.thePlayer.getCurrentEquippedItem().getItem() instanceof ItemSword)) {
return;
}
if (this.autoblock.getValue() && mc.objectMouseOver.entityHit != null && mc.objectMouseOver.entityHit.isEntityAlive()) {
if (mc.thePlayer.getCurrentEquippedItem().getItem() instanceof ItemSword && timer.delay(100)) {
mc.thePlayer.getCurrentEquippedItem().useItemRightClick(mc.theWorld, mc.thePlayer);
timer.reset();
}
}
}
target = null;
timer.reset();
}
}
Aggregations