mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
fix inventory switching sounds when using a placer or the drill
This commit is contained in:
parent
df81083ca7
commit
c98b5cf85f
2 changed files with 14 additions and 5 deletions
|
@ -106,14 +106,14 @@ public class ItemDrill extends ItemEnergy{
|
||||||
if(StackUtil.isValid(equip) && equip != stack){
|
if(StackUtil.isValid(equip) && equip != stack){
|
||||||
ItemStack toPlaceStack = equip.copy();
|
ItemStack toPlaceStack = equip.copy();
|
||||||
|
|
||||||
player.setHeldItem(hand, toPlaceStack);
|
WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack);
|
||||||
|
|
||||||
//tryPlaceItemIntoWorld could throw an Exception
|
//tryPlaceItemIntoWorld could throw an Exception
|
||||||
try{
|
try{
|
||||||
//Places the Block into the World
|
//Places the Block into the World
|
||||||
if(toPlaceStack.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) != EnumActionResult.FAIL){
|
if(toPlaceStack.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) != EnumActionResult.FAIL){
|
||||||
if(!player.capabilities.isCreativeMode){
|
if(!player.capabilities.isCreativeMode){
|
||||||
player.setHeldItem(hand, StackUtil.validateCopy(toPlaceStack));
|
WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, StackUtil.validateCopy(toPlaceStack));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public class ItemDrill extends ItemEnergy{
|
||||||
}
|
}
|
||||||
|
|
||||||
player.inventory.setInventorySlotContents(slot, player.getHeldItem(hand));
|
player.inventory.setInventorySlotContents(slot, player.getHeldItem(hand));
|
||||||
player.setHeldItem(hand, stack);
|
WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, stack);
|
||||||
|
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,12 +242,12 @@ public final class WorldUtil{
|
||||||
if(world instanceof WorldServer){
|
if(world instanceof WorldServer){
|
||||||
FakePlayer fake = FakePlayerFactory.getMinecraft((WorldServer)world);
|
FakePlayer fake = FakePlayerFactory.getMinecraft((WorldServer)world);
|
||||||
ItemStack heldBefore = fake.getHeldItemMainhand();
|
ItemStack heldBefore = fake.getHeldItemMainhand();
|
||||||
fake.setHeldItem(EnumHand.MAIN_HAND, stack.copy());
|
setHandItemWithoutAnnoyingSound(fake, EnumHand.MAIN_HAND, stack.copy());
|
||||||
|
|
||||||
fake.getHeldItemMainhand().onItemUse(fake, world, offsetPos, fake.getActiveHand(), side.getOpposite(), 0.5F, 0.5F, 0.5F);
|
fake.getHeldItemMainhand().onItemUse(fake, world, offsetPos, fake.getActiveHand(), side.getOpposite(), 0.5F, 0.5F, 0.5F);
|
||||||
|
|
||||||
ItemStack result = fake.getHeldItem(EnumHand.MAIN_HAND);
|
ItemStack result = fake.getHeldItem(EnumHand.MAIN_HAND);
|
||||||
fake.setHeldItem(EnumHand.MAIN_HAND, heldBefore);
|
setHandItemWithoutAnnoyingSound(fake, EnumHand.MAIN_HAND, heldBefore);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -469,4 +469,13 @@ public final class WorldUtil{
|
||||||
}
|
}
|
||||||
return 0F;
|
return 0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setHandItemWithoutAnnoyingSound(EntityPlayer player, EnumHand hand, ItemStack stack){
|
||||||
|
if(hand == EnumHand.MAIN_HAND){
|
||||||
|
player.inventory.mainInventory.set(player.inventory.currentItem, stack);
|
||||||
|
}
|
||||||
|
else if(hand == EnumHand.OFF_HAND){
|
||||||
|
player.inventory.offHandInventory.set(0, stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue