mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
glaggle 3: return to blibble's field
This commit is contained in:
parent
ecec7e5a36
commit
4c3047c121
@ -2024,7 +2024,7 @@ public class ModBlocks {
|
||||
cm_sheet = new BlockCM(Material.iron, EnumCMMaterials.class, true, true).setBlockName("cm_sheet").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_sheet");
|
||||
cm_engine = new BlockCM(Material.iron, EnumCMEngines.class, true, true).setBlockName("cm_engine").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_engine");
|
||||
cm_tank = new BlockCMGlass(Material.iron, EnumCMMaterials.class, true, true).setBlockName("cm_tank").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_tank");
|
||||
cm_port = new BlockCM(Material.iron, EnumCMMaterials.class, true, true).setBlockName("cm_port").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_port");
|
||||
cm_port = new BlockCMPort(Material.iron, EnumCMMaterials.class, true, true).setBlockName("cm_port").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_port");
|
||||
custom_machine = new BlockCustomMachine().setBlockName("custom_machine").setCreativeTab(MainRegistry.blockTab).setHardness(5.0F).setResistance(10.0F);
|
||||
|
||||
reactor_element = new BlockPillar(Material.iron, RefStrings.MODID + ":reactor_element_top", RefStrings.MODID + ":reactor_element_base").setBlockName("reactor_element").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":reactor_element_side");
|
||||
|
||||
32
src/main/java/com/hbm/blocks/machine/BlockCMPort.java
Normal file
32
src/main/java/com/hbm/blocks/machine/BlockCMPort.java
Normal file
@ -0,0 +1,32 @@
|
||||
package com.hbm.blocks.machine;
|
||||
|
||||
import com.hbm.tileentity.TileEntityProxyCombo;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCMPort extends BlockCM implements ITileEntityProvider {
|
||||
|
||||
public BlockCMPort(Material mat, Class<? extends Enum> theEnum, boolean multiName, boolean multiTexture) {
|
||||
super(mat, theEnum, multiName, multiTexture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileEntityProxyCombo().inventory().power().fluid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z) {
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block b, int m) {
|
||||
super.breakBlock(world, x, y, z, b, m);
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
}
|
||||
@ -22,6 +22,7 @@ import net.minecraft.stats.StatList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockCustomMachine extends BlockContainer {
|
||||
@ -115,7 +116,7 @@ public class BlockCustomMachine extends BlockContainer {
|
||||
Item item = getItemDropped(metadata, world.rand, fortune);
|
||||
if(item != null) {
|
||||
|
||||
ItemStack stack = new ItemStack(item, 1, damageDropped(metadata));
|
||||
ItemStack stack = new ItemStack(item);
|
||||
TileEntityCustomMachine tile = (TileEntityCustomMachine) world.getTileEntity(x, y, z);
|
||||
|
||||
if(tile != null) {
|
||||
@ -128,4 +129,20 @@ public class BlockCustomMachine extends BlockContainer {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) { //using the deprecated one to make NEI happy
|
||||
|
||||
TileEntityCustomMachine tile = (TileEntityCustomMachine) world.getTileEntity(x, y, z);
|
||||
|
||||
ItemStack stack = new ItemStack(this);
|
||||
|
||||
if(tile != null && tile.machineType != null && !tile.machineType.isEmpty()) {
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
stack.stackTagCompound.setString("machineType", tile.machineType);
|
||||
return stack;
|
||||
}
|
||||
|
||||
return super.getPickBlock(target, world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,9 @@ public class ContainerMachineCustom extends Container {
|
||||
//Input
|
||||
this.addSlotToContainer(new Slot(tile, 0, 150, 72));
|
||||
//Fluid IDs
|
||||
for(int i = 0; i < tile.inputTanks.length; i++) this.addSlotToContainer(new Slot(tile, 1 + i, 8, 54 + 18 * i));
|
||||
for(int i = 0; i < tile.inputTanks.length; i++) {
|
||||
this.addSlotToContainer(new Slot(tile, 1 + i, 8 + 18 * i, 54));
|
||||
}
|
||||
//Item inputs
|
||||
if(tile.config.itemInCount > 0) this.addSlotToContainer(new Slot(tile, 4, 8, 72));
|
||||
if(tile.config.itemInCount > 1) this.addSlotToContainer(new Slot(tile, 5, 26, 72));
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.SlotPattern;
|
||||
import com.hbm.inventory.container.ContainerMachineCustom;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.machine.TileEntityCustomMachine;
|
||||
@ -9,6 +12,8 @@ import com.hbm.tileentity.machine.TileEntityCustomMachine;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIMachineCustom extends GuiInfoContainer {
|
||||
@ -24,6 +29,41 @@ public class GUIMachineCustom extends GuiInfoContainer {
|
||||
this.ySize = 256;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int x, int y, float interp) {
|
||||
super.drawScreen(x, y, interp);
|
||||
|
||||
this.drawElectricityInfo(this, x, y, guiLeft + 150, guiTop + 18, 16, 52, custom.power, custom.config.maxPower);
|
||||
|
||||
if(this.mc.thePlayer.inventory.getItemStack() == null) {
|
||||
for(int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i) {
|
||||
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i);
|
||||
int tileIndex = slot.getSlotIndex();
|
||||
|
||||
if(this.isMouseOverSlot(slot, x, y) && slot instanceof SlotPattern && custom.matcher.modes[tileIndex - 10] != null) {
|
||||
|
||||
String label = EnumChatFormatting.YELLOW + "";
|
||||
|
||||
switch(custom.matcher.modes[tileIndex - 10]) {
|
||||
case "exact": label += "Item and meta match"; break;
|
||||
case "wildcard": label += "Item matches"; break;
|
||||
default: label += "Ore dict key matches: " + custom.matcher.modes[tileIndex - 10]; break;
|
||||
}
|
||||
|
||||
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label }), x, y - 30);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < custom.inputTanks.length; i++) {
|
||||
custom.inputTanks[i].renderTankInfo(this, x, y, guiLeft + 8 + 18 * i, guiTop + 18, 16, 34);
|
||||
}
|
||||
|
||||
for(int i = 0; i < custom.outputTanks.length; i++) {
|
||||
custom.outputTanks[i].renderTankInfo(this, x, y, guiLeft + 78 + 18 * i, guiTop + 18, 16, 34);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.custom.getInventoryName();
|
||||
@ -37,6 +77,16 @@ public class GUIMachineCustom extends GuiInfoContainer {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
int p = custom.progress * 90 / custom.maxProgress;
|
||||
drawTexturedModalRect(guiLeft + 78, guiTop + 119, 192, 0, Math.min(p, 44), 16);
|
||||
if(p > 44) {
|
||||
p-= 44;
|
||||
drawTexturedModalRect(guiLeft + 78 + 44, guiTop + 119, 192, 16, p, 16);
|
||||
}
|
||||
|
||||
int e = (int) (custom.power * 52 / custom.config.maxPower);
|
||||
drawTexturedModalRect(guiLeft + 150, guiTop + 70 - e, 176, 52 - e, 16, e);
|
||||
|
||||
for(int i = 0; i < 2; i++) {
|
||||
for(int j = 0; j < 3; j++) {
|
||||
int index = i * 3 + j;
|
||||
@ -58,6 +108,14 @@ public class GUIMachineCustom extends GuiInfoContainer {
|
||||
drawTexturedModalRect(guiLeft + 77 + i * 18, guiTop + 17, 192 + i * 18, 32, 18, 36);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < custom.inputTanks.length; i++) {
|
||||
custom.inputTanks[i].renderTank(guiLeft + 8 + 18 * i, guiTop + 52, this.zLevel, 16, 34);
|
||||
}
|
||||
|
||||
for(int i = 0; i < custom.outputTanks.length; i++) {
|
||||
custom.outputTanks[i].renderTank(guiLeft + 78 + 18 * i, guiTop + 52, this.zLevel, 16, 34);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -3,16 +3,27 @@ package com.hbm.tileentity;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.IProxyController;
|
||||
import com.hbm.util.Compat;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileEntityProxyBase extends TileEntityLoadedBase {
|
||||
|
||||
public BlockPos cachedPosition;
|
||||
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public TileEntity getTE() {
|
||||
|
||||
if(cachedPosition != null) {
|
||||
TileEntity te = Compat.getTileStandard(worldObj, cachedPosition.getX(), cachedPosition.getY(), cachedPosition.getZ());
|
||||
if(te != null && te != this) return te;
|
||||
cachedPosition = null;
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
if(this.getBlockType() instanceof BlockDummyable) {
|
||||
|
||||
@ -36,4 +47,23 @@ public class TileEntityProxyBase extends TileEntityLoadedBase {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
if(nbt.getBoolean("hasPos")) cachedPosition = new BlockPos(nbt.getInteger("pX"), nbt.getInteger("pY"), nbt.getInteger("pZ"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
if(this.cachedPosition != null) {
|
||||
nbt.setBoolean("hasPos", true);
|
||||
nbt.setInteger("pX", this.cachedPosition.getX());
|
||||
nbt.setInteger("pY", this.cachedPosition.getY());
|
||||
nbt.setInteger("pZ", this.cachedPosition.getZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
|
||||
return ((IEnergyConnector)getTile()).canConnect(dir);
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -459,7 +459,7 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
|
||||
if(getTile() instanceof IFluidConnector) {
|
||||
return ((IFluidConnector)getTile()).canConnect(type, dir);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,38 +1,56 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.config.CustomMachineConfigJSON;
|
||||
import com.hbm.config.CustomMachineConfigJSON.MachineConfiguration;
|
||||
import com.hbm.config.CustomMachineConfigJSON.MachineConfiguration.ComponentDefinition;
|
||||
import com.hbm.inventory.FluidStack;
|
||||
import com.hbm.inventory.container.ContainerMachineCustom;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.inventory.gui.GUIMachineCustom;
|
||||
import com.hbm.inventory.recipes.CustomMachineRecipes;
|
||||
import com.hbm.inventory.recipes.CustomMachineRecipes.CustomMachineRecipe;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.module.ModulePatternMatcher;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.tileentity.TileEntityProxyBase;
|
||||
import com.hbm.util.Compat;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
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;
|
||||
|
||||
public class TileEntityCustomMachine extends TileEntityMachineBase implements IGUIProvider {
|
||||
public class TileEntityCustomMachine extends TileEntityMachineBase implements IFluidStandardTransceiver, IGUIProvider {
|
||||
|
||||
public String machineType;
|
||||
public MachineConfiguration config;
|
||||
|
||||
public long power;
|
||||
public int progress;
|
||||
public int maxProgress = 1;
|
||||
public FluidTank[] inputTanks;
|
||||
public FluidTank[] outputTanks;
|
||||
public ModulePatternMatcher matcher;
|
||||
public int structureCheckDelay;
|
||||
public boolean structureOK = false;
|
||||
public CustomMachineRecipe cachedRecipe;
|
||||
|
||||
public List<DirPos> connectionPos = new ArrayList();
|
||||
|
||||
public TileEntityCustomMachine() {
|
||||
/*
|
||||
@ -77,14 +95,80 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IG
|
||||
worldObj.func_147480_a(xCoord, yCoord, zCoord, false);
|
||||
return;
|
||||
}
|
||||
|
||||
this.power = Library.chargeTEFromItems(slots, 0, power, this.config.maxPower);
|
||||
|
||||
if(this.inputTanks.length > 0) this.inputTanks[0].setType(1, slots);
|
||||
if(this.inputTanks.length > 1) this.inputTanks[1].setType(2, slots);
|
||||
if(this.inputTanks.length > 2) this.inputTanks[2].setType(3, slots);
|
||||
|
||||
this.structureCheckDelay--;
|
||||
if(this.structureCheckDelay <= 0) this.checkStructure();
|
||||
|
||||
if(this.worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
for(DirPos pos : this.connectionPos) {
|
||||
for(FluidTank tank : this.inputTanks) {
|
||||
this.trySubscribe(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(this.structureOK) {
|
||||
|
||||
if(config.generatorMode) {
|
||||
if(this.cachedRecipe == null) {
|
||||
CustomMachineRecipe recipe = this.getMatchingRecipe();
|
||||
if(this.hasRequiredQuantities(recipe) && this.hasSpace(recipe)) {
|
||||
this.cachedRecipe = recipe;
|
||||
this.useUpInput(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
if(this.cachedRecipe != null) {
|
||||
this.maxProgress = (int) Math.max(cachedRecipe.duration / this.config.recipeSpeedMult, 1);
|
||||
int powerReq = (int) Math.max(cachedRecipe.consumptionPerTick * this.config.recipeConsumptionMult, 1);
|
||||
|
||||
this.progress++;
|
||||
this.power += powerReq;
|
||||
if(power > config.maxPower) power = config.maxPower;
|
||||
|
||||
if(progress >= this.maxProgress) {
|
||||
this.progress = 0;
|
||||
this.processRecipe(cachedRecipe);
|
||||
this.cachedRecipe = null;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
CustomMachineRecipe recipe = this.getMatchingRecipe();
|
||||
|
||||
if(recipe != null) {
|
||||
this.maxProgress = (int) Math.max(recipe.duration / this.config.recipeSpeedMult, 1);
|
||||
int powerReq = (int) Math.max(recipe.consumptionPerTick * this.config.recipeConsumptionMult, 1);
|
||||
|
||||
if(this.power >= powerReq && this.hasRequiredQuantities(recipe) && this.hasSpace(recipe)) {
|
||||
this.progress++;
|
||||
this.power -= powerReq;
|
||||
|
||||
if(progress >= this.maxProgress) {
|
||||
this.progress = 0;
|
||||
this.useUpInput(recipe);
|
||||
this.processRecipe(recipe);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.progress = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.progress = 0;
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString("type", this.machineType);
|
||||
data.setLong("power", power);
|
||||
data.setInteger("progress", progress);
|
||||
data.setInteger("maxProgress", maxProgress);
|
||||
for(int i = 0; i < inputTanks.length; i++) inputTanks[i].writeToNBT(data, "i" + i);
|
||||
for(int i = 0; i < outputTanks.length; i++) outputTanks[i].writeToNBT(data, "o" + i);
|
||||
this.matcher.writeToNBT(data);
|
||||
@ -92,8 +176,88 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IG
|
||||
}
|
||||
}
|
||||
|
||||
/** Only accepts inputs in a fixed order, saves a ton of performance because there's no permutations to check for */
|
||||
public CustomMachineRecipe getMatchingRecipe() {
|
||||
List<CustomMachineRecipe> recipes = CustomMachineRecipes.recipes.get(this.machineType);
|
||||
if(recipes == null || recipes.isEmpty()) return null;
|
||||
|
||||
outer:
|
||||
for(CustomMachineRecipe recipe : recipes) {
|
||||
for(int i = 0; i < recipe.inputFluids.length; i++) {
|
||||
if(this.inputTanks[i].getTankType() != recipe.inputFluids[i].type || this.inputTanks[i].getPressure() != recipe.inputFluids[i].pressure) continue outer;
|
||||
}
|
||||
|
||||
for(int i = 0; i < recipe.inputItems.length; i++) {
|
||||
if(recipe.inputItems[i] != null && slots[i + 4] == null) continue outer;
|
||||
if(!recipe.inputItems[i].matchesRecipe(slots[i + 4], true)) continue outer;
|
||||
}
|
||||
|
||||
return recipe;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasRequiredQuantities(CustomMachineRecipe recipe) {
|
||||
|
||||
for(int i = 0; i < recipe.inputFluids.length; i++) {
|
||||
if(this.inputTanks[i].getFill() < recipe.inputFluids[i].fill) return false;
|
||||
}
|
||||
|
||||
for(int i = 0; i < recipe.inputItems.length; i++) {
|
||||
if(slots[i + 4] != null && slots[i + 4].stackSize < recipe.inputItems[i].stacksize) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasSpace(CustomMachineRecipe recipe) {
|
||||
|
||||
for(int i = 0; i < recipe.outputFluids.length; i++) {
|
||||
if(this.outputTanks[i].getTankType() == recipe.outputFluids[i].type && this.outputTanks[i].getFill() + recipe.outputFluids[i].fill > this.outputTanks[i].getMaxFill()) return false;
|
||||
}
|
||||
|
||||
for(int i = 0; i < recipe.outputItems.length; i++) {
|
||||
if(slots[i + 16] != null && (slots[i + 16].getItem() != recipe.outputItems[i].key.getItem() || slots[i + 16].getItemDamage() != recipe.outputItems[i].key.getItemDamage())) return false;
|
||||
if(slots[i + 16] != null && slots[16 + i].stackSize + recipe.outputItems[i].key.stackSize > slots[i + 16].getMaxStackSize()) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void useUpInput(CustomMachineRecipe recipe) {
|
||||
|
||||
for(int i = 0; i < recipe.inputFluids.length; i++) {
|
||||
this.inputTanks[i].setFill(this.inputTanks[i].getFill() - recipe.inputFluids[i].fill);
|
||||
}
|
||||
|
||||
for(int i = 0; i < recipe.inputItems.length; i++) {
|
||||
this.decrStackSize(i + 4, recipe.inputItems[i].stacksize);
|
||||
}
|
||||
}
|
||||
|
||||
public void processRecipe(CustomMachineRecipe recipe) {
|
||||
|
||||
for(int i = 0; i < recipe.outputFluids.length; i++) {
|
||||
if(this.outputTanks[i].getTankType() != recipe.outputFluids[i].type) this.outputTanks[i].setTankType(recipe.outputFluids[i].type);
|
||||
this.outputTanks[i].setFill(this.outputTanks[i].getFill() + recipe.outputFluids[i].fill);
|
||||
}
|
||||
|
||||
for(int i = 0; i < recipe.outputItems.length; i++) {
|
||||
|
||||
if(worldObj.rand.nextFloat() < recipe.outputItems[i].value) {
|
||||
if(slots[i + 16] == null) {
|
||||
slots[i + 16] = recipe.outputItems[i].key.copy();
|
||||
} else {
|
||||
slots[i + 16].stackSize += recipe.outputItems[i].key.stackSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkStructure() {
|
||||
|
||||
this.connectionPos.clear();
|
||||
this.structureCheckDelay = 300;
|
||||
this.structureOK = false;
|
||||
if(this.config == null) return false;
|
||||
@ -120,6 +284,21 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IG
|
||||
|
||||
int meta = worldObj.getBlockMetadata(x, y, z);
|
||||
if(!comp.allowedMetas.contains(meta)) return false;
|
||||
|
||||
TileEntity tile = Compat.getTileStandard(worldObj, x, y, z);
|
||||
if(tile instanceof TileEntityProxyBase) {
|
||||
TileEntityProxyBase proxy = (TileEntityProxyBase) tile;
|
||||
proxy.cachedPosition = new BlockPos(xCoord, yCoord, zCoord);
|
||||
proxy.markDirty();
|
||||
|
||||
for(ForgeDirection facing : ForgeDirection.VALID_DIRECTIONS) {
|
||||
this.connectionPos.add(new DirPos(x + facing.offsetX, y + facing.offsetY, z + facing.offsetZ, facing));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(ForgeDirection facing : ForgeDirection.VALID_DIRECTIONS) {
|
||||
this.connectionPos.add(new DirPos(xCoord + facing.offsetX, yCoord + facing.offsetY, zCoord + facing.offsetZ, facing));
|
||||
}
|
||||
|
||||
this.structureOK = true;
|
||||
@ -147,6 +326,35 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IG
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
if(this.config == null) return new int[] { };
|
||||
if(this.config.itemInCount > 0) return new int[] { 4, 16, 17, 18, 19, 20, 21 };
|
||||
if(this.config.itemInCount > 1) return new int[] { 4, 5, 16, 17, 18, 19, 20, 21 };
|
||||
if(this.config.itemInCount > 2) return new int[] { 4, 5, 6, 16, 17, 18, 19, 20, 21 };
|
||||
if(this.config.itemInCount > 3) return new int[] { 4, 5, 6, 7, 16, 17, 18, 19, 20, 21 };
|
||||
if(this.config.itemInCount > 4) return new int[] { 4, 5, 6, 7, 8, 16, 17, 18, 19, 20, 21 };
|
||||
if(this.config.itemInCount > 5) return new int[] { 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 21 };
|
||||
return new int[] { };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack stack, int j) {
|
||||
return i >= 16 && i <= 21;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
if(slot < 4 || slot > 9) return false;
|
||||
|
||||
int index = slot - 4;
|
||||
int filterSlot = slot + 6;
|
||||
|
||||
if(slots[filterSlot] == null) return true;
|
||||
|
||||
return matcher.isValidForFilter(slots[filterSlot], index, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void networkUnpack(NBTTagCompound nbt) {
|
||||
this.machineType = nbt.getString("type");
|
||||
@ -154,6 +362,7 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IG
|
||||
|
||||
this.power = nbt.getLong("power");
|
||||
this.progress = nbt.getInteger("progress");
|
||||
this.maxProgress = nbt.getInteger("maxProgress");
|
||||
for(int i = 0; i < inputTanks.length; i++) inputTanks[i].readFromNBT(nbt, "i" + i);
|
||||
for(int i = 0; i < outputTanks.length; i++) outputTanks[i].readFromNBT(nbt, "o" + i);
|
||||
|
||||
@ -167,16 +376,24 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IG
|
||||
this.init();
|
||||
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
for(int i = 0; i < inputTanks.length; i++) inputTanks[i].readFromNBT(nbt, "i" + i);
|
||||
for(int i = 0; i < outputTanks.length; i++) outputTanks[i].readFromNBT(nbt, "o" + i);
|
||||
|
||||
this.matcher.readFromNBT(nbt);
|
||||
if(this.config != null) {
|
||||
|
||||
for(int i = 0; i < inputTanks.length; i++) inputTanks[i].readFromNBT(nbt, "i" + i);
|
||||
for(int i = 0; i < outputTanks.length; i++) outputTanks[i].readFromNBT(nbt, "o" + i);
|
||||
|
||||
this.matcher.readFromNBT(nbt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
|
||||
if(machineType == null || this.config == null) {
|
||||
super.writeToNBT(nbt);
|
||||
return;
|
||||
}
|
||||
|
||||
nbt.setString("machineType", machineType);
|
||||
|
||||
super.writeToNBT(nbt);
|
||||
@ -187,6 +404,27 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IG
|
||||
this.matcher.writeToNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getAllTanks() {
|
||||
|
||||
FluidTank[] all = new FluidTank[inputTanks.length + outputTanks.length];
|
||||
|
||||
for(int i = 0; i < inputTanks.length; i++) all[i] = inputTanks[i];
|
||||
for(int i = 0; i < outputTanks.length; i++) all[inputTanks.length + i] = outputTanks[i];
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getSendingTanks() {
|
||||
return outputTanks != null ? outputTanks : new FluidTank[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTank[] getReceivingTanks() {
|
||||
return inputTanks != null ? inputTanks : new FluidTank[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if(this.config == null) return null;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user