Added sounds to the Conveyor Belts
This commit is contained in:
parent
bf9f9d2392
commit
cac04ed7e4
5 changed files with 42 additions and 2 deletions
|
@ -5,6 +5,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import assemblyline.client.gui.GuiEncoder;
|
||||
import assemblyline.client.gui.GuiImprinter;
|
||||
import assemblyline.client.render.BlockRenderingHandler;
|
||||
|
@ -14,6 +15,7 @@ import assemblyline.client.render.RenderCrate;
|
|||
import assemblyline.client.render.RenderDetector;
|
||||
import assemblyline.client.render.RenderManipulator;
|
||||
import assemblyline.client.render.RenderRejector;
|
||||
import assemblyline.client.sound.SoundManager;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.CommonProxy;
|
||||
import assemblyline.common.block.TileEntityCrate;
|
||||
|
@ -36,6 +38,7 @@ public class ClientProxy extends CommonProxy
|
|||
MinecraftForgeClient.preloadTexture(AssemblyLine.BLOCK_TEXTURE_PATH);
|
||||
MinecraftForgeClient.preloadTexture(AssemblyLine.ITEM_TEXTURE_PATH);
|
||||
RenderingRegistry.registerBlockHandler(new BlockRenderingHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new SoundManager());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
21
src/minecraft/assemblyline/client/sound/SoundManager.java
Normal file
21
src/minecraft/assemblyline/client/sound/SoundManager.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package assemblyline.client.sound;
|
||||
|
||||
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
|
||||
public class SoundManager
|
||||
{
|
||||
@ForgeSubscribe
|
||||
public void onSound(SoundLoadEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
event.manager.soundPoolSounds.addSound("assemblyline/conveyor.wav", getClass().getResource("conveyor.wav"));
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("Failed to register one or more sounds.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import java.util.EnumSet;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
|
|
@ -247,9 +247,20 @@ public class BlockConveyorBelt extends BlockMachine
|
|||
entity.motionX += difference * 0.06;
|
||||
// /entity.posX = x + 0.5;
|
||||
}
|
||||
|
||||
|
||||
((EntityItem) entity).age++;
|
||||
((EntityItem) entity).delayBeforeCanPickup = 20;
|
||||
|
||||
boolean foundSneaking = false;
|
||||
for (EntityPlayer player : (List<EntityPlayer>) world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1)))
|
||||
{
|
||||
if (player.isSneaking())
|
||||
foundSneaking = true;
|
||||
}
|
||||
|
||||
if (foundSneaking)
|
||||
((EntityItem) entity).delayBeforeCanPickup = 0;
|
||||
else
|
||||
((EntityItem) entity).delayBeforeCanPickup = 20;
|
||||
entity.onGround = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package assemblyline.common.machine.belt;
|
|||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -119,6 +120,9 @@ public class TileEntityConveyorBelt extends TileEntityAssemblyNetwork implements
|
|||
|
||||
if (this.isRunning())
|
||||
{
|
||||
if (this.ticks % (80) == 0) //sound is 4 seconds long (20 ticks/second)
|
||||
Minecraft.getMinecraft().sndManager.playSound("assemblyline.conveyor", this.xCoord, this.yCoord, this.zCoord, 0.125f, 0.3f);
|
||||
|
||||
this.wheelRotation += 40;
|
||||
|
||||
if (this.wheelRotation > 360)
|
||||
|
|
Loading…
Reference in a new issue