Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minecraft.src;
- import java.util.Random;
- public class BlockBattery extends BlockContainer {
- public BlockBattery(int i, int j, Material material) {
- super(i, j, material);
- updateCounter = 0;
- setTickOnLoad(true);
- }
- protected TileEntity getBlockEntity() {
- return new TileEntityBattery();
- }
- public int tickRate() {
- return 2;
- }
- public void updateTick(World world, int i, int j, int k, Random random) {
- TileEntityBattery tileentity = (TileEntityBattery)world.getBlockTileEntity(i, j, k);
- updateCounter = (updateCounter + 1) % 20;
- tileentity.currentState = tileentity.poweredTick[updateCounter];
- if (tileentity.currentState != tileentity.prevState) {
- if (tileentity.enabledFace[0]) world.notifyBlocksOfNeighborChange(i, j + 1, k, blockID);
- if (tileentity.enabledFace[1]) world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
- if (tileentity.enabledFace[2]) world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID);
- if (tileentity.enabledFace[3]) world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID);
- if (tileentity.enabledFace[4]) world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID);
- if (tileentity.enabledFace[5]) world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID);
- tileentity.prevState = tileentity.currentState;
- }
- }
- public boolean isPoweringTo(IBlockAccess iblockaccess, int i, int j, int k, int l) {
- TileEntityBattery tileentity = (TileEntityBattery)iblockaccess.getBlockTileEntity(i, j, k);
- return tileentity.currentState && tileentity.enabledFace[l];
- }
- public boolean isIndirectlyPoweringTo(World world, int i, int j, int k, int l) {
- TileEntityBattery tileentity = (TileEntityBattery)world.getBlockTileEntity(i, j, k);
- return tileentity.currentState && tileentity.enabledFace[l];
- }
- public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) {
- // Open GUI to Configure
- return false;
- }
- private int updateCounter;
- }
- package net.minecraft.src;
- public class TileEntityBattery extends TileEntity {
- public TileEntityBattery() {
- enabledFace = new boolean[] {
- false, false, false, false, false, false
- };
- poweredTick = new boolean[] {
- false, false, false, false, false, false, false, false, false, false,
- false, false, false, false, false, false, false, false, false, false
- };
- currentState = false;
- prevState = false;
- }
- public void readFromNBT(NBTTagCompound nbttagcompound) {
- super.readFromNBT(nbttagcompound);
- //
- }
- public void writeToNBT(NBTTagCompound nbttagcompound) {
- super.writeToNBT(nbttagcompound);
- //
- }
- public boolean[] enabledFace;
- public boolean[] poweredTick;
- public boolean currentState;
- public boolean prevState;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement