Fix issue with chainsaw cutting speed. Closes #1376
This commit is contained in:
parent
b9084d620e
commit
05884b2fda
5 changed files with 19 additions and 14 deletions
|
@ -92,10 +92,10 @@ public class BlockBreakHandler {
|
|||
|
||||
@SubscribeEvent
|
||||
public void getBreakSpeedEvent(PlayerEvent.BreakSpeed event){
|
||||
if(event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.ADVANCED_CHAINSAW){
|
||||
if(event.getEntityPlayer().getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.ADVANCED_CHAINSAW && event.getOriginalSpeed() > 1.0f){
|
||||
BlockPos pos = event.getPos();
|
||||
World worldIn = event.getEntityPlayer().world;
|
||||
float speed = 2F;
|
||||
float speed = 20F;
|
||||
int blocks = 0;
|
||||
for (int i = 1; i < 10; i++) {
|
||||
BlockPos nextPos = pos.up(i);
|
||||
|
@ -104,7 +104,7 @@ public class BlockBreakHandler {
|
|||
blocks ++;
|
||||
}
|
||||
}
|
||||
event.setNewSpeed(speed * blocks);
|
||||
event.setNewSpeed(speed / blocks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class ItemAdvancedChainsaw extends ItemChainsaw {
|
|||
|
||||
public ItemAdvancedChainsaw() {
|
||||
super(ToolMaterial.DIAMOND, "techreborn.advancedChainsaw", ConfigTechReborn.AdvancedChainsawCharge,
|
||||
4.0F);
|
||||
1.0F);
|
||||
this.cost = 250;
|
||||
}
|
||||
|
||||
|
@ -81,11 +81,6 @@ public class ItemAdvancedChainsaw extends ItemChainsaw {
|
|||
return super.onBlockDestroyed(stack, worldIn, blockIn, pos, entityLiving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, IBlockState state) {
|
||||
return super.getDestroySpeed(stack, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(IBlockState blockIn) {
|
||||
return Items.DIAMOND_AXE.canHarvestBlock(blockIn);
|
||||
|
|
|
@ -53,6 +53,7 @@ public class ItemChainsaw extends ItemAxe implements IEnergyItemInfo, IEnergyInt
|
|||
|
||||
public int maxCharge = 1;
|
||||
public int cost = 250;
|
||||
public float poweredSpeed = 20F;
|
||||
public float unpoweredSpeed = 2.0F;
|
||||
public double transferLimit = 100;
|
||||
public boolean isBreaking = false;
|
||||
|
@ -60,12 +61,11 @@ public class ItemChainsaw extends ItemAxe implements IEnergyItemInfo, IEnergyInt
|
|||
public ItemChainsaw(ToolMaterial material, String unlocalizedName, int energyCapacity,
|
||||
float unpoweredSpeed) {
|
||||
super(material);
|
||||
efficiency = 20F;
|
||||
setCreativeTab(TechRebornCreativeTab.instance);
|
||||
setMaxStackSize(1);
|
||||
setUnlocalizedName(unlocalizedName);
|
||||
this.maxCharge = energyCapacity;
|
||||
this.unpoweredSpeed = unpoweredSpeed;
|
||||
this.efficiency = unpoweredSpeed;
|
||||
|
||||
this.addPropertyOverride(new ResourceLocation("techreborn:animated"), new IItemPropertyGetter() {
|
||||
@Override
|
||||
|
@ -83,6 +83,16 @@ public class ItemChainsaw extends ItemAxe implements IEnergyItemInfo, IEnergyInt
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDestroySpeed(ItemStack stack, IBlockState state) {
|
||||
if (PoweredItem.canUseEnergy(cost, stack) && state.getBlock().isToolEffective("axe", state)) {
|
||||
return this.poweredSpeed;
|
||||
}
|
||||
else {
|
||||
return super.getDestroySpeed(stack, state);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState blockIn, BlockPos pos,
|
||||
EntityLivingBase entityLiving) {
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ItemDiamondChainsaw extends ItemChainsaw {
|
|||
|
||||
public ItemDiamondChainsaw() {
|
||||
super(ToolMaterial.DIAMOND, "techreborn.diamondChainsaw", ConfigTechReborn.DiamondChainsawCharge,
|
||||
2.5F);
|
||||
1.0F);
|
||||
this.cost = 250;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ItemSteelChainsaw extends ItemChainsaw {
|
|||
|
||||
public ItemSteelChainsaw() {
|
||||
super(ToolMaterial.IRON, "techreborn.ironChainsaw", ConfigTechReborn.IronChainsawCharge,
|
||||
2.0F);
|
||||
0.5F);
|
||||
this.cost = 50;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue