mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
More work on pumpjack
This commit is contained in:
parent
5a27d31441
commit
f5c8d4309a
File diff suppressed because it is too large
Load Diff
@ -422,6 +422,8 @@ public class ModBlocks {
|
||||
public static Block dummy_port_fluidtank;
|
||||
public static Block dummy_block_refinery;
|
||||
public static Block dummy_port_refinery;
|
||||
public static Block dummy_block_pumpjack;
|
||||
public static Block dummy_port_pumpjack;
|
||||
|
||||
|
||||
private static void initializeBlock() {
|
||||
@ -746,6 +748,8 @@ public class ModBlocks {
|
||||
dummy_port_fluidtank = new DummyBlockFluidTank(Material.iron).setBlockName("dummy_port_fluidtank").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":block_steel");
|
||||
dummy_block_refinery = new DummyBlockRefinery(Material.iron).setBlockName("dummy_block_refinery").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":block_titanium");
|
||||
dummy_port_refinery = new DummyBlockRefinery(Material.iron).setBlockName("dummy_port_refinery").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":block_titanium");
|
||||
dummy_block_pumpjack = new DummyBlockPumpjack(Material.iron).setBlockName("dummy_block_pumpjack").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":block_titanium");
|
||||
dummy_port_pumpjack = new DummyBlockPumpjack(Material.iron).setBlockName("dummy_port_pumpjack").setHardness(5.0F).setResistance(10.0F).setCreativeTab(null).setBlockTextureName(RefStrings.MODID + ":block_titanium");
|
||||
}
|
||||
|
||||
private static void registerBlock() {
|
||||
@ -1056,6 +1060,8 @@ public class ModBlocks {
|
||||
GameRegistry.registerBlock(dummy_port_fluidtank, dummy_port_fluidtank.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(dummy_block_refinery, dummy_block_refinery.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(dummy_port_refinery, dummy_port_refinery.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(dummy_block_pumpjack, dummy_block_pumpjack.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(dummy_port_pumpjack, dummy_port_pumpjack.getUnlocalizedName());
|
||||
|
||||
//Other Technical Blocks
|
||||
GameRegistry.registerBlock(oil_pipe, oil_pipe.getUnlocalizedName());
|
||||
|
||||
107
com/hbm/blocks/machine/DummyBlockPumpjack.java
Normal file
107
com/hbm/blocks/machine/DummyBlockPumpjack.java
Normal file
@ -0,0 +1,107 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.interfaces.IDummy;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.TileEntityDummy;
|
||||
import com.hbm.tileentity.TileEntityMachineChemplant;
|
||||
import com.hbm.tileentity.TileEntityMachinePumpjack;
|
||||
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class DummyBlockPumpjack extends BlockContainer implements IDummy {
|
||||
|
||||
public static boolean safeBreak = false;
|
||||
|
||||
public DummyBlockPumpjack(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
return new TileEntityDummy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int i)
|
||||
{
|
||||
if(!safeBreak) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te != null && te instanceof TileEntityDummy) {
|
||||
int a = ((TileEntityDummy)te).targetX;
|
||||
int b = ((TileEntityDummy)te).targetY;
|
||||
int c = ((TileEntityDummy)te).targetZ;
|
||||
|
||||
//world.getBlock(a, b, c).breakBlock(world, a, b, c, block, i);
|
||||
if(!world.isRemote)
|
||||
world.func_147480_a(a, b, c, true);
|
||||
}
|
||||
}
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Item getItem(World world, int x, int y, int z)
|
||||
{
|
||||
return Item.getItemFromBlock(ModBlocks.machine_pumpjack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
if(world.isRemote)
|
||||
{
|
||||
return true;
|
||||
} else if(!player.isSneaking())
|
||||
{
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te != null && te instanceof TileEntityDummy) {
|
||||
int a = ((TileEntityDummy)te).targetX;
|
||||
int b = ((TileEntityDummy)te).targetY;
|
||||
int c = ((TileEntityDummy)te).targetZ;
|
||||
|
||||
TileEntityMachinePumpjack entity = (TileEntityMachinePumpjack) world.getTileEntity(a, b, c);
|
||||
if(entity != null)
|
||||
{
|
||||
FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_machine_pumpjack, world, a, b, c);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,17 +1,41 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.handler.MultiblockHandler;
|
||||
import com.hbm.interfaces.IMultiblock;
|
||||
import com.hbm.tileentity.TileEntityDummy;
|
||||
import com.hbm.tileentity.TileEntityMachineOilWell;
|
||||
import com.hbm.tileentity.TileEntityMachinePumpjack;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class MachinePumpjack extends BlockContainer {
|
||||
public class MachinePumpjack extends BlockContainer implements IMultiblock {
|
||||
|
||||
private final Random field_149933_a = new Random();
|
||||
private Random rand;
|
||||
private static boolean keepInventory;
|
||||
|
||||
public MachinePumpjack(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
|
||||
{
|
||||
return Item.getItemFromBlock(ModBlocks.machine_pumpjack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
|
||||
@ -32,5 +56,179 @@ public class MachinePumpjack extends BlockContainer {
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
|
||||
{
|
||||
if (!keepInventory)
|
||||
{
|
||||
TileEntityMachinePumpjack tileentityfurnace = (TileEntityMachinePumpjack)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
|
||||
|
||||
if (tileentityfurnace != null)
|
||||
{
|
||||
for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1)
|
||||
{
|
||||
ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||
float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||
float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
|
||||
|
||||
while (itemstack.stackSize > 0)
|
||||
{
|
||||
int j1 = this.field_149933_a.nextInt(21) + 10;
|
||||
|
||||
if (j1 > itemstack.stackSize)
|
||||
{
|
||||
j1 = itemstack.stackSize;
|
||||
}
|
||||
|
||||
itemstack.stackSize -= j1;
|
||||
EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
|
||||
|
||||
if (itemstack.hasTagCompound())
|
||||
{
|
||||
entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
|
||||
}
|
||||
|
||||
float f3 = 0.05F;
|
||||
entityitem.motionX = (float)this.field_149933_a.nextGaussian() * f3;
|
||||
entityitem.motionY = (float)this.field_149933_a.nextGaussian() * f3 + 0.2F;
|
||||
entityitem.motionZ = (float)this.field_149933_a.nextGaussian() * f3;
|
||||
p_149749_1_.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
|
||||
int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
|
||||
if (i == 0) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
|
||||
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.pumpjackDimensionEast)) {
|
||||
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.pumpjackDimensionEast, ModBlocks.dummy_block_pumpjack);
|
||||
|
||||
//
|
||||
DummyBlockPumpjack.safeBreak = true;
|
||||
world.setBlock(x + 2, y, z, ModBlocks.dummy_port_pumpjack);
|
||||
TileEntity te = world.getTileEntity(x + 2, y, z);
|
||||
if(te instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
world.setBlock(x - 3, y, z, ModBlocks.dummy_port_pumpjack);
|
||||
TileEntity te2 = world.getTileEntity(x - 3, y, z);
|
||||
if(te instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te2;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
DummyBlockPumpjack.safeBreak = false;
|
||||
//
|
||||
|
||||
} else
|
||||
world.func_147480_a(x, y, z, true);
|
||||
}
|
||||
if (i == 1) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
|
||||
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.pumpjackDimensionSouth)) {
|
||||
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.pumpjackDimensionSouth, ModBlocks.dummy_block_pumpjack);
|
||||
|
||||
//
|
||||
DummyBlockPumpjack.safeBreak = true;
|
||||
world.setBlock(x, y, z + 2, ModBlocks.dummy_port_pumpjack);
|
||||
TileEntity te = world.getTileEntity(x, y, z + 2);
|
||||
if(te instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
world.setBlock(x, y, z - 3, ModBlocks.dummy_port_pumpjack);
|
||||
TileEntity te2 = world.getTileEntity(x, y, z - 3);
|
||||
if(te instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te2;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
DummyBlockPumpjack.safeBreak = false;
|
||||
//
|
||||
|
||||
} else
|
||||
world.func_147480_a(x, y, z, true);
|
||||
}
|
||||
if (i == 2) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
|
||||
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.pumpjackDimensionWest)) {
|
||||
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.pumpjackDimensionWest, ModBlocks.dummy_block_pumpjack);
|
||||
|
||||
//
|
||||
DummyBlockPumpjack.safeBreak = true;
|
||||
world.setBlock(x + 3, y, z, ModBlocks.dummy_port_pumpjack);
|
||||
TileEntity te = world.getTileEntity(x + 3, y, z);
|
||||
if(te instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
world.setBlock(x - 2, y, z, ModBlocks.dummy_port_pumpjack);
|
||||
TileEntity te2 = world.getTileEntity(x - 2, y, z);
|
||||
if(te instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te2;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
DummyBlockPumpjack.safeBreak = false;
|
||||
//
|
||||
|
||||
} else
|
||||
world.func_147480_a(x, y, z, true);
|
||||
}
|
||||
if (i == 3) {
|
||||
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
|
||||
if(MultiblockHandler.checkSpace(world, x, y, z, MultiblockHandler.pumpjackDimensionNorth)) {
|
||||
MultiblockHandler.fillUp(world, x, y, z, MultiblockHandler.pumpjackDimensionNorth, ModBlocks.dummy_block_pumpjack);
|
||||
|
||||
//
|
||||
DummyBlockPumpjack.safeBreak = true;
|
||||
world.setBlock(x, y, z + 3, ModBlocks.dummy_port_pumpjack);
|
||||
TileEntity te = world.getTileEntity(x, y, z + 3);
|
||||
if(te instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
world.setBlock(x, y, z - 2, ModBlocks.dummy_port_pumpjack);
|
||||
TileEntity te2 = world.getTileEntity(x, y, z - 2);
|
||||
if(te instanceof TileEntityDummy) {
|
||||
TileEntityDummy dummy = (TileEntityDummy)te2;
|
||||
dummy.targetX = x;
|
||||
dummy.targetY = y;
|
||||
dummy.targetZ = z;
|
||||
}
|
||||
DummyBlockPumpjack.safeBreak = false;
|
||||
//
|
||||
|
||||
} else
|
||||
world.func_147480_a(x, y, z, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,149 +1,10 @@
|
||||
package com.hbm.handler;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.inventory.container.ContainerBombMulti;
|
||||
import com.hbm.inventory.container.ContainerCentrifuge;
|
||||
import com.hbm.inventory.container.ContainerConverterHeRf;
|
||||
import com.hbm.inventory.container.ContainerConverterRfHe;
|
||||
import com.hbm.inventory.container.ContainerCoreAdvanced;
|
||||
import com.hbm.inventory.container.ContainerCoreTitanium;
|
||||
import com.hbm.inventory.container.ContainerDiFurnace;
|
||||
import com.hbm.inventory.container.ContainerElectricFurnace;
|
||||
import com.hbm.inventory.container.ContainerFWatzCore;
|
||||
import com.hbm.inventory.container.ContainerFusionMultiblock;
|
||||
import com.hbm.inventory.container.ContainerGenerator;
|
||||
import com.hbm.inventory.container.ContainerIGenerator;
|
||||
import com.hbm.inventory.container.ContainerLaunchPadTier1;
|
||||
import com.hbm.inventory.container.ContainerMachineAssembler;
|
||||
import com.hbm.inventory.container.ContainerMachineBattery;
|
||||
import com.hbm.inventory.container.ContainerMachineCMBFactory;
|
||||
import com.hbm.inventory.container.ContainerMachineChemplant;
|
||||
import com.hbm.inventory.container.ContainerMachineCoal;
|
||||
import com.hbm.inventory.container.ContainerMachineCyclotron;
|
||||
import com.hbm.inventory.container.ContainerMachineDeuterium;
|
||||
import com.hbm.inventory.container.ContainerMachineDiesel;
|
||||
import com.hbm.inventory.container.ContainerMachineFluidTank;
|
||||
import com.hbm.inventory.container.ContainerMachineGasFlare;
|
||||
import com.hbm.inventory.container.ContainerMachineMiningDrill;
|
||||
import com.hbm.inventory.container.ContainerMachineOilWell;
|
||||
import com.hbm.inventory.container.ContainerMachineRTG;
|
||||
import com.hbm.inventory.container.ContainerMachineRefinery;
|
||||
import com.hbm.inventory.container.ContainerMachineSchrabidiumTransmutator;
|
||||
import com.hbm.inventory.container.ContainerMachineShredder;
|
||||
import com.hbm.inventory.container.ContainerMachineTeleporter;
|
||||
import com.hbm.inventory.container.ContainerNukeBoy;
|
||||
import com.hbm.inventory.container.ContainerNukeCustom;
|
||||
import com.hbm.inventory.container.ContainerNukeFleija;
|
||||
import com.hbm.inventory.container.ContainerNukeFurnace;
|
||||
import com.hbm.inventory.container.ContainerNukeGadget;
|
||||
import com.hbm.inventory.container.ContainerNukeMan;
|
||||
import com.hbm.inventory.container.ContainerNukeMike;
|
||||
import com.hbm.inventory.container.ContainerNukePrototype;
|
||||
import com.hbm.inventory.container.ContainerNukeTsar;
|
||||
import com.hbm.inventory.container.ContainerPuF6Tank;
|
||||
import com.hbm.inventory.container.ContainerReactor;
|
||||
import com.hbm.inventory.container.ContainerReactorMultiblock;
|
||||
import com.hbm.inventory.container.ContainerReiXMainframe;
|
||||
import com.hbm.inventory.container.ContainerRtgFurnace;
|
||||
import com.hbm.inventory.container.ContainerTestNuke;
|
||||
import com.hbm.inventory.container.ContainerUF6Tank;
|
||||
import com.hbm.inventory.container.ContainerWatzCore;
|
||||
import com.hbm.inventory.gui.GUIBombMulti;
|
||||
import com.hbm.inventory.gui.GUIConverterHeRf;
|
||||
import com.hbm.inventory.gui.GUIConverterRfHe;
|
||||
import com.hbm.inventory.gui.GUICoreAdvanced;
|
||||
import com.hbm.inventory.gui.GUICoreTitanium;
|
||||
import com.hbm.inventory.gui.GUIFWatzCore;
|
||||
import com.hbm.inventory.gui.GUIFusionMultiblock;
|
||||
import com.hbm.inventory.gui.GUIIGenerator;
|
||||
import com.hbm.inventory.gui.GUILaunchPadTier1;
|
||||
import com.hbm.inventory.gui.GUIMachineAssembler;
|
||||
import com.hbm.inventory.gui.GUIMachineBattery;
|
||||
import com.hbm.inventory.gui.GUIMachineCMBFactory;
|
||||
import com.hbm.inventory.gui.GUIMachineCentrifuge;
|
||||
import com.hbm.inventory.gui.GUIMachineChemplant;
|
||||
import com.hbm.inventory.gui.GUIMachineCoal;
|
||||
import com.hbm.inventory.gui.GUIMachineCyclotron;
|
||||
import com.hbm.inventory.gui.GUIMachineDeuterium;
|
||||
import com.hbm.inventory.gui.GUIMachineDiesel;
|
||||
import com.hbm.inventory.gui.GUIMachineElectricFurnace;
|
||||
import com.hbm.inventory.gui.GUIMachineFluidTank;
|
||||
import com.hbm.inventory.gui.GUIMachineGasFlare;
|
||||
import com.hbm.inventory.gui.GUIMachineGenerator;
|
||||
import com.hbm.inventory.gui.GUIMachineMiningDrill;
|
||||
import com.hbm.inventory.gui.GUIMachineOilWell;
|
||||
import com.hbm.inventory.gui.GUIMachinePuF6Tank;
|
||||
import com.hbm.inventory.gui.GUIMachineRTG;
|
||||
import com.hbm.inventory.gui.GUIMachineReactor;
|
||||
import com.hbm.inventory.gui.GUIMachineRefinery;
|
||||
import com.hbm.inventory.gui.GUIMachineSchrabidiumTransmutator;
|
||||
import com.hbm.inventory.gui.GUIMachineShredder;
|
||||
import com.hbm.inventory.gui.GUIMachineTeleporter;
|
||||
import com.hbm.inventory.gui.GUIMachineUF6Tank;
|
||||
import com.hbm.inventory.gui.GUINukeBoy;
|
||||
import com.hbm.inventory.gui.GUINukeCustom;
|
||||
import com.hbm.inventory.gui.GUINukeFleija;
|
||||
import com.hbm.inventory.gui.GUINukeFurnace;
|
||||
import com.hbm.inventory.gui.GUINukeGadget;
|
||||
import com.hbm.inventory.gui.GUINukeMan;
|
||||
import com.hbm.inventory.gui.GUINukeMike;
|
||||
import com.hbm.inventory.gui.GUINukePrototype;
|
||||
import com.hbm.inventory.gui.GUINukeTsar;
|
||||
import com.hbm.inventory.gui.GUIReactorMultiblock;
|
||||
import com.hbm.inventory.gui.GUIReiXMainframe;
|
||||
import com.hbm.inventory.gui.GUIRtgFurnace;
|
||||
import com.hbm.inventory.gui.GUIScreenTemplateFolder;
|
||||
import com.hbm.inventory.gui.GUITestDiFurnace;
|
||||
import com.hbm.inventory.gui.GUITestNuke;
|
||||
import com.hbm.inventory.gui.GUIWatzCore;
|
||||
import com.hbm.inventory.container.*;
|
||||
import com.hbm.inventory.gui.*;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.tileentity.TileEntityBombMulti;
|
||||
import com.hbm.tileentity.TileEntityConverterHeRf;
|
||||
import com.hbm.tileentity.TileEntityConverterRfHe;
|
||||
import com.hbm.tileentity.TileEntityCoreAdvanced;
|
||||
import com.hbm.tileentity.TileEntityCoreTitanium;
|
||||
import com.hbm.tileentity.TileEntityDiFurnace;
|
||||
import com.hbm.tileentity.TileEntityFWatzCore;
|
||||
import com.hbm.tileentity.TileEntityFusionMultiblock;
|
||||
import com.hbm.tileentity.TileEntityMachineIGenerator;
|
||||
import com.hbm.tileentity.TileEntityMachineMiningDrill;
|
||||
import com.hbm.tileentity.TileEntityMachineOilWell;
|
||||
import com.hbm.tileentity.TileEntityLaunchPad;
|
||||
import com.hbm.tileentity.TileEntityMachineAssembler;
|
||||
import com.hbm.tileentity.TileEntityMachineBattery;
|
||||
import com.hbm.tileentity.TileEntityMachineCMBFactory;
|
||||
import com.hbm.tileentity.TileEntityMachineCentrifuge;
|
||||
import com.hbm.tileentity.TileEntityMachineChemplant;
|
||||
import com.hbm.tileentity.TileEntityMachineCoal;
|
||||
import com.hbm.tileentity.TileEntityMachineCyclotron;
|
||||
import com.hbm.tileentity.TileEntityMachineDeuterium;
|
||||
import com.hbm.tileentity.TileEntityMachineDiesel;
|
||||
import com.hbm.tileentity.TileEntityMachineElectricFurnace;
|
||||
import com.hbm.tileentity.TileEntityMachineFluidTank;
|
||||
import com.hbm.tileentity.TileEntityMachineGasFlare;
|
||||
import com.hbm.tileentity.TileEntityMachineGenerator;
|
||||
import com.hbm.tileentity.TileEntityMachinePuF6Tank;
|
||||
import com.hbm.tileentity.TileEntityMachineRTG;
|
||||
import com.hbm.tileentity.TileEntityMachineReactor;
|
||||
import com.hbm.tileentity.TileEntityMachineRefinery;
|
||||
import com.hbm.tileentity.TileEntityMachineSchrabidiumTransmutator;
|
||||
import com.hbm.tileentity.TileEntityMachineShredder;
|
||||
import com.hbm.tileentity.TileEntityMachineTeleporter;
|
||||
import com.hbm.tileentity.TileEntityMachineUF6Tank;
|
||||
import com.hbm.tileentity.TileEntityNukeBoy;
|
||||
import com.hbm.tileentity.TileEntityNukeCustom;
|
||||
import com.hbm.tileentity.TileEntityNukeFleija;
|
||||
import com.hbm.tileentity.TileEntityNukeFurnace;
|
||||
import com.hbm.tileentity.TileEntityNukeGadget;
|
||||
import com.hbm.tileentity.TileEntityNukeMan;
|
||||
import com.hbm.tileentity.TileEntityNukeMike;
|
||||
import com.hbm.tileentity.TileEntityNukePrototype;
|
||||
import com.hbm.tileentity.TileEntityNukeTsar;
|
||||
import com.hbm.tileentity.TileEntityReactorMultiblock;
|
||||
import com.hbm.tileentity.TileEntityReiXMainframe;
|
||||
import com.hbm.tileentity.TileEntityRtgFurnace;
|
||||
import com.hbm.tileentity.TileEntityTestNuke;
|
||||
import com.hbm.tileentity.TileEntityWatzCore;
|
||||
import com.hbm.tileentity.*;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@ -534,6 +395,14 @@ public class GUIHandler implements IGuiHandler {
|
||||
return new ContainerMachineFluidTank(player.inventory, (TileEntityMachineFluidTank) entity);
|
||||
}
|
||||
}
|
||||
|
||||
case ModBlocks.guiID_machine_pumpjack:
|
||||
{
|
||||
if(entity instanceof TileEntityMachinePumpjack)
|
||||
{
|
||||
return new ContainerMachinePumpjack(player.inventory, (TileEntityMachinePumpjack) entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -922,6 +791,14 @@ public class GUIHandler implements IGuiHandler {
|
||||
return new GUIMachineFluidTank(player.inventory, (TileEntityMachineFluidTank) entity);
|
||||
}
|
||||
}
|
||||
|
||||
case ModBlocks.guiID_machine_pumpjack:
|
||||
{
|
||||
if(entity instanceof TileEntityMachinePumpjack)
|
||||
{
|
||||
return new GUIMachinePumpjack(player.inventory, (TileEntityMachinePumpjack) entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//CLIENTONLY GUIS
|
||||
|
||||
@ -59,6 +59,10 @@ public class MultiblockHandler {
|
||||
public static final int[] fluidTankDimensionNS = new int[] { 1, 1, 2, 0, 2, 2 };
|
||||
public static final int[] fluidTankDimensionEW = new int[] { 2, 2, 2, 0, 1, 1 };
|
||||
public static final int[] refineryDimensions = new int[] { 1, 1, 9, 0, 1, 1 };
|
||||
public static final int[] pumpjackDimensionNorth = new int[] { 1, 1, 4, 0, 5, 0 };
|
||||
public static final int[] pumpjackDimensionEast = new int[] { 0, 5, 4, 0, 1, 1 };
|
||||
public static final int[] pumpjackDimensionSouth = new int[] { 1, 1, 4, 0, 0, 5 };
|
||||
public static final int[] pumpjackDimensionWest = new int[] { 5, 0, 4, 0, 1, 1 };
|
||||
|
||||
//Approved!
|
||||
public static boolean checkSpace(World world, int x, int y, int z, int[] i) {
|
||||
|
||||
146
com/hbm/inventory/container/ContainerMachinePumpjack.java
Normal file
146
com/hbm/inventory/container/ContainerMachinePumpjack.java
Normal file
@ -0,0 +1,146 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotMachineOutput;
|
||||
import com.hbm.tileentity.TileEntityMachineOilWell;
|
||||
import com.hbm.tileentity.TileEntityMachinePumpjack;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerMachinePumpjack extends Container {
|
||||
|
||||
private TileEntityMachinePumpjack testNuke;
|
||||
private int power;
|
||||
private int warning;
|
||||
private int warning2;
|
||||
|
||||
public ContainerMachinePumpjack(InventoryPlayer invPlayer, TileEntityMachinePumpjack tedf) {
|
||||
power = 0;
|
||||
warning = 0;
|
||||
warning2 = 0;
|
||||
|
||||
testNuke = tedf;
|
||||
|
||||
//Battery
|
||||
this.addSlotToContainer(new Slot(tedf, 0, 44, 54));
|
||||
//Canister Input
|
||||
this.addSlotToContainer(new Slot(tedf, 1, 134, 18));
|
||||
//Canister Output
|
||||
this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 2, 134, 54));
|
||||
//Gas Input
|
||||
this.addSlotToContainer(new Slot(tedf, 3, 134, 72));
|
||||
//Gas Output
|
||||
this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 4, 134, 108));
|
||||
//Chip
|
||||
this.addSlotToContainer(new Slot(tedf, 5, 8, 90));
|
||||
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
for(int j = 0; j < 9; j++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18 + 56));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142 + 56));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting crafting) {
|
||||
super.addCraftingToCrafters(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 0, this.testNuke.power);
|
||||
crafting.sendProgressBarUpdate(this, 1, this.testNuke.warning);
|
||||
crafting.sendProgressBarUpdate(this, 2, this.testNuke.warning2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2)
|
||||
{
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if (var4 != null && var4.getHasStack())
|
||||
{
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if (par2 <= 5) {
|
||||
if (!this.mergeItemStack(var5, 6, this.inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(var5, 0, 2, false))
|
||||
{
|
||||
if (!this.mergeItemStack(var5, 3, 4, false))
|
||||
if (!this.mergeItemStack(var5, 5, 6, false))
|
||||
return null;
|
||||
}
|
||||
|
||||
if (var5.stackSize == 0)
|
||||
{
|
||||
var4.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return testNuke.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for(int i = 0; i < this.crafters.size(); i++)
|
||||
{
|
||||
ICrafting par1 = (ICrafting)this.crafters.get(i);
|
||||
if(this.power != this.testNuke.power)
|
||||
{
|
||||
par1.sendProgressBarUpdate(this, 0, this.testNuke.power);
|
||||
}
|
||||
if(this.warning != this.testNuke.warning)
|
||||
{
|
||||
par1.sendProgressBarUpdate(this, 1, this.testNuke.warning);
|
||||
}
|
||||
if(this.warning2 != this.testNuke.warning2)
|
||||
{
|
||||
par1.sendProgressBarUpdate(this, 2, this.testNuke.warning2);
|
||||
}
|
||||
}
|
||||
|
||||
this.power = this.testNuke.power;
|
||||
this.warning = this.testNuke.warning;
|
||||
this.warning2 = this.testNuke.warning2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int i, int j) {
|
||||
if(i == 0)
|
||||
{
|
||||
testNuke.power = j;
|
||||
}
|
||||
if(i == 1)
|
||||
{
|
||||
testNuke.warning = j;
|
||||
}
|
||||
if(i == 2)
|
||||
{
|
||||
testNuke.warning2 = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
77
com/hbm/inventory/gui/GUIMachinePumpjack.java
Normal file
77
com/hbm/inventory/gui/GUIMachinePumpjack.java
Normal file
@ -0,0 +1,77 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.FluidTank;
|
||||
import com.hbm.inventory.container.ContainerMachineOilWell;
|
||||
import com.hbm.inventory.container.ContainerMachinePumpjack;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.TileEntityMachineOilWell;
|
||||
import com.hbm.tileentity.TileEntityMachinePumpjack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIMachinePumpjack extends GuiFluidContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_well_large.png");
|
||||
private TileEntityMachinePumpjack derrick;
|
||||
|
||||
public GUIMachinePumpjack(InventoryPlayer invPlayer, TileEntityMachinePumpjack tedf) {
|
||||
super(new ContainerMachinePumpjack(invPlayer, tedf));
|
||||
derrick = tedf;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 222;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||
super.drawScreen(mouseX, mouseY, f);
|
||||
|
||||
derrick.tanks[0].renderTankInfo(this, mouseX, mouseY, guiLeft + 80, guiTop + 70 - 52, 34, 52);
|
||||
derrick.tanks[1].renderTankInfo(this, mouseX, mouseY, guiLeft + 80, guiTop + 124 - 52, 34, 52);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer( int i, int j) {
|
||||
String name = this.derrick.hasCustomInventoryName() ? this.derrick.getInventoryName() : I18n.format(this.derrick.getInventoryName());
|
||||
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
int i = derrick.getPowerScaled(52);
|
||||
drawTexturedModalRect(guiLeft + 8, guiTop + 70 - i, 176, 52 - i, 16, i);
|
||||
|
||||
int k = derrick.warning;
|
||||
if(k == 2)
|
||||
drawTexturedModalRect(guiLeft + 44, guiTop + 18, 176, 52, 16, 16);
|
||||
if(k == 1)
|
||||
drawTexturedModalRect(guiLeft + 44, guiTop + 18, 192, 52, 16, 16);
|
||||
|
||||
int l = derrick.warning2;
|
||||
if(l == 1)
|
||||
drawTexturedModalRect(guiLeft + 44, guiTop + 90, 208, 52, 16, 16);
|
||||
if(l == 2)
|
||||
drawTexturedModalRect(guiLeft + 44, guiTop + 90, 224, 52, 16, 16);
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(FluidTank.fluidTextures);
|
||||
|
||||
derrick.tanks[0].renderTank(this, guiLeft + 80, guiTop + 70, derrick.tanks[0].getTankType().textureX() * FluidTank.x, derrick.tanks[0].getTankType().textureY() * FluidTank.y, 16, 52);
|
||||
derrick.tanks[0].renderTank(this, guiLeft + 96, guiTop + 70, derrick.tanks[0].getTankType().textureX() * FluidTank.x, derrick.tanks[0].getTankType().textureY() * FluidTank.y, 16, 52);
|
||||
derrick.tanks[0].renderTank(this, guiLeft + 112, guiTop + 70, derrick.tanks[0].getTankType().textureX() * FluidTank.x, derrick.tanks[0].getTankType().textureY() * FluidTank.y, 2, 52);
|
||||
derrick.tanks[1].renderTank(this, guiLeft + 80, guiTop + 124, derrick.tanks[1].getTankType().textureX() * FluidTank.x, derrick.tanks[1].getTankType().textureY() * FluidTank.y, 16, 52);
|
||||
derrick.tanks[1].renderTank(this, guiLeft + 96, guiTop + 124, derrick.tanks[1].getTankType().textureX() * FluidTank.x, derrick.tanks[1].getTankType().textureY() * FluidTank.y, 16, 52);
|
||||
derrick.tanks[1].renderTank(this, guiLeft + 112, guiTop + 124, derrick.tanks[1].getTankType().textureX() * FluidTank.x, derrick.tanks[1].getTankType().textureY() * FluidTank.y, 2, 52);
|
||||
}
|
||||
}
|
||||
@ -43,6 +43,8 @@ public class PacketDispatcher {
|
||||
wrapper.registerMessage(TETurretPacket.Handler.class, TETurretPacket.class, i++, Side.CLIENT);
|
||||
//Signals server to consume items and create template
|
||||
wrapper.registerMessage(ItemFolderPacket.Handler.class, ItemFolderPacket.class, i++, Side.SERVER);
|
||||
//Pumpjack rotation for animation rendering
|
||||
wrapper.registerMessage(TEPumpjackPacket.Handler.class, TEPumpjackPacket.class, i++, Side.CLIENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
68
com/hbm/packet/TEPumpjackPacket.java
Normal file
68
com/hbm/packet/TEPumpjackPacket.java
Normal file
@ -0,0 +1,68 @@
|
||||
package com.hbm.packet;
|
||||
|
||||
import com.hbm.tileentity.TileEntityMachineAssembler;
|
||||
import com.hbm.tileentity.TileEntityMachinePumpjack;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TEPumpjackPacket implements IMessage {
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
int spin;
|
||||
boolean progress;
|
||||
|
||||
public TEPumpjackPacket()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public TEPumpjackPacket(int x, int y, int z, int spin, boolean bool)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.spin = spin;
|
||||
this.progress = bool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
spin = buf.readInt();
|
||||
progress = buf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeInt(spin);
|
||||
buf.writeBoolean(progress);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<TEPumpjackPacket, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(TEPumpjackPacket m, MessageContext ctx) {
|
||||
TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(m.x, m.y, m.z);
|
||||
|
||||
if (te != null && te instanceof TileEntityMachinePumpjack) {
|
||||
|
||||
TileEntityMachinePumpjack gen = (TileEntityMachinePumpjack) te;
|
||||
gen.rotation = m.spin;
|
||||
gen.isProgressing = m.progress;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.ResourceManager;
|
||||
import com.hbm.tileentity.TileEntityMachinePumpjack;
|
||||
import com.hbm.tileentity.TileEntityTurretBase;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
@ -17,17 +18,28 @@ public class RenderPumpjack extends TileEntitySpecialRenderer {
|
||||
|
||||
private ResourceLocation gadgetTexture = new ResourceLocation(RefStrings.MODID, "textures/models/TheGadget3_.png");
|
||||
|
||||
int i = 0;
|
||||
int i;
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f)
|
||||
{
|
||||
i += 2;
|
||||
if(i >= 360)
|
||||
i-= 360;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5D, y, z + 0.5D);
|
||||
GL11.glTranslated(x + 0.5, y, z + 0.5);
|
||||
switch(tileEntity.getBlockMetadata())
|
||||
{
|
||||
case 2:
|
||||
GL11.glRotatef(0, 0F, 1F, 0F); break;
|
||||
case 4:
|
||||
GL11.glRotatef(90, 0F, 1F, 0F); break;
|
||||
case 3:
|
||||
GL11.glRotatef(180, 0F, 1F, 0F); break;
|
||||
case 5:
|
||||
GL11.glRotatef(270, 0F, 1F, 0F); break;
|
||||
}
|
||||
|
||||
if(tileEntity instanceof TileEntityMachinePumpjack)
|
||||
i= ((TileEntityMachinePumpjack)tileEntity).rotation;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glRotatef(180, 0F, 1F, 0F);
|
||||
@ -37,13 +49,12 @@ public class RenderPumpjack extends TileEntitySpecialRenderer {
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
renderTileEntityAt2(tileEntity, x, y, z, f);
|
||||
renderTileEntityAt2();
|
||||
}
|
||||
|
||||
public void renderTileEntityAt2(TileEntity tileEntity, double x, double y, double z, float f)
|
||||
public void renderTileEntityAt2()
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5D, y, z + 0.5D);
|
||||
GL11.glTranslated(0, 1.5, 5.5);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
@ -51,17 +62,18 @@ public class RenderPumpjack extends TileEntitySpecialRenderer {
|
||||
|
||||
this.bindTexture(gadgetTexture);
|
||||
GL11.glRotated(i - 90, 1F, 0F, 0F);
|
||||
|
||||
ResourceManager.pumpjack_rotor.renderAll();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
renderTileEntityAt3(tileEntity, x, y, z, f);
|
||||
renderTileEntityAt3();
|
||||
}
|
||||
|
||||
public void renderTileEntityAt3(TileEntity tileEntity, double x, double y, double z, float f)
|
||||
public void renderTileEntityAt3()
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5D, y + 1, z + 0.5D);
|
||||
GL11.glTranslated(0, 1, 0);
|
||||
GL11.glTranslated(0, 2.5, 2.5);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
@ -74,13 +86,13 @@ public class RenderPumpjack extends TileEntitySpecialRenderer {
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
renderTileEntityAt4(tileEntity, x, y, z, f);
|
||||
renderTileEntityAt4();
|
||||
}
|
||||
|
||||
public void renderTileEntityAt4(TileEntity tileEntity, double x, double y, double z, float f)
|
||||
public void renderTileEntityAt4()
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5D, y + 1, z + 0.5D);
|
||||
GL11.glTranslated(0, 1, 0);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glRotatef(180, 0F, 1F, 0F);
|
||||
@ -94,6 +106,7 @@ public class RenderPumpjack extends TileEntitySpecialRenderer {
|
||||
drawConnection(-0.55, 0.5 + t, -5.5 - u, -0.55, 2.5 + v, -2.5 - w);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void drawConnection(double x, double y, double z, double a, double b, double c) {
|
||||
|
||||
@ -1,7 +1,524 @@
|
||||
package com.hbm.tileentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.entity.particle.EntityGasFX;
|
||||
import com.hbm.explosion.ExplosionLarge;
|
||||
import com.hbm.handler.FluidTypeHandler.FluidType;
|
||||
import com.hbm.interfaces.IConsumer;
|
||||
import com.hbm.interfaces.IFluidAcceptor;
|
||||
import com.hbm.interfaces.IFluidContainer;
|
||||
import com.hbm.interfaces.IFluidSource;
|
||||
import com.hbm.inventory.FluidTank;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.special.ItemBattery;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.TEAssemblerPacket;
|
||||
import com.hbm.packet.TEPumpjackPacket;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class TileEntityMachinePumpjack extends TileEntity {
|
||||
public class TileEntityMachinePumpjack extends TileEntity implements ISidedInventory, IConsumer, IFluidContainer, IFluidSource {
|
||||
|
||||
private ItemStack slots[];
|
||||
|
||||
public int power;
|
||||
public int warning;
|
||||
public int warning2;
|
||||
public static final int maxPower = 100000;
|
||||
public int age = 0;
|
||||
public int age2 = 0;
|
||||
public List<IFluidAcceptor> list1 = new ArrayList();
|
||||
public List<IFluidAcceptor> list2 = new ArrayList();
|
||||
public FluidTank[] tanks;
|
||||
public boolean isProgressing;
|
||||
public int rotation;
|
||||
|
||||
private static final int[] slots_top = new int[] {1};
|
||||
private static final int[] slots_bottom = new int[] {2, 0};
|
||||
private static final int[] slots_side = new int[] {0};
|
||||
Random rand = new Random();
|
||||
|
||||
private String customName;
|
||||
|
||||
public TileEntityMachinePumpjack() {
|
||||
slots = new ItemStack[6];
|
||||
tanks = new FluidTank[2];
|
||||
tanks[0] = new FluidTank(FluidType.OIL, 128000, 0);
|
||||
tanks[1] = new FluidTank(FluidType.GAS, 128000, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return slots.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return slots[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
if(slots[i] != null)
|
||||
{
|
||||
ItemStack itemStack = slots[i];
|
||||
slots[i] = null;
|
||||
return itemStack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemStack) {
|
||||
slots[i] = itemStack;
|
||||
if(itemStack != null && itemStack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemStack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return this.hasCustomInventoryName() ? this.customName : "container.oilWell";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return this.customName != null && this.customName.length() > 0;
|
||||
}
|
||||
|
||||
public void setCustomName(String name) {
|
||||
this.customName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
if(worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
|
||||
{
|
||||
return false;
|
||||
}else{
|
||||
return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <=128;
|
||||
}
|
||||
}
|
||||
|
||||
//You scrubs aren't needed for anything (right now)
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
|
||||
if(i == 0)
|
||||
if(itemStack.getItem() instanceof ItemBattery)
|
||||
return true;
|
||||
|
||||
if(i == 1)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
if(slots[i] != null)
|
||||
{
|
||||
if(slots[i].stackSize <= j)
|
||||
{
|
||||
ItemStack itemStack = slots[i];
|
||||
slots[i] = null;
|
||||
return itemStack;
|
||||
}
|
||||
ItemStack itemStack1 = slots[i].splitStack(j);
|
||||
if (slots[i].stackSize == 0)
|
||||
{
|
||||
slots[i] = null;
|
||||
}
|
||||
|
||||
return itemStack1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
NBTTagList list = nbt.getTagList("items", 10);
|
||||
|
||||
this.power = nbt.getInteger("powerTime");
|
||||
this.age = nbt.getInteger("age");
|
||||
|
||||
this.tanks[0].readFromNBT(nbt, "oil");
|
||||
this.tanks[1].readFromNBT(nbt, "gas");
|
||||
|
||||
slots = new ItemStack[getSizeInventory()];
|
||||
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbt1 = list.getCompoundTagAt(i);
|
||||
byte b0 = nbt1.getByte("slot");
|
||||
if(b0 >= 0 && b0 < slots.length)
|
||||
{
|
||||
slots[b0] = ItemStack.loadItemStackFromNBT(nbt1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("powerTime", power);
|
||||
nbt.setInteger("age", age);
|
||||
|
||||
this.tanks[0].writeToNBT(nbt, "oil");
|
||||
this.tanks[1].writeToNBT(nbt, "gas");
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for(int i = 0; i < slots.length; i++)
|
||||
{
|
||||
if(slots[i] != null)
|
||||
{
|
||||
NBTTagCompound nbt1 = new NBTTagCompound();
|
||||
nbt1.setByte("slot", (byte)i);
|
||||
slots[i].writeToNBT(nbt1);
|
||||
list.appendTag(nbt1);
|
||||
}
|
||||
}
|
||||
nbt.setTag("items", list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int p_94128_1_)
|
||||
{
|
||||
return p_94128_1_ == 0 ? slots_bottom : (p_94128_1_ == 1 ? slots_top : slots_side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemStack, int j) {
|
||||
return this.isItemValidForSlot(i, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemStack, int j) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getPowerScaled(int i) {
|
||||
return (power * i) / maxPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
int timer = 20;
|
||||
|
||||
age++;
|
||||
age2++;
|
||||
if(age >= timer)
|
||||
age -= timer;
|
||||
if(age2 >= 20)
|
||||
age2 -= 20;
|
||||
if(age2 == 9 || age2 == 19) {
|
||||
fillFluidInit(tanks[0].getTankType());
|
||||
fillFluidInit(tanks[1].getTankType());
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
this.tanks[0].unloadTank(1, 2, slots);
|
||||
this.tanks[1].unloadTank(3, 4, slots);
|
||||
|
||||
for(int i = 0; i < 2; i++) {
|
||||
tanks[i].updateTank(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
power = Library.chargeTEFromItems(slots, 0, power, maxPower);
|
||||
|
||||
if(power >= 200) {
|
||||
|
||||
//operation start
|
||||
|
||||
if(age == timer - 1) {
|
||||
warning = 0;
|
||||
|
||||
//warning 0, green: derrick is operational
|
||||
//warning 1, red: derrick is full, has no power or the drill is jammed
|
||||
//warning 2, yellow: drill has reached max depth
|
||||
|
||||
for(int i = this.yCoord - 1; i > this.yCoord - 1 - 100; i--) {
|
||||
|
||||
if(i <= 5) {
|
||||
//Code 2: The drilling ended
|
||||
warning = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
Block b = worldObj.getBlock(this.xCoord, i, this.zCoord);
|
||||
if(b == ModBlocks.oil_pipe)
|
||||
continue;
|
||||
|
||||
if(b == Blocks.air || b == Blocks.grass || b == Blocks.dirt ||
|
||||
b == Blocks.stone || b == Blocks.sand || b == Blocks.sandstone ||
|
||||
b == Blocks.clay || b == Blocks.hardened_clay || b == Blocks.stained_hardened_clay ||
|
||||
b == Blocks.gravel || isOre(b, worldObj.getBlockMetadata(xCoord, i, zCoord)) ||
|
||||
b.isReplaceable(worldObj, xCoord, i, zCoord)) {
|
||||
worldObj.setBlock(xCoord, i, zCoord, ModBlocks.oil_pipe);
|
||||
|
||||
//Code 2: The drilling ended
|
||||
if(i == this.yCoord - 100)
|
||||
warning = 2;
|
||||
break;
|
||||
|
||||
} else if((b == ModBlocks.ore_oil || b == ModBlocks.ore_oil_empty) && this.tanks[0].getFill() < this.tanks[0].getMaxFill() && this.tanks[1].getFill() < this.tanks[1].getMaxFill()) {
|
||||
if(succ(this.xCoord, i, this.zCoord)) {
|
||||
|
||||
this.tanks[0].setFill(this.tanks[0].getFill() + 650);
|
||||
if(this.tanks[0].getFill() > this.tanks[0].getMaxFill())
|
||||
this.tanks[0].setFill(tanks[0].getMaxFill());
|
||||
|
||||
|
||||
this.tanks[1].setFill(this.tanks[1].getFill() + (100 + rand.nextInt(301)));
|
||||
if(this.tanks[1].getFill() > this.tanks[1].getMaxFill())
|
||||
this.tanks[1].setFill(tanks[1].getMaxFill());
|
||||
|
||||
break;
|
||||
} else {
|
||||
worldObj.setBlock(xCoord, i, zCoord, ModBlocks.oil_pipe);
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
//Code 1: Drill jammed
|
||||
warning = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//operation end
|
||||
|
||||
power -= 200;
|
||||
} else {
|
||||
warning = 1;
|
||||
}
|
||||
|
||||
warning2 = 0;
|
||||
if(tanks[1].getFill() > 0) {
|
||||
if(slots[5] != null && (slots[5].getItem() == ModItems.fuse || slots[5].getItem() == ModItems.screwdriver)) {
|
||||
warning2 = 2;
|
||||
tanks[1].setFill(tanks[1].getFill() - 50);
|
||||
if(tanks[1].getFill() <= 0)
|
||||
tanks[1].setFill(0);
|
||||
worldObj.spawnEntityInWorld(new EntityGasFX(worldObj, this.xCoord + 0.5F, this.yCoord + 0.5F, this.zCoord + 0.5F, 0.0, 0.0, 0.0));
|
||||
} else {
|
||||
warning2 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
isProgressing = warning == 0;
|
||||
rotation += (warning == 0 ? 5 : 0);
|
||||
rotation = rotation % 360;
|
||||
|
||||
PacketDispatcher.wrapper.sendToAll(new TEPumpjackPacket(xCoord, yCoord, zCoord, rotation, isProgressing));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isOre(Block b, int meta) {
|
||||
|
||||
int[] ids = OreDictionary.getOreIDs(new ItemStack(b, 1, meta));
|
||||
|
||||
for(int i = 0; i < ids.length; i++) {
|
||||
|
||||
String s = OreDictionary.getOreName(ids[i]);
|
||||
|
||||
if(s.length() > 3 && s.substring(0, 3).equals("ore"))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean succ(int x, int y, int z) {
|
||||
|
||||
list.clear();
|
||||
|
||||
succ1(x, y, z);
|
||||
succ2(x, y, z);
|
||||
|
||||
if(!list.isEmpty()) {
|
||||
|
||||
int i = rand.nextInt(list.size());
|
||||
int a = list.get(i)[0];
|
||||
int b = list.get(i)[1];
|
||||
int c = list.get(i)[2];
|
||||
|
||||
if(worldObj.getBlock(a, b, c) == ModBlocks.ore_oil) {
|
||||
|
||||
worldObj.setBlock(a, b, c, ModBlocks.ore_oil_empty);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void succInit1(int x, int y, int z) {
|
||||
succ1(x + 1, y, z);
|
||||
succ1(x - 1, y, z);
|
||||
succ1(x, y + 1, z);
|
||||
succ1(x, y - 1, z);
|
||||
succ1(x, y, z + 1);
|
||||
succ1(x, y, z - 1);
|
||||
}
|
||||
|
||||
public void succInit2(int x, int y, int z) {
|
||||
succ2(x + 1, y, z);
|
||||
succ2(x - 1, y, z);
|
||||
succ2(x, y + 1, z);
|
||||
succ2(x, y - 1, z);
|
||||
succ2(x, y, z + 1);
|
||||
succ2(x, y, z - 1);
|
||||
}
|
||||
|
||||
List<int[]> list = new ArrayList<int[]>();
|
||||
|
||||
public void succ1(int x, int y, int z) {
|
||||
if(worldObj.getBlock(x, y, z) == ModBlocks.ore_oil_empty &&
|
||||
worldObj.getBlockMetadata(x, y, z) == 0) {
|
||||
worldObj.setBlockMetadataWithNotify(x, y, z, 1, 2);
|
||||
succInit1(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
public void succ2(int x, int y, int z) {
|
||||
if(worldObj.getBlock(x, y, z) == ModBlocks.ore_oil_empty &&
|
||||
worldObj.getBlockMetadata(x, y, z) == 1) {
|
||||
worldObj.setBlockMetadataWithNotify(x, y, z, 0, 2);
|
||||
succInit2(x, y, z);
|
||||
} else if(worldObj.getBlock(x, y, z) == ModBlocks.ore_oil) {
|
||||
list.add(new int[] { x, y, z });
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(int i) {
|
||||
power = i;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPower() {
|
||||
return power;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPower() {
|
||||
return maxPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
return TileEntity.INFINITE_EXTENT_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public double getMaxRenderDistanceSquared()
|
||||
{
|
||||
return 65536.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getTact() {
|
||||
if (age2 >= 0 && age2 < 10) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillFluidInit(FluidType type) {
|
||||
fillFluid(this.xCoord - 2, this.yCoord, this.zCoord, getTact(), type);
|
||||
fillFluid(this.xCoord + 2, this.yCoord, this.zCoord, getTact(), type);
|
||||
fillFluid(this.xCoord, this.yCoord, this.zCoord - 2, getTact(), type);
|
||||
fillFluid(this.xCoord, this.yCoord, this.zCoord + 2, getTact(), type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillFluid(int x, int y, int z, boolean newTact, FluidType type) {
|
||||
Library.transmitFluid(x, y, z, newTact, this, worldObj, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSFluidFill(FluidType type) {
|
||||
if(type.name().equals(tanks[0].getTankType().name()))
|
||||
return tanks[0].getFill();
|
||||
else if(type.name().equals(tanks[1].getTankType().name()))
|
||||
return tanks[1].getFill();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSFluidFill(int i, FluidType type) {
|
||||
if(type.name().equals(tanks[0].getTankType().name()))
|
||||
tanks[0].setFill(i);
|
||||
else if(type.name().equals(tanks[1].getTankType().name()))
|
||||
tanks[1].setFill(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IFluidAcceptor> getFluidList(FluidType type) {
|
||||
if(type.name().equals(tanks[0].getTankType().name()))
|
||||
return this.list1;
|
||||
if(type.name().equals(tanks[1].getTankType().name()))
|
||||
return this.list2;
|
||||
return new ArrayList<IFluidAcceptor>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearFluidList(FluidType type) {
|
||||
if(type.name().equals(tanks[0].getTankType().name()))
|
||||
list1.clear();
|
||||
if(type.name().equals(tanks[1].getTankType().name()))
|
||||
list2.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFillstate(int fill, int index) {
|
||||
if(index < 2 && tanks[index] != null)
|
||||
tanks[index].setFill(fill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(FluidType type, int index) {
|
||||
if(index < 2 && tanks[index] != null)
|
||||
tanks[index].setTankType(type);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user