TileEntityNote .java

net.minecraft.tileentity.TileEntityNote (class): members: previousRedstoneState, changePitch, triggerNote, note, readFromNBT, writeToNBT. strings: "note".

net.minecraft.tileentityclass71 linescommonextends TileEntity1.7 KB

API Surface (4)

void writeToNBT(NBTTagCompound compound)
void readFromNBT(NBTTagCompound compound)
void changePitch()
void triggerNote(World worldIn, BlockPos p_175108_2_)

Fields & Constants (2)

note
previousRedstoneState

String literals (1)

"note"

Code Graph: Dependencies (7)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

TileEntityNote.java71 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.tileentity;
2
3
import net.minecraft.block.material.Material;
4
import net.minecraft.init.Blocks;
5
import net.minecraft.nbt.NBTTagCompound;
6
import net.minecraft.util.BlockPos;
7
import net.minecraft.util.MathHelper;
8
import net.minecraft.world.World;
9
10
public class TileEntityNote extends TileEntity
11
{
12
    /** Note to play */
13
    public byte note;
14
15
    /** stores the latest redstone state */
16
    public boolean previousRedstoneState;
17
18
    public void writeToNBT(NBTTagCompound compound)
19
    {
20
        super.writeToNBT(compound);
21
        compound.setByte("note", this.note);
22
    }
23
24
    public void readFromNBT(NBTTagCompound compound)
25
    {
26
        super.readFromNBT(compound);
27
        this.note = compound.getByte("note");
28
        this.note = (byte)MathHelper.clamp_int(this.note, 0, 24);
29
    }
30
31
    /**
32
     * change pitch by -> (currentPitch + 1) % 25
33
     */
34
    public void changePitch()
35
    {
36
        this.note = (byte)((this.note + 1) % 25);
37
        this.markDirty();
38
    }
39
40
    public void triggerNote(World worldIn, BlockPos p_175108_2_)
41
    {
42
        if (worldIn.getBlockState(p_175108_2_.up()).getBlock().getMaterial() == Material.air)
43
        {
44
            Material material = worldIn.getBlockState(p_175108_2_.down()).getBlock().getMaterial();
45
            int i = 0;
46
47
            if (material == Material.rock)
48
            {
49
                i = 1;
50
            }
51
52
            if (material == Material.sand)
53
            {
54
                i = 2;
55
            }
56
57
            if (material == Material.glass)
58
            {
59
                i = 3;
60
            }
61
62
            if (material == Material.wood)
63
            {
64
                i = 4;
65
            }
66
67
            worldIn.addBlockEvent(p_175108_2_, Blocks.noteblock, i, this.note);
68
        }
69
    }
70
}
71

Deobfuscated MCP 1.8.9 source of TileEntityNote from Marcelektro/MavenMCP-1.8.9 (net/minecraft/tileentity/TileEntityNote.java), stored verbatim.