use of net.minecraft.item.AxeItem in project friends-and-foes by Faboslav.
the class CopperGolemEntity method interactMob.
@Override
public ActionResult interactMob(PlayerEntity player, Hand hand) {
ItemStack itemStack = player.getStackInHand(hand);
Item itemInHand = itemStack.getItem();
boolean interactionResult = false;
if (itemInHand == Items.COPPER_INGOT) {
interactionResult = this.tryToInteractMobWithCopperIngot(player, itemStack);
} else if (itemInHand == Items.HONEYCOMB) {
interactionResult = this.tryToInteractMobWithHoneycomb(player, itemStack);
} else if (itemInHand instanceof AxeItem) {
interactionResult = this.tryToInteractMobWithAxe(player, hand, itemStack);
}
if (interactionResult) {
this.emitGameEvent(GameEvent.MOB_INTERACT, this.getCameraBlockPos());
return ActionResult.success(this.world.isClient);
}
return super.interactMob(player, hand);
}
use of net.minecraft.item.AxeItem in project Moonfix by Kingdom-of-Moon.
the class ClientPlayerInteractionManagerMixin method interactBlock.
// makes log strips and grass path actions be ignored unless if player is pressing sneak
@Inject(at = @At("HEAD"), method = "interactBlock", cancellable = true)
private void interactBlock(ClientPlayerEntity player, ClientWorld world, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
if (player.isSneaking())
return;
Item item = player.getStackInHand(hand).getItem();
BlockState block = world.getBlockState(hitResult.getBlockPos());
boolean path = (boolean) ConfigManager.Config.DIRT_PATH.value && item instanceof ShovelItem && ShovelItemAccessor.getPathStates().containsKey(block.getBlock());
boolean stripped = (boolean) ConfigManager.Config.STRIPPED_LOGS.value && item instanceof AxeItem && AxeItemAccessor.getStrippedBlocks().containsKey(block.getBlock());
if (path || stripped) {
cir.setReturnValue(ActionResult.PASS);
cir.cancel();
}
}
use of net.minecraft.item.AxeItem in project LevelZ by Globox1997.
the class LevelzGui method getDamageLabel.
private String getDamageLabel(PlayerStatsManager playerStatsManager, PlayerEntity playerEntity) {
float damage = 0.0F;
boolean isSword = false;
Item item = playerEntity.getMainHandStack().getItem();
if (item instanceof ToolItem) {
ArrayList<Object> levelList = new ArrayList<Object>();
if (item instanceof SwordItem) {
levelList = LevelLists.swordList;
isSword = true;
} else if (item instanceof AxeItem)
levelList = LevelLists.axeList;
else if (item instanceof HoeItem)
levelList = LevelLists.hoeList;
else
levelList = LevelLists.toolList;
if (PlayerStatsManager.playerLevelisHighEnough(playerEntity, levelList, ((ToolItem) item).getMaterial().toString().toLowerCase(), false)) {
if (isSword)
damage = ((SwordItem) item).getAttackDamage();
else if (item instanceof MiningToolItem)
damage = ((MiningToolItem) item).getAttackDamage();
}
}
damage += playerEntity.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE);
return "" + BigDecimal.valueOf(damage).setScale(2, RoundingMode.HALF_DOWN).floatValue();
}
use of net.minecraft.item.AxeItem in project ChocolateQuestRepoured by TeamChocoQuest.
the class AbstractEntityCQR method hurt.
public boolean hurt(DamageSource source, float amount, boolean sentFromPart) {
// Start IceAndFire compatibility
if (CQRConfig.advanced.enableSpecialFeatures && source.getEntity() != null) {
ResourceLocation resLoc = EntityList.getKey(source.getEntity());
if (resLoc != null && resLoc.getNamespace().equalsIgnoreCase("iceandfire")) {
amount *= 0.5F;
}
}
// End IceAndFire compatibility
// Shoulder entity stuff
this.spawnShoulderEntities();
if (this.level.getLevelData().isHardcore()) {
amount *= 0.7F;
} else {
Difficulty difficulty = this.level.getDifficulty();
if (difficulty == Difficulty.HARD) {
amount *= 0.8F;
} else if (difficulty == Difficulty.NORMAL) {
amount *= 0.9F;
}
}
// End of shoulder entity stuff
amount = this.handleDamageCap(source, amount);
if (!this.level.isClientSide && amount > 0.0F && this.canBlockDamageSource(source)) {
if (source.getDirectEntity() instanceof LivingEntity && !(source.getDirectEntity() instanceof PlayerEntity) && ((LivingEntity) source.getDirectEntity()).getMainHandItem().getItem() instanceof AxeItem) {
this.lastTickShieldDisabled = this.tickCount;
} else {
this.damageBlockedWithShield += amount;
if (this.damageBlockedWithShield >= CQRConfig.general.damageBlockedByShield) {
this.damageBlockedWithShield = 0.0F;
this.lastTickShieldDisabled = this.tickCount;
}
}
}
boolean flag = super.hurt(source, amount);
if (flag && CQRConfig.mobs.armorShattersOnMobs) {
this.handleArmorBreaking();
}
return flag;
}
use of net.minecraft.item.AxeItem in project Architects-Palette-Fabric by Slomaxonical-907.
the class TotemBlock method onUse.
@Override
public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockHitResult hit) {
ItemStack playerItem = player.getStackInHand(handIn);
if (playerItem.getItem() instanceof AxeItem) {
BlockState newState = this.totemType.getStrip().getDefaultState().with(FACING, state.get(FACING));
worldIn.setBlockState(pos, newState, 3);
playerItem.damage(1, player, (p) -> p.sendToolBreakStatus(handIn));
worldIn.playSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1, 1);
/* if (player instanceof ServerPlayerEntity) {
APCriterion.CARVE_TOTEM.trigger((ServerPlayerEntity) player);
}*/
return ActionResult.success(worldIn.isClient);
}
return ActionResult.FAIL;
}
Aggregations