mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
core strand caster stuffs
This commit is contained in:
parent
11f4b55a9d
commit
9ad76d3bcc
189
src/main/java/com/hbm/blocks/machine/MachineStrandCaster.java
Normal file
189
src/main/java/com/hbm/blocks/machine/MachineStrandCaster.java
Normal file
@ -0,0 +1,189 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import api.hbm.block.ICrucibleAcceptor;
|
||||
import api.hbm.block.IToolable;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.handler.MultiblockHandlerXR;
|
||||
import com.hbm.inventory.material.Mats;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemMold;
|
||||
import com.hbm.items.machine.ItemScraps;
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
import com.hbm.tileentity.machine.TileEntityCrucible;
|
||||
import com.hbm.tileentity.machine.TileEntityFoundryCastingBase;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineStrandCaster;
|
||||
import com.hbm.util.I18nUtil;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class MachineStrandCaster extends BlockDummyable implements ICrucibleAcceptor, ILookOverlay {
|
||||
|
||||
public MachineStrandCaster() {
|
||||
super(Material.iron);
|
||||
}
|
||||
//reminder, if the machine is a solid brick, get dimensions will already handle it without the need to use fillSapce
|
||||
//the order is up, down, forward, backward, left, right
|
||||
//x is for left(-)/right(+), z is for forward(+)/backward(-), y you already know
|
||||
@Override
|
||||
public int[] getDimensions() {return new int[]{0, 0, 6, 0, 1, 0};}
|
||||
|
||||
@Override
|
||||
public int getOffset() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
|
||||
if(meta >= 12) return new TileEntityMachineStrandCaster();
|
||||
if(meta >= 6) return new TileEntityProxyCombo(true, false, true).moltenMetal();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
|
||||
super.fillSpace(world, x, y, z, dir, o);
|
||||
|
||||
x += dir.offsetX * o;
|
||||
z += dir.offsetZ * o;
|
||||
|
||||
MultiblockHandlerXR.fillSpace(world, x, y, z, new int[]{1, 0, 1, 0, 1, 0}, this, dir);
|
||||
|
||||
this.makeExtra(world, x - dir.offsetX, y, z);
|
||||
this.makeExtra(world, x, y, z + dir.offsetX * 5);
|
||||
this.makeExtra(world, x- dir.offsetX, y, z + dir.offsetX * 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, Mats.MaterialStack stack) {
|
||||
|
||||
TileEntity poured = world.getTileEntity(x, y, z);
|
||||
if(!(poured instanceof TileEntityProxyCombo && ((TileEntityProxyCombo)poured).moltenMetal)) return false;
|
||||
|
||||
int[] pos = this.findCore(world, x, y, z);
|
||||
if(pos == null) return false;
|
||||
TileEntity tile = world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
if(!(tile instanceof TileEntityMachineStrandCaster)) return false;
|
||||
TileEntityMachineStrandCaster caster = (TileEntityMachineStrandCaster) tile;
|
||||
|
||||
return caster.canAcceptPartialPour(world, x, y, z, dX, dY, dZ, side, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mats.MaterialStack pour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, Mats.MaterialStack stack) {
|
||||
|
||||
TileEntity poured = world.getTileEntity(x, y, z);
|
||||
if(!(poured instanceof TileEntityProxyCombo && ((TileEntityProxyCombo)poured).moltenMetal)) return stack;
|
||||
|
||||
int[] pos = this.findCore(world, x, y, z);
|
||||
if(pos == null) return stack;
|
||||
TileEntity tile = world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
if(!(tile instanceof TileEntityMachineStrandCaster)) return stack;
|
||||
TileEntityMachineStrandCaster caster = (TileEntityMachineStrandCaster) tile;
|
||||
|
||||
return caster.pour(world, x, y, z, dX, dY, dZ, side, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptPartialFlow(World world, int x, int y, int z, ForgeDirection side, Mats.MaterialStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mats.MaterialStack flow(World world, int x, int y, int z, ForgeDirection side, Mats.MaterialStack stack) {
|
||||
return null;
|
||||
}
|
||||
///entirety of foundry base code here, because dual inheritance is evil apparently
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
TileEntityFoundryCastingBase cast = (TileEntityFoundryCastingBase) world.getTileEntity(x, y, z);
|
||||
|
||||
//insert mold
|
||||
if(player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.mold && cast.slots[0] == null) {
|
||||
cast.slots[0] = player.getHeldItem().copy();
|
||||
cast.slots[0].stackSize = 1;
|
||||
player.getHeldItem().stackSize--;
|
||||
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "hbm:item.upgradePlug", 1.0F, 1.0F);
|
||||
cast.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemTool && player.getHeldItem().getItem().getToolClasses(player.getHeldItem()).contains("shovel")) {
|
||||
if(cast.amount > 0) {
|
||||
ItemStack scrap = ItemScraps.create(new Mats.MaterialStack(cast.type, cast.amount));
|
||||
if(!player.inventory.addItemStackToInventory(scrap)) {
|
||||
EntityItem item = new EntityItem(world, x + 0.5, y + this.maxY, z + 0.5, scrap);
|
||||
world.spawnEntityInWorld(item);
|
||||
} else {
|
||||
player.inventoryContainer.detectAndSendChanges();
|
||||
}
|
||||
cast.amount = 0;
|
||||
cast.type = null;
|
||||
cast.markDirty();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.standardOpenBehavior(world, x, y, z, player, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block b, int i) {
|
||||
|
||||
TileEntityFoundryCastingBase cast = (TileEntityFoundryCastingBase) world.getTileEntity(x, y, z);
|
||||
if(cast.amount > 0) {
|
||||
ItemStack scrap = ItemScraps.create(new Mats.MaterialStack(cast.type, cast.amount));
|
||||
EntityItem item = new EntityItem(world, x + 0.5, y + this.maxY, z + 0.5, scrap);
|
||||
world.spawnEntityInWorld(item);
|
||||
cast.amount = 0; //just for safety
|
||||
}
|
||||
|
||||
for(ItemStack stack : cast.slots) {
|
||||
if(stack != null) {
|
||||
EntityItem drop = new EntityItem(world, x + 0.5, y + this.maxY, z + 0.5, stack.copy());
|
||||
world.spawnEntityInWorld(drop);
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(world, x, y, z, b, i);
|
||||
}
|
||||
|
||||
public void printHook(RenderGameOverlayEvent.Pre event, World world, int x, int y, int z) {
|
||||
TileEntityFoundryCastingBase cast = (TileEntityFoundryCastingBase) world.getTileEntity(x, y, z);
|
||||
List<String> text = new ArrayList();
|
||||
|
||||
if(cast.slots[0] == null) {
|
||||
text.add(EnumChatFormatting.RED + I18nUtil.resolveKey("foundry.noCast"));
|
||||
} else if(cast.slots[0].getItem() == ModItems.mold){
|
||||
ItemMold.Mold mold = ((ItemMold) cast.slots[0].getItem()).getMold(cast.slots[0]);
|
||||
text.add(EnumChatFormatting.BLUE + mold.getTitle());
|
||||
}
|
||||
|
||||
ILookOverlay.printGeneric(event, I18nUtil.resolveKey(this.getUnlocalizedName() + ".name"), 0xFF4000, 0x401000, text);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,74 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotNonRetarded;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineStrandCaster;
|
||||
import com.hbm.util.InventoryUtil;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerStrandCaster extends Container {
|
||||
|
||||
protected TileEntityMachineStrandCaster caster;
|
||||
|
||||
public ContainerStrandCaster(InventoryPlayer invPlayer, TileEntityMachineStrandCaster caster) {
|
||||
this.caster = caster;
|
||||
|
||||
//the wretched mold
|
||||
this.addSlotToContainer(new SlotNonRetarded(this.caster, 0, 57, 62));
|
||||
|
||||
//input
|
||||
for(int i = 0; i < 3; i++) {
|
||||
for(int j = 0; j < 2; j++) {
|
||||
this.addSlotToContainer(new SlotNonRetarded(this.caster, j + i * 3 + 1, 125 + j * 18, 26 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
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, 132 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 190));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
||||
ItemStack stack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(index);
|
||||
|
||||
if(slot != null && slot.getHasStack()) {
|
||||
ItemStack originalStack = slot.getStack();
|
||||
stack = originalStack.copy();
|
||||
|
||||
if(index <= 6) {
|
||||
if(!this.mergeItemStack(originalStack, 10, this.inventorySlots.size(), true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onSlotChange(originalStack, stack);
|
||||
|
||||
} else if(!InventoryUtil.mergeItemStack(this.inventorySlots, originalStack, 0, 10, false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(originalStack.stackSize == 0) {
|
||||
slot.putStack((ItemStack) null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return caster.isUseableByPlayer(player);
|
||||
}
|
||||
}
|
||||
102
src/main/java/com/hbm/inventory/gui/GUIStrandCaster.java
Normal file
102
src/main/java/com/hbm/inventory/gui/GUIStrandCaster.java
Normal file
@ -0,0 +1,102 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import com.hbm.inventory.container.ContainerStrandCaster;
|
||||
import com.hbm.inventory.material.Mats;
|
||||
import com.hbm.inventory.material.Mats.MaterialStack;
|
||||
import com.hbm.inventory.material.NTMMaterial;
|
||||
import com.hbm.inventory.material.NTMMaterial.SmeltingBehavior;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineStrandCaster;
|
||||
import com.hbm.util.I18nUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class GUIStrandCaster extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_strand_caster.png");
|
||||
private TileEntityMachineStrandCaster caster;
|
||||
|
||||
public GUIStrandCaster(InventoryPlayer invPlayer, TileEntityMachineStrandCaster tedf) {
|
||||
super(new ContainerStrandCaster(invPlayer, tedf));
|
||||
caster = tedf;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 214;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float interp) {
|
||||
super.drawScreen(x, y, interp);
|
||||
|
||||
drawStackInfo(x, y, 16, 17);
|
||||
|
||||
caster.water.renderTankInfo(this, x, y, guiLeft + 82, guiTop + 38, 16, 24);
|
||||
caster.steam.renderTankInfo(this, x, y, guiLeft + 82, guiTop + 89, 16, 24);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.caster.hasCustomInventoryName() ? this.caster.getInventoryName() : I18n.format(this.caster.getInventoryName());
|
||||
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 0xffffff);
|
||||
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);
|
||||
|
||||
caster.water.renderTank(guiLeft + 82, guiTop + 38, this.zLevel, 16, 24);
|
||||
caster.steam.renderTank(guiLeft + 82, guiTop + 89, this.zLevel, 16, 24);
|
||||
|
||||
if (caster.amount != 0) {
|
||||
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
|
||||
|
||||
int targetHeight = (caster.amount) * 79 / caster.getCapacity();
|
||||
int offset = caster.type.smeltable == SmeltingBehavior.ADDITIVE ? 34 : 0; //additives use a differnt texture
|
||||
|
||||
int hex = caster.type.moltenColor;
|
||||
//hex = 0xC18336;
|
||||
Color color = new Color(hex);
|
||||
GL11.glColor3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F);
|
||||
drawTexturedModalRect(guiLeft + 17, guiTop + 92 - targetHeight, 176 + offset, 89 - targetHeight, 34, targetHeight);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1F, 1F, 1F, 0.3F);
|
||||
drawTexturedModalRect(guiLeft + 17, guiTop + 92 - targetHeight, 176 + offset, 89 - targetHeight, 34, targetHeight);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
||||
GL11.glColor3f(255, 255, 255);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void drawStackInfo(int mouseX, int mouseY, int x, int y) {
|
||||
|
||||
List<String> list = new ArrayList();
|
||||
|
||||
if(caster.type == null) list.add(EnumChatFormatting.RED + "Empty");
|
||||
else list.add(EnumChatFormatting.YELLOW + I18nUtil.resolveKey(caster.type.getUnlocalizedName()) + ": " + Mats.formatAmount(caster.amount, Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)));
|
||||
|
||||
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + x, guiTop + y, 36, 81, mouseX, mouseY, list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -23,6 +23,7 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
|
||||
boolean power;
|
||||
boolean fluid;
|
||||
boolean heat;
|
||||
public boolean moltenMetal;
|
||||
|
||||
public TileEntityProxyCombo() { }
|
||||
|
||||
@ -41,7 +42,10 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
|
||||
this.power = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TileEntityProxyCombo moltenMetal() {
|
||||
this.moltenMetal = true;
|
||||
return this;
|
||||
}
|
||||
public TileEntityProxyCombo fluid() {
|
||||
this.fluid = true;
|
||||
return this;
|
||||
|
||||
@ -22,7 +22,8 @@ public abstract class TileEntityFoundryCastingBase extends TileEntityFoundryBase
|
||||
|
||||
public ItemStack slots[] = new ItemStack[2];
|
||||
public int cooloff = 100;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
@ -0,0 +1,195 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import api.hbm.block.ICrucibleAcceptor;
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.inventory.container.ContainerAssemfac;
|
||||
import com.hbm.inventory.container.ContainerStrandCaster;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.gui.GUIAssemfac;
|
||||
import com.hbm.inventory.gui.GUIStrandCaster;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemMold;
|
||||
import com.hbm.packet.NBTPacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.INBTPacketReceiver;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
//god thank you bob for this base class
|
||||
public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase implements IGUIProvider, ICrucibleAcceptor,ISidedInventory, IFluidStandardTransceiver, INBTPacketReceiver {
|
||||
public FluidTank water;
|
||||
public FluidTank steam;
|
||||
|
||||
public ItemStack[] slots = new ItemStack[6];
|
||||
|
||||
public TileEntityMachineStrandCaster() {
|
||||
|
||||
water = new FluidTank(Fluids.WATER, 64_000);
|
||||
steam = new FluidTank(Fluids.SPENTSTEAM, 64_000);
|
||||
}
|
||||
int cooldown = 10;
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
if(this.amount > this.getCapacity()) {
|
||||
this.amount = this.getCapacity();
|
||||
}
|
||||
|
||||
if(this.amount == 0) {
|
||||
this.type = null;
|
||||
}
|
||||
|
||||
if(worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
this.updateConnections();
|
||||
}
|
||||
|
||||
for(DirPos pos : getConPos()) {
|
||||
this.sendFluid(steam, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
}
|
||||
|
||||
ItemMold.Mold mold = this.getInstalledMold();
|
||||
|
||||
if(mold != null && this.amount >= this.getCapacity() && slots[1] == null && water.getFill() >= getWaterRequired() ) {
|
||||
cooldown--;
|
||||
|
||||
if(cooldown <= 0) {
|
||||
this.amount -= mold.getCost();
|
||||
|
||||
ItemStack out = mold.getOutput(type);
|
||||
|
||||
for(int i = 1; i < 7; i++) {
|
||||
if(slots[i].isItemEqual(out) && slots[i].stackSize + out.stackSize <= out.getMaxStackSize()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(slots[i] == null) {
|
||||
slots[i] = out.copy();
|
||||
} else {
|
||||
slots[i].stackSize += out.stackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
water.setFill(water.getFill() - getWaterRequired());
|
||||
steam.setFill(steam.getFill() + getWaterRequired());
|
||||
|
||||
cooldown = 20;
|
||||
}
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
|
||||
water.writeToNBT(data, "w");
|
||||
steam.writeToNBT(data, "s");
|
||||
|
||||
this.networkPack(data, 150);
|
||||
|
||||
} else {
|
||||
cooldown = 20;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DirPos[] getConPos() {
|
||||
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||
|
||||
return new DirPos[] {
|
||||
new DirPos(xCoord - dir.offsetX, yCoord, zCoord, rot),
|
||||
new DirPos(xCoord, yCoord, zCoord + dir.offsetX, rot),
|
||||
new DirPos(xCoord, yCoord, zCoord + dir.offsetX * 5, rot.getOpposite()),
|
||||
new DirPos(xCoord- dir.offsetX, yCoord, zCoord + dir.offsetX * 5, rot.getOpposite()),
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public int getMoldSize() {
|
||||
return getInstalledMold().size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
ItemMold.Mold mold = this.getInstalledMold();
|
||||
return mold == null ? 0 : mold.getCost() * 10;
|
||||
}
|
||||
private int getWaterRequired() {
|
||||
return getInstalledMold() != null ? 5 * getInstalledMold().getCost() : 10;
|
||||
}
|
||||
private void updateConnections() {
|
||||
for(DirPos pos : getConPos()) {
|
||||
this.trySubscribe(water.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getSendingTanks() {
|
||||
return new FluidTank[] { steam };
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getReceivingTanks() {
|
||||
return new FluidTank[] { water };
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getAllTanks() {
|
||||
return new FluidTank[] { water, steam };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new ContainerStrandCaster(player.inventory, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new GUIStrandCaster(player.inventory, this);
|
||||
}
|
||||
public void networkPack(NBTTagCompound nbt, int range) {
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new NetworkRegistry.TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
|
||||
}
|
||||
@Override
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
water.readFromNBT(nbt, "w");
|
||||
steam.readFromNBT(nbt, "s");
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack) {
|
||||
|
||||
if(i == 0) {
|
||||
return stack.getItem() == ModItems.mold;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 65536.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int meta) {
|
||||
return new int[] { 1, 2, 3, 4, 5, 6};
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Loading…
x
Reference in New Issue
Block a user