Skip to content

Commit

Permalink
Wrench rotation sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu committed Nov 26, 2021
1 parent 7c72156 commit f0f8014
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/main/java/gregtech/api/block/machines/BlockMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import gregtech.api.cover.CoverBehavior;
import gregtech.api.cover.ICoverable;
import gregtech.api.cover.IFacadeCover;
import gregtech.api.items.metaitem.MetaItem;
import gregtech.api.items.toolitem.IToolStats;
import gregtech.api.items.toolitem.ToolMetaItem;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.MetaTileEntityHolder;
import gregtech.api.pipenet.block.BlockPipe;
Expand Down Expand Up @@ -332,6 +335,11 @@ public boolean onBlockActivated(@Nonnull World worldIn, @Nonnull BlockPos pos, @

if (wrenchItem.damageItem(DamageValues.DAMAGE_FOR_WRENCH, true) &&
metaTileEntity.onWrenchClick(playerIn, hand, wrenchDirection, rayTraceResult)) {

if(itemStack.getItem() instanceof ToolMetaItem<?>) {
IToolStats stats = ((ToolMetaItem<?>) itemStack.getItem()).getItem(itemStack).getToolStats();
stats.onBreakingUse(itemStack);
}
wrenchItem.damageItem(DamageValues.DAMAGE_FOR_WRENCH, false);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ public ModularUI.Builder createUITemplate(EntityPlayer player) {
@Override
public void onAttached() {
super.onAttached();
this.setupSound(workableHandler.recipeMap.getSound(), this.getPos(), this.getWorld());
this.setupSound(workableHandler.getRecipeMap().getSound(), this.getPos(), this.getWorld());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ public boolean isActive() {
@Override
public void onAttached() {
super.onAttached();
this.setupSound(this.workable.recipeMap.getSound(), this.getPos(), this.getWorld());
this.setupSound(this.workable.getRecipeMap().getSound(), this.getPos(), this.getWorld());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected boolean shouldUpdate(MTETrait trait) {
@Override
public void onAttached() {
super.onAttached();
this.setupSound(recipeMapWorkable.recipeMap.getSound(), this.getPos(), this.getWorld());
this.setupSound(recipeMapWorkable.getRecipeMap().getSound(), this.getPos(), this.getWorld());
}

public boolean canCreateSound() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gregtech.common.items.behaviors;

import gregtech.api.items.metaitem.stats.IItemBehaviour;
import gregtech.api.items.toolitem.IToolStats;
import gregtech.api.items.toolitem.ToolMetaItem;
import gregtech.api.metatileentity.MetaTileEntityHolder;
import gregtech.api.util.GTUtility;
import net.minecraft.client.resources.I18n;
Expand All @@ -27,7 +29,9 @@ public WrenchBehaviour(int cost) {
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
if (!world.isRemote && !world.isAirBlock(pos)) {
ItemStack stack = player.getHeldItem(hand);

TileEntity tileEntity = world.getTileEntity(pos);

if (tileEntity instanceof MetaTileEntityHolder)
//machines handle wrench click manually
return EnumActionResult.PASS;
Expand Down

0 comments on commit f0f8014

Please sign in to comment.