Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/main/java/gregtech/api/block/IStateSoundType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package gregtech.api.block;

import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;

import org.jetbrains.annotations.NotNull;

public interface IStateSoundType {

@NotNull
SoundType getSoundType(@NotNull IBlockState state);
}
13 changes: 13 additions & 0 deletions src/main/java/gregtech/api/block/VariantBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
Expand Down Expand Up @@ -112,6 +115,16 @@ public int getMetaFromState(IBlockState state) {
return state.getValue(VARIANT).ordinal();
}

@NotNull
@Override
public SoundType getSoundType(@NotNull IBlockState state, @NotNull World world, @NotNull BlockPos pos,
@Nullable Entity entity) {
if (getState(state) instanceof IStateSoundType stateSoundType) {
return stateSoundType.getSoundType(state);
}
return super.getSoundType(state, world, pos, entity);
}

// magic is here
@SuppressWarnings("unchecked")
protected static <T, R> Class<T> getActualTypeParameter(Class<? extends R> thisClass, Class<R> declaringClass) {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/gregtech/api/block/machines/BlockMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -590,4 +590,13 @@ public void randomDisplayTick(@NotNull IBlockState stateIn, @NotNull World world
MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos);
if (metaTileEntity != null) metaTileEntity.randomDisplayTick();
}

@NotNull
@Override
public SoundType getSoundType(@NotNull IBlockState state, @NotNull World world, @NotNull BlockPos pos,
@Nullable Entity entity) {
MetaTileEntity metaTileEntity = getMetaTileEntity(world, pos);
if (metaTileEntity == null) return getSoundType();
return metaTileEntity.getSoundType();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import gregtech.common.items.MetaItems;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
Expand Down Expand Up @@ -908,6 +909,14 @@ private void updateSound() {
}
}

/**
* @return The sound type used when this block is broken, placed, stepped on, hit, or fallen on.
*/
@NotNull
public SoundType getSoundType() {
return SoundType.METAL;
}

public final @NotNull ItemStack getStackForm(int amount) {
int metaTileEntityIntId = registry.getIdByObjectName(metaTileEntityId);
return new ItemStack(registry.getBlock(), amount, metaTileEntityIntId);
Expand Down
21 changes: 17 additions & 4 deletions src/main/java/gregtech/common/blocks/BlockMetalCasing.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gregtech.common.blocks;

import gregtech.api.block.IStateHarvestLevel;
import gregtech.api.block.IStateSoundType;
import gregtech.api.block.VariantBlock;
import gregtech.api.items.toolitem.ToolClasses;

Expand Down Expand Up @@ -31,27 +32,33 @@ public boolean canCreatureSpawn(@NotNull IBlockState state, @NotNull IBlockAcces
return false;
}

public enum MetalCasingType implements IStringSerializable, IStateHarvestLevel {
public enum MetalCasingType implements IStringSerializable, IStateHarvestLevel, IStateSoundType {

BRONZE_BRICKS("bronze_bricks", 1),
PRIMITIVE_BRICKS("primitive_bricks", 1),
PRIMITIVE_BRICKS("primitive_bricks", 1, SoundType.STONE),
INVAR_HEATPROOF("invar_heatproof", 1),
ALUMINIUM_FROSTPROOF("aluminium_frostproof", 1),
STEEL_SOLID("steel_solid", 2),
STAINLESS_CLEAN("stainless_clean", 2),
TITANIUM_STABLE("titanium_stable", 2),
TUNGSTENSTEEL_ROBUST("tungstensteel_robust", 3),
COKE_BRICKS("coke_bricks", 1),
COKE_BRICKS("coke_bricks", 1, SoundType.STONE),
PTFE_INERT_CASING("ptfe_inert", 0),
HSSE_STURDY("hsse_sturdy", 3),
PALLADIUM_SUBSTATION("palladium_substation", 3);

private final String name;
private final int harvestLevel;
private final SoundType soundType;

MetalCasingType(String name, int harvestLevel) {
MetalCasingType(String name, int harvestLevel, SoundType soundType) {
this.name = name;
this.harvestLevel = harvestLevel;
this.soundType = soundType;
}

MetalCasingType(String name, int harvestLevel) {
this(name, harvestLevel, SoundType.METAL);
}

@NotNull
Expand All @@ -69,5 +76,11 @@ public int getHarvestLevel(IBlockState state) {
public String getHarvestTool(IBlockState state) {
return ToolClasses.WRENCH;
}

@NotNull
@Override
public SoundType getSoundType(@NotNull IBlockState state) {
return soundType;
}
}
}
21 changes: 17 additions & 4 deletions src/main/java/gregtech/common/blocks/BlockSteamCasing.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gregtech.common.blocks;

import gregtech.api.block.IStateHarvestLevel;
import gregtech.api.block.IStateSoundType;
import gregtech.api.block.VariantBlock;
import gregtech.api.items.toolitem.ToolClasses;

Expand Down Expand Up @@ -51,21 +52,27 @@ public void addInformation(@NotNull ItemStack stack, @Nullable World player, @No
}
}

public enum SteamCasingType implements IStringSerializable, IStateHarvestLevel {
public enum SteamCasingType implements IStringSerializable, IStateHarvestLevel, IStateSoundType {

BRONZE_HULL("bronze_hull", 1),
BRONZE_BRICKS_HULL("bronze_bricks_hull", 1),
STEEL_HULL("steel_hull", 2),
STEEL_BRICKS_HULL("steel_bricks_hull", 2),
PUMP_DECK("pump_deck", 1),
WOOD_WALL("wood_wall", 0);
PUMP_DECK("pump_deck", 1, SoundType.WOOD),
WOOD_WALL("wood_wall", 0, SoundType.WOOD);

private final String name;
private final int harvestLevel;
private final SoundType soundType;

SteamCasingType(String name, int harvestLevel) {
SteamCasingType(String name, int harvestLevel, SoundType soundType) {
this.name = name;
this.harvestLevel = harvestLevel;
this.soundType = soundType;
}

SteamCasingType(String name, int harvestLevel) {
this(name, harvestLevel, SoundType.METAL);
}

@Override
Expand All @@ -83,5 +90,11 @@ public int getHarvestLevel(IBlockState state) {
public String getHarvestTool(IBlockState state) {
return ToolClasses.WRENCH;
}

@NotNull
@Override
public SoundType getSoundType(@NotNull IBlockState state) {
return soundType;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import gregtech.core.network.packets.PacketClipboardNBTUpdate;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.creativetab.CreativeTabs;
Expand Down Expand Up @@ -548,4 +549,10 @@ public boolean showToolUsages() {
public ItemStack getPickItem(EntityPlayer player) {
return this.getClipboard();
}

@NotNull
@Override
public SoundType getSoundType() {
return SoundType.WOOD;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import gregtech.common.metatileentities.MetaTileEntities;
import gregtech.common.mui.widget.GTFluidSlot;

import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
Expand Down Expand Up @@ -168,4 +169,10 @@ public boolean onRightClick(EntityPlayer playerIn, EnumHand hand, EnumFacing fac
}
return super.onRightClick(playerIn, hand, facing, hitResult);
}

@NotNull
@Override
public SoundType getSoundType() {
return SoundType.STONE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import gregtech.client.renderer.texture.Textures;
import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMultiblockPart;

import net.minecraft.block.SoundType;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
Expand All @@ -30,6 +31,7 @@
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.pipeline.IVertexOperation;
import codechicken.lib.vec.Matrix4;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
Expand Down Expand Up @@ -127,4 +129,10 @@ public boolean onRightClick(EntityPlayer playerIn, EnumHand hand, EnumFacing fac
}
return super.onRightClick(playerIn, hand, facing, hitResult);
}

@NotNull
@Override
public SoundType getSoundType() {
return SoundType.STONE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import gregtech.common.metatileentities.MetaTileEntities;
import gregtech.common.mui.widget.GTFluidSlot;

import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
Expand Down Expand Up @@ -191,4 +192,10 @@ public <T> T getCapability(Capability<T> capability, EnumFacing side) {
}
return super.getCapability(capability, side);
}

@NotNull
@Override
public SoundType getSoundType() {
return this.isMetal ? SoundType.METAL : SoundType.WOOD;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import gregtech.common.blocks.BlockMetalCasing;
import gregtech.common.blocks.MetaBlocks;

import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.SoundEvents;
Expand Down Expand Up @@ -209,4 +210,10 @@ public void randomDisplayTick() {
}
}
}

@NotNull
@Override
public SoundType getSoundType() {
return SoundType.STONE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import gregtech.common.blocks.MetaBlocks;
import gregtech.common.metatileentities.MetaTileEntities;

import net.minecraft.block.SoundType;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
Expand Down Expand Up @@ -191,4 +192,10 @@ public int getFluidProduction() {
public boolean allowsExtendedFacing() {
return false;
}

@NotNull
@Override
public SoundType getSoundType() {
return SoundType.WOOD;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import gregtech.common.metatileentities.storage.MetaTileEntityQuantumTank;
import gregtech.common.mui.widget.GTFluidSlot;

import net.minecraft.block.SoundType;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
Expand Down Expand Up @@ -191,4 +192,10 @@ public void addToolUsages(ItemStack stack, @Nullable World world, List<String> t
public int getDefaultPaintingColor() {
return 0xFFFFFF;
}

@NotNull
@Override
public SoundType getSoundType() {
return SoundType.WOOD;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import gregtech.client.renderer.texture.Textures;
import gregtech.common.metatileentities.multi.multiblockpart.MetaTileEntityMultiblockPart;

import net.minecraft.block.SoundType;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
Expand Down Expand Up @@ -150,4 +151,10 @@ public void addToolUsages(ItemStack stack, @Nullable World world, List<String> t
tooltip.add(I18n.format("gregtech.tool_action.wrench.set_facing"));
super.addToolUsages(stack, world, tooltip, advanced);
}

@NotNull
@Override
public SoundType getSoundType() {
return this.isMetal ? SoundType.METAL : SoundType.WOOD;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import gregtech.client.renderer.texture.Textures;
import gregtech.common.items.MetaItems;

import net.minecraft.block.SoundType;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
Expand Down Expand Up @@ -279,4 +280,10 @@ public void addToolUsages(ItemStack stack, @Nullable World world, List<String> t
tooltip.add(I18n.format("gregtech.tool_action.screwdriver.access_covers"));
super.addToolUsages(stack, world, tooltip, advanced);
}

@NotNull
@Override
public SoundType getSoundType() {
return ModHandler.isMaterialWood(material) ? SoundType.WOOD : SoundType.METAL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import gregtech.client.renderer.texture.Textures;
import gregtech.client.utils.TooltipHelper;

import net.minecraft.block.SoundType;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
Expand Down Expand Up @@ -315,4 +316,10 @@ public void readFromNBT(NBTTagCompound data) {
protected boolean shouldSerializeInventories() {
return false;
}

@NotNull
@Override
public SoundType getSoundType() {
return this.isWood ? SoundType.WOOD : SoundType.METAL;
}
}
Loading
Loading