Red String dispenser.

This commit is contained in:
Lizbeth Rika committed 2014-11-14 23:38:40 +00:00
1 parent c3a3b93da1
commit 7df0c1c57f
6 files changed
+89

No files matched your search

@@ -0,0 +1,45 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under a
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
*
* File Created @ [Nov 14, 2014, 10:59:20 PM (GMT)]
*/
package vazkii.botania.common.block.string;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import vazkii.botania.common.block.tile.string.TileRedString;
import vazkii.botania.common.block.tile.string.TileRedStringContainer;
import vazkii.botania.common.block.tile.string.TileRedStringDispenser;
import vazkii.botania.common.lib.LibBlockNames;
public class BlockRedStringDispenser extends BlockRedString {
public BlockRedStringDispenser() {
super(LibBlockNames.RED_STRING_DISPENSER);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
boolean power = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z);
int meta = world.getBlockMetadata(x, y, z);
boolean powered = (meta & 8) != 0;
if(power && !powered) {
((TileRedStringDispenser) world.getTileEntity(x, y, z)).tickDispenser();
world.setBlockMetadataWithNotify(x, y, z, meta | 8, 4);
} else if(!power && powered)
world.setBlockMetadataWithNotify(x, y, z, meta & -9, 4);
}
@Override
public TileRedString createNewTileEntity(World world, int meta) {
return new TileRedStringDispenser();
}
}