BlockPressurePlate .java

net.minecraft.block.BlockPressurePlate (class, 97 lines): members: Sensitivity, sensitivity, computeRedstoneStrength, getRedstoneStrength, POWERED.

net.minecraft.blockclass97 linescommonextends BlockBasePressurePlate2.7 KB

API Surface (6)

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

Fields & Constants (2)

POWERED
sensitivity

String literals (1)

"powered"

Full Source

BlockPressurePlate.java97 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.block;
2
3
import java.util.List;
4
import net.minecraft.block.material.Material;
5
import net.minecraft.block.properties.IProperty;
6
import net.minecraft.block.properties.PropertyBool;
7
import net.minecraft.block.state.BlockState;
8
import net.minecraft.block.state.IBlockState;
9
import net.minecraft.entity.Entity;
10
import net.minecraft.entity.EntityLivingBase;
11
import net.minecraft.util.AxisAlignedBB;
12
import net.minecraft.util.BlockPos;
13
import net.minecraft.world.World;
14
15
public class BlockPressurePlate extends BlockBasePressurePlate
16
{
17
    public static final PropertyBool POWERED = PropertyBool.create("powered");
18
    private final BlockPressurePlate.Sensitivity sensitivity;
19
20
    protected BlockPressurePlate(Material materialIn, BlockPressurePlate.Sensitivity sensitivityIn)
21
    {
22
        super(materialIn);
23
        this.setDefaultState(this.blockState.getBaseState().withProperty(POWERED, Boolean.valueOf(false)));
24
        this.sensitivity = sensitivityIn;
25
    }
26
27
    protected int getRedstoneStrength(IBlockState state)
28
    {
29
        return ((Boolean)state.getValue(POWERED)).booleanValue() ? 15 : 0;
30
    }
31
32
    protected IBlockState setRedstoneStrength(IBlockState state, int strength)
33
    {
34
        return state.withProperty(POWERED, Boolean.valueOf(strength > 0));
35
    }
36
37
    protected int computeRedstoneStrength(World worldIn, BlockPos pos)
38
    {
39
        AxisAlignedBB axisalignedbb = this.getSensitiveAABB(pos);
40
        List <? extends Entity > list;
41
42
        switch (this.sensitivity)
43
        {
44
            case EVERYTHING:
45
                list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, axisalignedbb);
46
                break;
47
48
            case MOBS:
49
                list = worldIn.<Entity>getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
50
                break;
51
52
            default:
53
                return 0;
54
        }
55
56
        if (!list.isEmpty())
57
        {
58
            for (Entity entity : list)
59
            {
60
                if (!entity.doesEntityNotTriggerPressurePlate())
61
                {
62
                    return 15;
63
                }
64
            }
65
        }
66
67
        return 0;
68
    }
69
70
    /**
71
     * Convert the given metadata into a BlockState for this Block
72
     */
73
    public IBlockState getStateFromMeta(int meta)
74
    {
75
        return this.getDefaultState().withProperty(POWERED, Boolean.valueOf(meta == 1));
76
    }
77
78
    /**
79
     * Convert the BlockState into the correct metadata value
80
     */
81
    public int getMetaFromState(IBlockState state)
82
    {
83
        return ((Boolean)state.getValue(POWERED)).booleanValue() ? 1 : 0;
84
    }
85
86
    protected BlockState createBlockState()
87
    {
88
        return new BlockState(this, new IProperty[] {POWERED});
89
    }
90
91
    public static enum Sensitivity
92
    {
93
        EVERYTHING,
94
        MOBS;
95
    }
96
}
97

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