Skip to content

Commit 8f9e7b9

Browse files
committed
feat: allow giving mtes custom soundtypes
1 parent 92acc6a commit 8f9e7b9

13 files changed

+96
-0
lines changed

src/main/java/gregtech/api/block/machines/BlockMachine.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,4 +590,13 @@ public void randomDisplayTick(@NotNull IBlockState stateIn, @NotNull World world
590590
MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos);
591591
if (metaTileEntity != null) metaTileEntity.randomDisplayTick();
592592
}
593+
594+
@NotNull
595+
@Override
596+
public SoundType getSoundType(@NotNull IBlockState state, @NotNull World world, @NotNull BlockPos pos,
597+
@Nullable Entity entity) {
598+
MetaTileEntity metaTileEntity = getMetaTileEntity(world, pos);
599+
if (metaTileEntity == null) return getSoundType();
600+
return metaTileEntity.getSoundType();
601+
}
593602
}

src/main/java/gregtech/api/metatileentity/MetaTileEntity.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import gregtech.common.items.MetaItems;
4242

4343
import net.minecraft.block.Block;
44+
import net.minecraft.block.SoundType;
4445
import net.minecraft.block.state.BlockFaceShape;
4546
import net.minecraft.block.state.IBlockState;
4647
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -908,6 +909,14 @@ private void updateSound() {
908909
}
909910
}
910911

912+
/**
913+
* @return The sound type used when this block is broken, placed, stepped on, hit, or fallen on.
914+
*/
915+
@NotNull
916+
public SoundType getSoundType() {
917+
return SoundType.METAL;
918+
}
919+
911920
public final @NotNull ItemStack getStackForm(int amount) {
912921
int metaTileEntityIntId = registry.getIdByObjectName(metaTileEntityId);
913922
return new ItemStack(registry.getBlock(), amount, metaTileEntityIntId);

src/main/java/gregtech/common/metatileentities/MetaTileEntityClipboard.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import gregtech.core.network.packets.PacketClipboardNBTUpdate;
2222

2323
import net.minecraft.block.Block;
24+
import net.minecraft.block.SoundType;
2425
import net.minecraft.block.state.IBlockState;
2526
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
2627
import net.minecraft.creativetab.CreativeTabs;
@@ -548,4 +549,10 @@ public boolean showToolUsages() {
548549
public ItemStack getPickItem(EntityPlayer player) {
549550
return this.getClipboard();
550551
}
552+
553+
@NotNull
554+
@Override
555+
public SoundType getSoundType() {
556+
return SoundType.WOOD;
557+
}
551558
}

src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityCokeOven.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import gregtech.common.metatileentities.MetaTileEntities;
2222
import gregtech.common.mui.widget.GTFluidSlot;
2323

24+
import net.minecraft.block.SoundType;
2425
import net.minecraft.block.state.IBlockState;
2526
import net.minecraft.entity.player.EntityPlayer;
2627
import net.minecraft.entity.player.EntityPlayerMP;
@@ -168,4 +169,10 @@ public boolean onRightClick(EntityPlayer playerIn, EnumHand hand, EnumFacing fac
168169
}
169170
return super.onRightClick(playerIn, hand, facing, hitResult);
170171
}
172+
173+
@NotNull
174+
@Override
175+
public SoundType getSoundType() {
176+
return SoundType.STONE;
177+
}
171178
}

src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityCokeOvenHatch.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import gregtech.client.renderer.texture.Textures;
1313
import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMultiblockPart;
1414

15+
import net.minecraft.block.SoundType;
1516
import net.minecraft.client.resources.I18n;
1617
import net.minecraft.entity.player.EntityPlayer;
1718
import net.minecraft.item.ItemStack;
@@ -30,6 +31,7 @@
3031
import codechicken.lib.render.CCRenderState;
3132
import codechicken.lib.render.pipeline.IVertexOperation;
3233
import codechicken.lib.vec.Matrix4;
34+
import org.jetbrains.annotations.NotNull;
3335
import org.jetbrains.annotations.Nullable;
3436

3537
import java.util.List;
@@ -127,4 +129,10 @@ public boolean onRightClick(EntityPlayer playerIn, EnumHand hand, EnumFacing fac
127129
}
128130
return super.onRightClick(playerIn, hand, facing, hitResult);
129131
}
132+
133+
@NotNull
134+
@Override
135+
public SoundType getSoundType() {
136+
return SoundType.STONE;
137+
}
130138
}

src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityMultiblockTank.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import gregtech.common.metatileentities.MetaTileEntities;
2121
import gregtech.common.mui.widget.GTFluidSlot;
2222

23+
import net.minecraft.block.SoundType;
2324
import net.minecraft.block.state.IBlockState;
2425
import net.minecraft.client.resources.I18n;
2526
import net.minecraft.entity.player.EntityPlayer;
@@ -191,4 +192,10 @@ public <T> T getCapability(Capability<T> capability, EnumFacing side) {
191192
}
192193
return super.getCapability(capability, side);
193194
}
195+
196+
@NotNull
197+
@Override
198+
public SoundType getSoundType() {
199+
return this.isMetal ? SoundType.METAL : SoundType.WOOD;
200+
}
194201
}

src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityPrimitiveBlastFurnace.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import gregtech.common.blocks.BlockMetalCasing;
2525
import gregtech.common.blocks.MetaBlocks;
2626

27+
import net.minecraft.block.SoundType;
2728
import net.minecraft.block.state.IBlockState;
2829
import net.minecraft.entity.EntityLivingBase;
2930
import net.minecraft.init.SoundEvents;
@@ -209,4 +210,10 @@ public void randomDisplayTick() {
209210
}
210211
}
211212
}
213+
214+
@NotNull
215+
@Override
216+
public SoundType getSoundType() {
217+
return SoundType.STONE;
218+
}
212219
}

src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityPrimitiveWaterPump.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import gregtech.common.blocks.MetaBlocks;
1818
import gregtech.common.metatileentities.MetaTileEntities;
1919

20+
import net.minecraft.block.SoundType;
2021
import net.minecraft.client.resources.I18n;
2122
import net.minecraft.util.ResourceLocation;
2223
import net.minecraft.world.World;
@@ -191,4 +192,10 @@ public int getFluidProduction() {
191192
public boolean allowsExtendedFacing() {
192193
return false;
193194
}
195+
196+
@NotNull
197+
@Override
198+
public SoundType getSoundType() {
199+
return SoundType.WOOD;
200+
}
194201
}

src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityPumpHatch.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import gregtech.common.metatileentities.storage.MetaTileEntityQuantumTank;
1919
import gregtech.common.mui.widget.GTFluidSlot;
2020

21+
import net.minecraft.block.SoundType;
2122
import net.minecraft.client.resources.I18n;
2223
import net.minecraft.item.ItemStack;
2324
import net.minecraft.nbt.NBTTagCompound;
@@ -191,4 +192,10 @@ public void addToolUsages(ItemStack stack, @Nullable World world, List<String> t
191192
public int getDefaultPaintingColor() {
192193
return 0xFFFFFF;
193194
}
195+
196+
@NotNull
197+
@Override
198+
public SoundType getSoundType() {
199+
return SoundType.WOOD;
200+
}
194201
}

src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityTankValve.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import gregtech.client.renderer.texture.Textures;
1414
import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMultiblockPart;
1515

16+
import net.minecraft.block.SoundType;
1617
import net.minecraft.client.resources.I18n;
1718
import net.minecraft.item.ItemStack;
1819
import net.minecraft.tileentity.TileEntity;
@@ -150,4 +151,10 @@ public void addToolUsages(ItemStack stack, @Nullable World world, List<String> t
150151
tooltip.add(I18n.format("gregtech.tool_action.wrench.set_facing"));
151152
super.addToolUsages(stack, world, tooltip, advanced);
152153
}
154+
155+
@NotNull
156+
@Override
157+
public SoundType getSoundType() {
158+
return this.isMetal ? SoundType.METAL : SoundType.WOOD;
159+
}
153160
}

0 commit comments

Comments
 (0)