Fixed conveyor belt sound and animation
This commit is contained in:
parent
bf574c7c8c
commit
028ff3fc1a
5 changed files with 12 additions and 10 deletions
|
@ -17,7 +17,7 @@ public class SoundHandler
|
||||||
{
|
{
|
||||||
public static final SoundHandler INSTANCE = new SoundHandler();
|
public static final SoundHandler INSTANCE = new SoundHandler();
|
||||||
|
|
||||||
public static final String[] SOUND_FILES = { "hammer.ogg", "grinder1.ogg", "grinder2.ogg", "grinder3.ogg", "grinder4.ogg", "electricshock1.ogg", "electricshock2.ogg", "electricshock3.ogg", "electricshock4.ogg", "electricshock5.ogg", "electricshock6.ogg", "electricshock7.ogg" };
|
public static final String[] SOUND_FILES = { "hammer.ogg", "grinder1.ogg", "grinder2.ogg", "grinder3.ogg", "grinder4.ogg", "electricshock1.ogg", "electricshock2.ogg", "electricshock3.ogg", "electricshock4.ogg", "electricshock5.ogg", "electricshock6.ogg", "electricshock7.ogg" , "conveyor.ogg" };
|
||||||
|
|
||||||
@ForgeSubscribe
|
@ForgeSubscribe
|
||||||
public void loadSoundEvents(SoundLoadEvent event)
|
public void loadSoundEvents(SoundLoadEvent event)
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer implements ICu
|
||||||
bindTexture(name);
|
bindTexture(name);
|
||||||
GL11.glRotatef(180, 0f, 1f, 0f);
|
GL11.glRotatef(180, 0f, 1f, 0f);
|
||||||
GL11.glTranslatef(0f, -0.68f, 0f);
|
GL11.glTranslatef(0f, -0.68f, 0f);
|
||||||
MODEL.render(0.0625f, (float) Math.toRadians(tileEntity.getNetwork().getRotation()), false, false, false, false);
|
MODEL.render(0.0625f, (float) Math.toRadians(tileEntity.angle), false, false, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -124,7 +124,7 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer implements ICu
|
||||||
}
|
}
|
||||||
ResourceLocation name = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "belt/frame" + frame + ".png");
|
ResourceLocation name = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "belt/frame" + frame + ".png");
|
||||||
bindTexture(name);
|
bindTexture(name);
|
||||||
MODEL.render(0.0625F, (float) Math.toRadians(tileEntity.getNetwork().getRotation()), false, false, false, true);
|
MODEL.render(0.0625F, (float) Math.toRadians(tileEntity.angle), false, false, false, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import resonantinduction.api.IBelt;
|
import resonantinduction.api.IBelt;
|
||||||
|
import resonantinduction.core.Reference;
|
||||||
import resonantinduction.core.ResonantInduction;
|
import resonantinduction.core.ResonantInduction;
|
||||||
import resonantinduction.mechanical.Mechanical;
|
import resonantinduction.mechanical.Mechanical;
|
||||||
import resonantinduction.mechanical.network.IMechanical;
|
import resonantinduction.mechanical.network.IMechanical;
|
||||||
|
@ -76,11 +77,12 @@ public class TileConveyorBelt extends TileMechanical implements IBelt, IRotatabl
|
||||||
{
|
{
|
||||||
if (this.ticks % 10 == 0 && this.worldObj.isRemote && this.worldObj.getBlockId(this.xCoord - 1, this.yCoord, this.zCoord) != Mechanical.blockConveyorBelt.blockID && this.worldObj.getBlockId(xCoord, yCoord, zCoord - 1) != Mechanical.blockConveyorBelt.blockID)
|
if (this.ticks % 10 == 0 && this.worldObj.isRemote && this.worldObj.getBlockId(this.xCoord - 1, this.yCoord, this.zCoord) != Mechanical.blockConveyorBelt.blockID && this.worldObj.getBlockId(xCoord, yCoord, zCoord - 1) != Mechanical.blockConveyorBelt.blockID)
|
||||||
{
|
{
|
||||||
this.worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, "mods.assemblyline.conveyor", 0.5f, 0.7f, true);
|
this.worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, Reference.PREFIX + "conveyor", 0.5f, 0.7f, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
angle += Math.abs(angularVelocity / 20);
|
angle = getNetwork().getRotation(getMoveVelocity());
|
||||||
double beltPercentage = (angle % Math.PI) / Math.PI;
|
// (float) ((angle + getMoveVelocity() / 20) % Math.PI);
|
||||||
|
double beltPercentage = angle / (2 * Math.PI);
|
||||||
|
|
||||||
// Sync the animation. Slant belts are slower.
|
// Sync the animation. Slant belts are slower.
|
||||||
if (this.getSlant() == SlantType.NONE || this.getSlant() == SlantType.TOP)
|
if (this.getSlant() == SlantType.NONE || this.getSlant() == SlantType.TOP)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import universalelectricity.api.net.INetwork;
|
||||||
public interface IMechanicalNetwork extends INetwork<IMechanicalNetwork, IMechanical>
|
public interface IMechanicalNetwork extends INetwork<IMechanicalNetwork, IMechanical>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return The current rotation value of the network.
|
* @return The current rotation value of the network. Used for syncing rotational values.
|
||||||
*/
|
*/
|
||||||
public float getRotation();
|
public float getRotation(float velocity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,13 +144,13 @@ public class MechanicalNetwork extends Network<IMechanicalNetwork, IMechanical>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getRotation()
|
public float getRotation(float velocity)
|
||||||
{
|
{
|
||||||
long deltaTime = System.currentTimeMillis() - lastRotateTime;
|
long deltaTime = System.currentTimeMillis() - lastRotateTime;
|
||||||
|
|
||||||
if (deltaTime > 1)
|
if (deltaTime > 1)
|
||||||
{
|
{
|
||||||
rotation = (float) (((0) * (deltaTime / 1000f) + rotation) % (2 * Math.PI));
|
rotation = (float) (((velocity) * (deltaTime / 1000f) + rotation) % (2 * Math.PI));
|
||||||
lastRotateTime = System.currentTimeMillis();
|
lastRotateTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue