initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
74
java/src/game/tileentity/TileEntityNote.java
Executable file
74
java/src/game/tileentity/TileEntityNote.java
Executable file
|
@ -0,0 +1,74 @@
|
|||
package game.tileentity;
|
||||
|
||||
import game.ExtMath;
|
||||
import game.init.Blocks;
|
||||
import game.material.Material;
|
||||
import game.nbt.NBTTagCompound;
|
||||
import game.world.BlockPos;
|
||||
import game.world.World;
|
||||
|
||||
public class TileEntityNote extends TileEntity
|
||||
{
|
||||
/** Note to play */
|
||||
public byte note;
|
||||
|
||||
/** stores the latest redstone state */
|
||||
public boolean previousRedstoneState;
|
||||
|
||||
public void writeToNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.writeToNBT(compound);
|
||||
compound.setByte("note", this.note);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound)
|
||||
{
|
||||
super.readFromNBT(compound);
|
||||
this.note = compound.getByte("note");
|
||||
this.note = (byte)ExtMath.clampi(this.note, 0, 24);
|
||||
}
|
||||
|
||||
/**
|
||||
* change pitch by -> (currentPitch + 1) % 25
|
||||
*/
|
||||
public void changePitch()
|
||||
{
|
||||
this.note = (byte)((this.note + 1) % 25);
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public void triggerNote(World worldIn, BlockPos p_175108_2_)
|
||||
{
|
||||
if (worldIn.getState(p_175108_2_.up()).getBlock().getMaterial() == Material.air)
|
||||
{
|
||||
// Material material = worldIn.getBlockState(p_175108_2_.down()).getBlock().getMaterial();
|
||||
// int i = 0;
|
||||
//
|
||||
// if (material == Material.rock)
|
||||
// {
|
||||
// i = 1;
|
||||
// }
|
||||
//
|
||||
// if (material == Material.sand)
|
||||
// {
|
||||
// i = 2;
|
||||
// }
|
||||
//
|
||||
// if (material == Material.glass)
|
||||
// {
|
||||
// i = 3;
|
||||
// }
|
||||
//
|
||||
// if (material == Material.wood)
|
||||
// {
|
||||
// i = 4;
|
||||
// }
|
||||
|
||||
worldIn.addBlockEvent(p_175108_2_, Blocks.noteblock, 0, this.note);
|
||||
}
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return 0x80ff00;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue