Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.yarinch.modularmachines.block;
- import com.yarinch.modularmachines.ModularMachines;
- import com.yarinch.modularmachines.tileentity.TileEntityMachineCore;
- import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
- import net.minecraft.block.Block;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.world.World;
- public class BlockMachineBase extends BlockMM {
- public BlockMachineBase() {
- super();
- this.setBlockName("machineBase");
- this.setBlockTextureName("machineBase");
- }
- protected TileEntityMachineCore searchCore(World world, int x, int y, int z) {
- for (int x0 = -1; x0 <= 1; x0++) {
- for (int y0 = -1; y0 <= 1; y0++) {
- for (int z0 = -1; z0 <= 1; z0++) {
- if (world.getBlock(x + x0, y + y0, z + z0) instanceof BlockMachineCore) {
- return (TileEntityMachineCore)world.getTileEntity(x + x0, y + y0, z + z0);
- }
- }
- }
- }
- return null;
- }
- @Override
- public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
- TileEntityMachineCore te = searchCore(world, x, y, z);
- if (te != null) {
- if (!te.checkBefore) {
- te.multiblockCheck();
- te.checkBefore = true;
- }
- if (te.isFormed()) {
- if (!world.isRemote) {
- FMLNetworkHandler.openGui(player, ModularMachines.instance, 1, world, te.xCoord, te.yCoord, te.zCoord);
- }
- return true;
- }
- }
- return false;
- }
- //Each components returns the appropriate enum.
- public MachineComponents getMachineType() {
- return MachineComponents.NO_USE;
- }
- @Override
- public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
- TileEntityMachineCore te = searchCore(world, x, y, z);
- if (te != null) {
- te.disableForm();
- }
- super.breakBlock(world, x, y, z, block, meta);
- }
- /*@Override
- public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) {
- TileEntityMachineCore te = searchCore(world, x, y, z);
- if (te != null) {
- te.multiblockCheck();
- }
- return super.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, meta);
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement