BlockBrewingStand .java

net.minecraft.block.BlockBrewingStand (class, 217 lines): members: HAS_BOTTLE, getComparatorInputOverride, hasComparatorInputOverride, getLocalizedName.

net.minecraft.blockclass217 linescommonextends BlockContainer6.6 KB

API Surface (19)

String getLocalizedName()
boolean isOpaqueCube()
int getRenderType()
TileEntity createNewTileEntity(World worldIn, int meta)
boolean isFullCube()
void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
void setBlockBoundsForItemRender()
boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
void breakBlock(World worldIn, BlockPos pos, IBlockState state)
Item getItemDropped(IBlockState state, Random rand, int fortune)
Item getItem(World worldIn, BlockPos pos)
boolean hasComparatorInputOverride()
int getComparatorInputOverride(World worldIn, BlockPos pos)
EnumWorldBlockLayer getBlockLayer()
IBlockState getStateFromMeta(int meta)
int getMetaFromState(IBlockState state)
BlockState createBlockState()

Fields & Constants (1)

HAS_BOTTLE

String literals (4)

"has_bottle_0"
"has_bottle_1"
"has_bottle_2"
"item.brewingStand.name"

Full Source

BlockBrewingStand.java217 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.block;
2
3
import java.util.List;
4
import java.util.Random;
5
import net.minecraft.block.material.Material;
6
import net.minecraft.block.properties.IProperty;
7
import net.minecraft.block.properties.PropertyBool;
8
import net.minecraft.block.state.BlockState;
9
import net.minecraft.block.state.IBlockState;
10
import net.minecraft.entity.Entity;
11
import net.minecraft.entity.EntityLivingBase;
12
import net.minecraft.entity.player.EntityPlayer;
13
import net.minecraft.init.Items;
14
import net.minecraft.inventory.Container;
15
import net.minecraft.inventory.InventoryHelper;
16
import net.minecraft.item.Item;
17
import net.minecraft.item.ItemStack;
18
import net.minecraft.stats.StatList;
19
import net.minecraft.tileentity.TileEntity;
20
import net.minecraft.tileentity.TileEntityBrewingStand;
21
import net.minecraft.util.AxisAlignedBB;
22
import net.minecraft.util.BlockPos;
23
import net.minecraft.util.EnumFacing;
24
import net.minecraft.util.EnumParticleTypes;
25
import net.minecraft.util.EnumWorldBlockLayer;
26
import net.minecraft.util.StatCollector;
27
import net.minecraft.world.World;
28
29
public class BlockBrewingStand extends BlockContainer
30
{
31
    public static final PropertyBool[] HAS_BOTTLE = new PropertyBool[] {PropertyBool.create("has_bottle_0"), PropertyBool.create("has_bottle_1"), PropertyBool.create("has_bottle_2")};
32
33
    public BlockBrewingStand()
34
    {
35
        super(Material.iron);
36
        this.setDefaultState(this.blockState.getBaseState().withProperty(HAS_BOTTLE[0], Boolean.valueOf(false)).withProperty(HAS_BOTTLE[1], Boolean.valueOf(false)).withProperty(HAS_BOTTLE[2], Boolean.valueOf(false)));
37
    }
38
39
    /**
40
     * Gets the localized name of this block. Used for the statistics page.
41
     */
42
    public String getLocalizedName()
43
    {
44
        return StatCollector.translateToLocal("item.brewingStand.name");
45
    }
46
47
    /**
48
     * Used to determine ambient occlusion and culling when rebuilding chunks for render
49
     */
50
    public boolean isOpaqueCube()
51
    {
52
        return false;
53
    }
54
55
    /**
56
     * The type of render function called. 3 for standard block models, 2 for TESR's, 1 for liquids, -1 is no render
57
     */
58
    public int getRenderType()
59
    {
60
        return 3;
61
    }
62
63
    /**
64
     * Returns a new instance of a block's tile entity class. Called on placing the block.
65
     */
66
    public TileEntity createNewTileEntity(World worldIn, int meta)
67
    {
68
        return new TileEntityBrewingStand();
69
    }
70
71
    public boolean isFullCube()
72
    {
73
        return false;
74
    }
75
76
    /**
77
     * Add all collision boxes of this Block to the list that intersect with the given mask.
78
     */
79
    public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
80
    {
81
        this.setBlockBounds(0.4375F, 0.0F, 0.4375F, 0.5625F, 0.875F, 0.5625F);
82
        super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
83
        this.setBlockBoundsForItemRender();
84
        super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
85
    }
86
87
    /**
88
     * Sets the block's bounds for rendering it as an item
89
     */
90
    public void setBlockBoundsForItemRender()
91
    {
92
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
93
    }
94
95
    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
96
    {
97
        if (worldIn.isRemote)
98
        {
99
            return true;
100
        }
101
        else
102
        {
103
            TileEntity tileentity = worldIn.getTileEntity(pos);
104
105
            if (tileentity instanceof TileEntityBrewingStand)
106
            {
107
                playerIn.displayGUIChest((TileEntityBrewingStand)tileentity);
108
                playerIn.triggerAchievement(StatList.field_181729_M);
109
            }
110
111
            return true;
112
        }
113
    }
114
115
    /**
116
     * Called by ItemBlocks after a block is set in the world, to allow post-place logic
117
     */
118
    public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
119
    {
120
        if (stack.hasDisplayName())
121
        {
122
            TileEntity tileentity = worldIn.getTileEntity(pos);
123
124
            if (tileentity instanceof TileEntityBrewingStand)
125
            {
126
                ((TileEntityBrewingStand)tileentity).setName(stack.getDisplayName());
127
            }
128
        }
129
    }
130
131
    public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
132
    {
133
        double d0 = (double)((float)pos.getX() + 0.4F + rand.nextFloat() * 0.2F);
134
        double d1 = (double)((float)pos.getY() + 0.7F + rand.nextFloat() * 0.3F);
135
        double d2 = (double)((float)pos.getZ() + 0.4F + rand.nextFloat() * 0.2F);
136
        worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D, new int[0]);
137
    }
138
139
    public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
140
    {
141
        TileEntity tileentity = worldIn.getTileEntity(pos);
142
143
        if (tileentity instanceof TileEntityBrewingStand)
144
        {
145
            InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityBrewingStand)tileentity);
146
        }
147
148
        super.breakBlock(worldIn, pos, state);
149
    }
150
151
    /**
152
     * Get the Item that this Block should drop when harvested.
153
     */
154
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
155
    {
156
        return Items.brewing_stand;
157
    }
158
159
    public Item getItem(World worldIn, BlockPos pos)
160
    {
161
        return Items.brewing_stand;
162
    }
163
164
    public boolean hasComparatorInputOverride()
165
    {
166
        return true;
167
    }
168
169
    public int getComparatorInputOverride(World worldIn, BlockPos pos)
170
    {
171
        return Container.calcRedstone(worldIn.getTileEntity(pos));
172
    }
173
174
    public EnumWorldBlockLayer getBlockLayer()
175
    {
176
        return EnumWorldBlockLayer.CUTOUT;
177
    }
178
179
    /**
180
     * Convert the given metadata into a BlockState for this Block
181
     */
182
    public IBlockState getStateFromMeta(int meta)
183
    {
184
        IBlockState iblockstate = this.getDefaultState();
185
186
        for (int i = 0; i < 3; ++i)
187
        {
188
            iblockstate = iblockstate.withProperty(HAS_BOTTLE[i], Boolean.valueOf((meta & 1 << i) > 0));
189
        }
190
191
        return iblockstate;
192
    }
193
194
    /**
195
     * Convert the BlockState into the correct metadata value
196
     */
197
    public int getMetaFromState(IBlockState state)
198
    {
199
        int i = 0;
200
201
        for (int j = 0; j < 3; ++j)
202
        {
203
            if (((Boolean)state.getValue(HAS_BOTTLE[j])).booleanValue())
204
            {
205
                i |= 1 << j;
206
            }
207
        }
208
209
        return i;
210
    }
211
212
    protected BlockState createBlockState()
213
    {
214
        return new BlockState(this, new IProperty[] {HAS_BOTTLE[0], HAS_BOTTLE[1], HAS_BOTTLE[2]});
215
    }
216
}
217

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