BlockPressurePlateWeighted .java

net.minecraft.block.BlockPressurePlateWeighted (class, 85 lines): members: field_150068_a, computeRedstoneStrength, getRedstoneStrength, POWER, tickRate.

net.minecraft.blockclass85 linescommonextends BlockBasePressurePlate2.5 KB

API Surface (7)

int computeRedstoneStrength(World worldIn, BlockPos pos)
int getRedstoneStrength(IBlockState state)
IBlockState setRedstoneStrength(IBlockState state, int strength)
int tickRate(World worldIn)
IBlockState getStateFromMeta(int meta)
int getMetaFromState(IBlockState state)
BlockState createBlockState()

Fields & Constants (2)

POWER
field_150068_a

String literals (1)

"power"

Full Source

BlockPressurePlateWeighted.java85 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.block;
2
3
import net.minecraft.block.material.MapColor;
4
import net.minecraft.block.material.Material;
5
import net.minecraft.block.properties.IProperty;
6
import net.minecraft.block.properties.PropertyInteger;
7
import net.minecraft.block.state.BlockState;
8
import net.minecraft.block.state.IBlockState;
9
import net.minecraft.entity.Entity;
10
import net.minecraft.util.BlockPos;
11
import net.minecraft.util.MathHelper;
12
import net.minecraft.world.World;
13
14
public class BlockPressurePlateWeighted extends BlockBasePressurePlate
15
{
16
    public static final PropertyInteger POWER = PropertyInteger.create("power", 0, 15);
17
    private final int field_150068_a;
18
19
    protected BlockPressurePlateWeighted(Material p_i46379_1_, int p_i46379_2_)
20
    {
21
        this(p_i46379_1_, p_i46379_2_, p_i46379_1_.getMaterialMapColor());
22
    }
23
24
    protected BlockPressurePlateWeighted(Material p_i46380_1_, int p_i46380_2_, MapColor p_i46380_3_)
25
    {
26
        super(p_i46380_1_, p_i46380_3_);
27
        this.setDefaultState(this.blockState.getBaseState().withProperty(POWER, Integer.valueOf(0)));
28
        this.field_150068_a = p_i46380_2_;
29
    }
30
31
    protected int computeRedstoneStrength(World worldIn, BlockPos pos)
32
    {
33
        int i = Math.min(worldIn.getEntitiesWithinAABB(Entity.class, this.getSensitiveAABB(pos)).size(), this.field_150068_a);
34
35
        if (i > 0)
36
        {
37
            float f = (float)Math.min(this.field_150068_a, i) / (float)this.field_150068_a;
38
            return MathHelper.ceiling_float_int(f * 15.0F);
39
        }
40
        else
41
        {
42
            return 0;
43
        }
44
    }
45
46
    protected int getRedstoneStrength(IBlockState state)
47
    {
48
        return ((Integer)state.getValue(POWER)).intValue();
49
    }
50
51
    protected IBlockState setRedstoneStrength(IBlockState state, int strength)
52
    {
53
        return state.withProperty(POWER, Integer.valueOf(strength));
54
    }
55
56
    /**
57
     * How many world ticks before ticking
58
     */
59
    public int tickRate(World worldIn)
60
    {
61
        return 10;
62
    }
63
64
    /**
65
     * Convert the given metadata into a BlockState for this Block
66
     */
67
    public IBlockState getStateFromMeta(int meta)
68
    {
69
        return this.getDefaultState().withProperty(POWER, Integer.valueOf(meta));
70
    }
71
72
    /**
73
     * Convert the BlockState into the correct metadata value
74
     */
75
    public int getMetaFromState(IBlockState state)
76
    {
77
        return ((Integer)state.getValue(POWER)).intValue();
78
    }
79
80
    protected BlockState createBlockState()
81
    {
82
        return new BlockState(this, new IProperty[] {POWER});
83
    }
84
}
85

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