Fix sounds

This commit is contained in:
modmuss50 2016-05-08 11:42:59 +01:00
parent 9c6e9aef64
commit caaa5a3e7f
6 changed files with 36 additions and 26 deletions

View file

@ -16,11 +16,13 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import reborncore.RebornCore;
import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.init.ModSounds;
import techreborn.items.ItemParts;
import techreborn.items.tools.ItemTreeTap;
@ -173,9 +175,9 @@ public class BlockRubberLog extends Block implements ITexturedBlock
{
worldIn.setBlockState(pos,
state.withProperty(HAS_SAP, false).withProperty(SAP_SIDE, EnumFacing.getHorizontal(0)));
// TODO 1.9 sounds
// worldIn.playSoundAtEntity(playerIn,
// "techreborn:sap_extract", 0.8F, 1F);
worldIn.playSound(null, pos.getX(), pos.getY(),
pos.getZ(), ModSounds.extract,
SoundCategory.BLOCKS, 0.6F, 1F);
if (!worldIn.isRemote)
{
Random rand = new Random();

View file

@ -2,6 +2,7 @@ package techreborn.init;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
/**
* Created by Mark on 20/03/2016.
@ -10,16 +11,20 @@ public class ModSounds
{
public static SoundEvent shock;
public static SoundEvent dismantle;
public static SoundEvent extract;
public static void init()
{
shock = getSound("cable_shock");
dismantle = getSound("block_dismantle");
extract = getSound("sap_extract");
}
private static SoundEvent getSound(String str)
{
SoundEvent soundEvent = SoundEvent.REGISTRY.getObject(new ResourceLocation("techreborn" + str));
return soundEvent;
ResourceLocation resourceLocation = new ResourceLocation("techreborn" , str);
return GameRegistry.register(new SoundEvent(resourceLocation).setRegistryName(resourceLocation));
}
}

View file

@ -5,8 +5,15 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import techreborn.init.ModSounds;
import techreborn.items.ItemTR;
import techreborn.lib.ModInfo;
@ -20,14 +27,13 @@ public class ItemHammer extends ItemTR implements ITexturedItem
setMaxDamage(MaxDamage);
}
// @Override
// public boolean onItemUse(ItemStack stack, EntityPlayer player, World
// world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
// {
// world.playSoundAtEntity(player, "techreborn:block_dismantle", 0.8F,
// 0.4F);
// return true;
// }
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
world.playSound(player, player.posX, player.posY,
player.posZ, ModSounds.dismantle,
SoundCategory.BLOCKS, 0.6F, 1F);
return EnumActionResult.SUCCESS;
}
@Override
public Item setUnlocalizedName(String par1Str)

View file

@ -16,6 +16,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
@ -24,6 +25,7 @@ import reborncore.common.tile.TileMachineBase;
import techreborn.blocks.fluid.BlockFluidBase;
import techreborn.blocks.storage.BlockBatBox;
import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.init.ModSounds;
import techreborn.items.ItemTR;
import techreborn.lib.ModInfo;
import techreborn.tiles.storage.TileEnergyStorage;
@ -152,10 +154,9 @@ public class ItemWrench extends ItemTR implements ITexturedItem
}
}
}
// TODO 1.9 sounds
// world.playSoundAtEntity(player, "techreborn:block_dismantle",
// 0.8F, 1F);
world.playSound(null, player.posX, player.posY,
player.posZ, ModSounds.dismantle,
SoundCategory.BLOCKS, 0.6F, 1F);
if (!world.isRemote)
{
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2);

View file

@ -30,6 +30,7 @@ import reborncore.common.misc.Functions;
import reborncore.common.misc.vecmath.Vecs3dCube;
import reborncore.common.util.WorldUtils;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModSounds;
import techreborn.parts.walia.IPartWaliaProvider;
import techreborn.power.TRPowerNet;
import techreborn.utils.damageSources.ElectrialShockSource;
@ -305,9 +306,6 @@ public abstract class CableMultipart extends Multipart
@Override
public void onEntityCollided(Entity entity) {
if (getCableType().canKill && entity instanceof EntityLivingBase) {
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode) {
} else {
if (network != null) {
if (network.getEnergy() != 0) {
if (ConfigTechReborn.UninsulatedElectocutionDamage) {
@ -318,9 +316,9 @@ public abstract class CableMultipart extends Multipart
entity.attackEntityFrom(new ElectrialShockSource(), 1F);
}
if (ConfigTechReborn.UninsulatedElectocutionSound) {
// getWorld().playSound(entity.posX, entity.posY,
// entity.posZ, ModSounds.shock,
// SoundCategory.BLOCKS, 0.6F, 1F, false);
getWorld().playSound(null, entity.posX, entity.posY,
entity.posZ, ModSounds.shock,
SoundCategory.BLOCKS, 0.6F, 1F);
}
if (ConfigTechReborn.UninsulatedElectocutionParticle) {
getWorld().spawnParticle(EnumParticleTypes.CRIT, entity.posX, entity.posY, entity.posZ, 0,
@ -328,7 +326,6 @@ public abstract class CableMultipart extends Multipart
}
}
}
}
}
}

View file

@ -28,6 +28,7 @@ import techreborn.client.hud.ChargeHud;
import techreborn.client.keybindings.KeyBindings;
import techreborn.client.render.entitys.RenderNukePrimed;
import techreborn.entitys.EntityNukePrimed;
import techreborn.init.ModSounds;
import techreborn.manual.loader.ManualLoader;
import java.io.File;
@ -77,8 +78,6 @@ public class ClientProxy extends CommonProxy
// TODO FIX ME
ClientRegistry.registerKeyBinding(KeyBindings.config);
ClientMultiBlocks.init();
}
protected void registerItemModel(ItemStack item, String name) {