tweaks and fixes, template crate

This commit is contained in:
Bob 2023-07-15 22:30:49 +02:00
parent 24a0fbffef
commit ea8dcd9508
28 changed files with 367 additions and 592 deletions

View File

@ -5,6 +5,11 @@
* Freezes entities
* Can only deal damage to already frozen entities
* Damage is proportional to max health, dealing more damage the stronger the mob is
* Template crate
* A cheap 27 slot crate
* Assemblers will insert their loaded template into the template crate after doing one operation with it
* Assemblers will also pull templates from template crates if no template is currently loaded
* This hopefully makes certain types of automation like AE2 easier as the template is therefore treated like a crafting ingredient that is returned afterwards
## Changed
* Making LPG in the compressor now requires two compression steps
@ -13,6 +18,17 @@
* Fire now deals 4x more damage to glyphids
* Cryogenic fluids from the chemthrower no longer deal direct damage, instead freezing the target
* Once the target is already frozen, it will deal damage and apply the same effects as it used to
* Decreased the damage caused by hot fluids in the chemical thrower, regular steam no longer instantly vaporizes nuclear creepers
* Decreased acid damage and armor damage for corrosive liquids in the chemical thrower
* Glyphid hives have been made half as common, delete your config for this change to take effect
* The assembler now uses more modern code that lets it take and insert items from all storage blocks and not just NTM crates
* This new code also causes assemblers to only take as many items from containers as are actually required instead of sucking up as much as available whcih would cause clogs
* Assemblers and chemical plants now take the required items from containers instantly instead of only taking a single item per tick
* The universal projectile entity has been updated, it now uses a much better synchronization and interpolation method that prevents position desyncs after bouncing
* This also fixes issues where bullets could not damage multiple entities within the same tick, if they could penetrate them
* The old system also had issues with spectral bullets not damaging entities right behind walls, which has been fixed
* The coilgun now destroys solid blocks in its path
* Glyphids no longer use extended 128 block targeting unless soot pollution crosses a certain threshold (1 by default)
## Fixed
* Fixed issue where mk5 explosions would behave weirdly in their origin chunk, often blowing through bedrock and thick layers of concrete

View File

@ -637,11 +637,12 @@ public class ModBlocks {
public static Block sat_dock;
public static Block soyuz_capsule;
public static Block crate_iron;
public static Block crate_steel;
public static Block crate_desh;
public static Block crate_tungsten;
public static Block crate_template;
public static Block safe;
public static Block mass_storage;
@ -2182,6 +2183,7 @@ public class ModBlocks {
crate_steel = new BlockStorageCrate(Material.iron).setBlockName("crate_steel").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
crate_desh = new BlockStorageCrate(Material.iron).setBlockName("crate_desh").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
crate_tungsten = new BlockStorageCrate(Material.iron).setBlockName("crate_tungsten").setStepSound(Block.soundTypeMetal).setHardness(7.5F).setResistance(300.0F).setCreativeTab(MainRegistry.machineTab);
crate_template = new BlockStorageCrate(Material.iron).setBlockName("crate_template").setStepSound(Block.soundTypeMetal).setHardness(7.5F).setResistance(300.0F).setCreativeTab(MainRegistry.machineTab);
safe = new BlockStorageCrate(Material.iron).setBlockName("safe").setStepSound(Block.soundTypeMetal).setHardness(7.5F).setResistance(10000.0F).setCreativeTab(MainRegistry.machineTab);
mass_storage = new BlockMassStorage().setBlockName("mass_storage").setStepSound(Block.soundTypeMetal).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
@ -3009,6 +3011,7 @@ public class ModBlocks {
register(crate_steel);
register(crate_desh);
register(crate_tungsten);
register(crate_template);
register(safe);
register(mass_storage);

View File

@ -72,6 +72,9 @@ public class BlockStorageCrate extends BlockContainer implements IBlockMulti {
this.iconTop = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top");
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side");
}
if(this == ModBlocks.crate_template) {
this.iconTop = this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":crate_template");
}
}
@Override
@ -90,6 +93,7 @@ public class BlockStorageCrate extends BlockContainer implements IBlockMulti {
if(this == ModBlocks.crate_steel) return new TileEntityCrateSteel();
if(this == ModBlocks.crate_desh) return new TileEntityCrateDesh();
if(this == ModBlocks.crate_tungsten) return new TileEntityCrateTungsten();
if(this == ModBlocks.crate_template) return new TileEntityCrateTemplate();
if(this == ModBlocks.safe) return new TileEntitySafe();
return null;
}

View File

@ -29,13 +29,14 @@ public class MobConfig {
public static boolean enableMobGear = true;
public static boolean enableHives = true;
public static int hiveSpawn = 128;
public static int hiveSpawn = 256;
public static double scoutThreshold = 0.1;
public static double tier2Threshold = 1;
public static double tier3Threshold = 10;
public static double tier4Threshold = 50;
public static double tier5Threshold = 100;
public static double spawnMax = 50;
public static double targetingThreshold = 1;
public static void loadFromConfig(Configuration config) {
@ -67,12 +68,13 @@ public class MobConfig {
enableMobGear = CommonConfig.createConfigBool(config, CATEGORY, "12.D01_enableMobGear", "Whether zombies and skeletons should have additional gear when spawning", true);
enableHives = CommonConfig.createConfigBool(config, CATEGORY, "12.G00_enableHives", "Whether glyphid hives should spawn", true);
hiveSpawn = CommonConfig.createConfigInt(config, CATEGORY, "12.G01_hiveSpawn", "The average amount of chunks per hive", 128);
hiveSpawn = CommonConfig.createConfigInt(config, CATEGORY, "12.G01_hiveSpawn", "The average amount of chunks per hive", 256);
scoutThreshold = CommonConfig.createConfigDouble(config, CATEGORY, "12.G02_scoutThreshold", "Minimum amount of soot for scouts to spawn", 0.1);
tier2Threshold = CommonConfig.createConfigDouble(config, CATEGORY, "12.G03_tier2Threshold", "Minimum amount of soot for tier 2 glyphids to spawn", 1);
tier3Threshold = CommonConfig.createConfigDouble(config, CATEGORY, "12.G04_tier3Threshold", "Minimum amount of soot for tier 3 glyphids to spawn", 10);
tier4Threshold = CommonConfig.createConfigDouble(config, CATEGORY, "12.G05_tier4Threshold", "Minimum amount of soot for tier 4 glyphids to spawn", 50);
tier5Threshold = CommonConfig.createConfigDouble(config, CATEGORY, "12.G06_tier5Threshold", "Minimum amount of soot for tier 5 glyphids to spawn", 100);
spawnMax = CommonConfig.createConfigDouble(config, CATEGORY, "12.G07_spawnMax", "Maximum amount of glyphids being able to exist at once through natural spawning", 50);
targetingThreshold = CommonConfig.createConfigDouble(config, CATEGORY, "12.G08_targetingThreshold", "Minimum amount of soot required for glyphids' extended targeting range to activate", 1D);
}
}

View File

@ -4,7 +4,10 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.hbm.config.MobConfig;
import com.hbm.entity.pathfinder.PathFinderUtils;
import com.hbm.handler.pollution.PollutionHandler;
import com.hbm.handler.pollution.PollutionHandler.PollutionType;
import com.hbm.items.ModItems;
import com.hbm.lib.ModDamageSource;
import com.hbm.main.ResourceManager;
@ -65,7 +68,7 @@ public class EntityGlyphid extends EntityMob {
@Override
protected Entity findPlayerToAttack() {
EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 128.0D);
EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, useExtendedTargeting() ? 128D : 16D);
return entityplayer != null && this.canEntityBeSeen(entityplayer) ? entityplayer : null;
}
@ -74,10 +77,14 @@ public class EntityGlyphid extends EntityMob {
super.updateEntityActionState();
// hell yeah!!
if(this.entityToAttack != null && !this.hasPath()) {
if(useExtendedTargeting() && this.entityToAttack != null && !this.hasPath()) {
this.setPathToEntity(PathFinderUtils.getPathEntityToEntityPartial(worldObj, this, this.entityToAttack, 16F, true, false, false, true));
}
}
public boolean useExtendedTargeting() {
return PollutionHandler.getPollution(worldObj, (int) Math.floor(posX), (int) Math.floor(posY), (int) Math.floor(posZ), PollutionType.SOOT) >= MobConfig.targetingThreshold;
}
@Override
protected boolean canDespawn() {

View File

@ -132,7 +132,6 @@ public class EntityBulletBaseNT extends EntityThrowableInterp implements IBullet
this.renderDistanceWeight = 10.0D;
this.setSize(0.5F, 0.5F);
System.out.println("" + this.config.spread);
this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, 1.0F, this.config.spread * (offsetShot ? 1F : 0.25F));
}
@ -378,8 +377,10 @@ public class EntityBulletBaseNT extends EntityThrowableInterp implements IBullet
if(config.bntImpact != null)
config.bntImpact.behaveBlockHit(this, bX, bY, bZ);
if(!worldObj.isRemote && !config.liveAfterImpact)
this.setDead();
if(!worldObj.isRemote) {
if(!config.liveAfterImpact && !config.isSpectral && bY > -1) this.setDead();
if(!config.doesPenetrate && bY == -1) this.setDead();
}
if(config.incendiary > 0 && !this.worldObj.isRemote) {
if(worldObj.rand.nextInt(3) == 0 && worldObj.getBlock((int)posX, (int)posY, (int)posZ) == Blocks.air) worldObj.setBlock((int)posX, (int)posY, (int)posZ, Blocks.fire);
@ -472,6 +473,8 @@ public class EntityBulletBaseNT extends EntityThrowableInterp implements IBullet
if(config.bntHit != null)
config.bntHit.behaveEntityHit(this, e);
//this.setDead();
}
//for when a bullet hurts an entity, not necessarily dying

View File

@ -175,7 +175,7 @@ public class EntityChemical extends EntityThrowableNT {
}
if(type.temperature >= 100) {
EntityDamageUtil.attackEntityFromIgnoreIFrame(e, getDamage(ModDamageSource.s_boil), 5F + (type.temperature - 100) * 0.02F); //5 damage at 100°C with one extra damage every 50°C
EntityDamageUtil.attackEntityFromIgnoreIFrame(e, getDamage(ModDamageSource.s_boil), 0.25F + (type.temperature - 100) * 0.001F); //.25 damage at 100°C with one extra damage every 1000°C
if(type.temperature >= 500) {
e.setFire(10); //afterburn for 10 seconds
@ -235,11 +235,11 @@ public class EntityChemical extends EntityThrowableNT {
if(type.hasTrait(FT_Corrosive.class)) {
FT_Corrosive trait = type.getTrait(FT_Corrosive.class);
EntityDamageUtil.attackEntityFromIgnoreIFrame(e, getDamage(ModDamageSource.s_acid), trait.getRating() / 20F);
EntityDamageUtil.attackEntityFromIgnoreIFrame(e, getDamage(ModDamageSource.s_acid), trait.getRating() / 50F);
if(living != null) {
for(int i = 0; i < 4; i++) {
ArmorUtil.damageSuit(living, i, trait.getRating() / 5);
ArmorUtil.damageSuit(living, i, (int) Math.ceil(trait.getRating() / 50));
}
}
}

View File

@ -192,7 +192,7 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile {
// if penetration is enabled, run impact for all intersecting entities
if(this.doesPenetrate()) {
this.onImpact(hitMop);
this.onImpact(new MovingObjectPosition(entity));
} else {
double dist = pos.distanceTo(hitMop.hitVec);

View File

@ -57,11 +57,11 @@ public class BulletConfiguration implements Cloneable {
//whether or not the bullet should penetrate mobs
public boolean doesPenetrate;
//whether or not the bullet should phase through blocks
//disables collisions with blocks entirely
public boolean isSpectral;
//whether or not the bullet should break glass
public boolean doesBreakGlass;
//whether the bullet should stay alive after colliding with a block
//bullets still call the impact function when hitting blocks but do not get destroyed
public boolean liveAfterImpact;
//creates a "muzzle flash" and a ton of smoke with every projectile spawned

View File

@ -34,6 +34,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
public class GunEnergyFactory {
@ -295,6 +296,30 @@ public class GunEnergyFactory {
bullet.trail = bullet.BOLT_NIGHTMARE;
bullet.vPFX = "fireworks";
bullet.bntUpdate = (entity) -> {
if(entity.worldObj.isRemote) return;
Vec3 vec = Vec3.createVectorHelper(entity.posX - entity.prevPosX, entity.posY - entity.prevPosY, entity.posZ - entity.prevPosZ);
double motion = Math.max(vec.lengthVector(), 0.1);
vec = vec.normalize();
for(double d = 0; d < motion; d += 0.5) {
int x = (int) Math.floor(entity.posX - vec.xCoord * d);
int y = (int) Math.floor(entity.posY - vec.yCoord * d);
int z = (int) Math.floor(entity.posZ - vec.zCoord * d);
Block b = entity.worldObj.getBlock(x, y, z);
float hardness = b.getBlockHardness(entity.worldObj, x, y, z);
if(b.getMaterial() != Material.air && hardness >= 0 && hardness < 1.25) {
System.out.println(b.getUnlocalizedName() + " " + hardness);
entity.worldObj.func_147480_a(x, y, z, false);
}
}
};
return bullet;
}

View File

@ -10,25 +10,20 @@ public class ContainerCrateIron extends ContainerCrateBase {
public ContainerCrateIron(InventoryPlayer invPlayer, TileEntityCrateIron tedf) {
super(tedf);
for(int i = 0; i < 4; i++)
{
for(int j = 0; j < 9; j++)
{
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(tedf, j + i * 9, 8 + j * 18, 18 + i * 18));
}
}
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 9; j++)
{
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 + 20));
}
}
for(int i = 0; i < 9; i++)
{
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142 + 20));
}
}

View File

@ -0,0 +1,29 @@
package com.hbm.inventory.container;
import com.hbm.tileentity.machine.storage.TileEntityCrateTemplate;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
public class ContainerCrateTemplate extends ContainerCrateBase {
public ContainerCrateTemplate(InventoryPlayer invPlayer, TileEntityCrateTemplate tedf) {
super(tedf);
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(tedf, j + i * 9, 8 + j * 18, 18 + 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, 86 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 144));
}
}
}

View File

@ -0,0 +1,42 @@
package com.hbm.inventory.gui;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerCrateTemplate;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.machine.storage.TileEntityCrateTemplate;
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 GUICrateTemplate extends GuiContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/storage/gui_crate_template.png");
private TileEntityCrateTemplate diFurnace;
public GUICrateTemplate(InventoryPlayer invPlayer, TileEntityCrateTemplate tedf) {
super(new ContainerCrateTemplate(invPlayer, tedf));
diFurnace = tedf;
this.xSize = 176;
this.ySize = 168;
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.diFurnace.hasCustomInventoryName() ? this.diFurnace.getInventoryName() : I18n.format(this.diFurnace.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);
}
}

View File

@ -30,7 +30,7 @@ public class GUIMachineAssembler extends GuiInfoContainer {
public void drawScreen(int mouseX, int mouseY, float f) {
super.drawScreen(mouseX, mouseY, f);
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 116, guiTop + 70 - 52, 16, 52, assembler.power, assembler.maxPower);
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 116, guiTop + 70 - 52, 16, 52, assembler.power, assembler.getMaxPower());
if(assembler.getStackInSlot(4) == null || assembler.getStackInSlot(4).getItem()!= ModItems.assembly_template) {
@ -63,14 +63,15 @@ public class GUIMachineAssembler extends GuiInfoContainer {
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
int i = (int)assembler.getPowerScaled(52);
int i = (int) (assembler.power * 52 / assembler.getMaxPower());
drawTexturedModalRect(guiLeft + 116, guiTop + 70 - i, 176, 52 - i, 16, i);
int j = assembler.getProgressScaled(83);
drawTexturedModalRect(guiLeft + 45, guiTop + 82, 2, 222, j, 32);
if(assembler.isProgressing) {
int j = assembler.progress[0] * 83 / assembler.maxProgress[0];
drawTexturedModalRect(guiLeft + 45, guiTop + 82, 2, 222, j, 32);
}
if(assembler.getStackInSlot(4) == null || assembler.getStackInSlot(4).getItem()!= ModItems.assembly_template) {
this.drawInfoPanel(guiLeft - 16, guiTop + 36, 16, 16, 6);
}

View File

@ -186,7 +186,7 @@ public class ItemAmmoHIMARS extends Item {
this.itemTypes[SMALL_WP] = new HIMARSRocket("standard_wp", "himars_standard_wp", 0) {
public void onImpact(EntityArtilleryRocket rocket, MovingObjectPosition mop) {
standardExplosion(rocket, mop, 20F, 3F, false, ModBlocks.slag, 1);
standardExplosion(rocket, mop, 20F, 3F, false, ModBlocks.block_slag, 1);
ExplosionLarge.spawnShrapnels(rocket.worldObj, (int) mop.hitVec.xCoord, (int) mop.hitVec.yCoord, (int) mop.hitVec.zCoord, 30);
ExplosionChaos.burn(rocket.worldObj, (int) mop.hitVec.xCoord, (int) mop.hitVec.yCoord, (int) mop.hitVec.zCoord, 20);
int radius = 30;
@ -209,7 +209,7 @@ public class ItemAmmoHIMARS extends Item {
this.itemTypes[SMALL_TB] = new HIMARSRocket("standard_tb", "himars_standard_tb", 0) {
public void onImpact(EntityArtilleryRocket rocket, MovingObjectPosition mop) {
standardExplosion(rocket, mop, 20F, 10F, true, ModBlocks.slag, 1);
standardExplosion(rocket, mop, 20F, 10F, true, ModBlocks.block_slag, 1);
ExplosionLarge.spawnShrapnels(rocket.worldObj, (int) mop.hitVec.xCoord, (int) mop.hitVec.yCoord, (int) mop.hitVec.zCoord, 30);
standardMush(rocket, mop, 20);
}};

View File

@ -293,6 +293,7 @@ public class CraftingManager {
addRecipeAuto(new ItemStack(ModBlocks.machine_turbine, 1), new Object[] { "SMS", "PTP", "SMS", 'S', STEEL.ingot(), 'T', ModItems.turbine_titanium, 'M', ModItems.coil_copper, 'P', ANY_PLASTIC.ingot() });
addRecipeAuto(new ItemStack(ModBlocks.machine_converter_he_rf, 1), new Object[] { "SSS", "CRB", "SSS", 'S', STEEL.ingot(), 'C', ModItems.coil_copper, 'R', ModItems.coil_copper_torus, 'B', REDSTONE.block() });
addRecipeAuto(new ItemStack(ModBlocks.machine_converter_rf_he, 1), new Object[] { "SSS", "BRC", "SSS", 'S', BE.ingot(), 'C', ModItems.coil_copper, 'R', ModItems.coil_copper_torus, 'B', REDSTONE.block() });
addRecipeAuto(new ItemStack(ModBlocks.crate_template, 1), new Object[] { "IPI", "P P", "IPI", 'I', IRON.ingot(), 'P', Items.paper });
addRecipeAuto(new ItemStack(ModBlocks.crate_iron, 1), new Object[] { "PPP", "I I", "III", 'P', IRON.plate(), 'I', IRON.ingot() });
addRecipeAuto(new ItemStack(ModBlocks.crate_steel, 1), new Object[] { "PPP", "I I", "III", 'P', STEEL.plate(), 'I', STEEL.ingot() });
addRecipeAuto(new ItemStack(ModBlocks.crate_desh, 1), new Object[] { " D ", "DSD", " D ", 'D', ModItems.plate_desh, 'S', ModBlocks.crate_steel });

View File

@ -1,64 +1,38 @@
package com.hbm.tileentity.machine;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ModBlocks;
import com.hbm.handler.MultiblockHandlerXR;
import com.hbm.inventory.RecipesCommon.AStack;
import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.inventory.UpgradeManager;
import com.hbm.inventory.container.ContainerMachineAssembler;
import com.hbm.inventory.gui.GUIMachineAssembler;
import com.hbm.inventory.recipes.AssemblerRecipes;
import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemAssemblyTemplate;
import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType;
import com.hbm.lib.Library;
import com.hbm.main.MainRegistry;
import com.hbm.sound.AudioWrapper;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.tileentity.machine.storage.TileEntityCrateBase;
import com.hbm.tileentity.machine.storage.TileEntityCrateIron;
import com.hbm.tileentity.machine.storage.TileEntityCrateSteel;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.energy.IBatteryItem;
import api.hbm.energy.IEnergyUser;
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.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.tileentity.TileEntityHopper;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityMachineAssembler extends TileEntityMachineBase implements IEnergyUser, IGUIProvider {
public class TileEntityMachineAssembler extends TileEntityMachineAssemblerBase {
public int recipe = -1;
public long power;
public static final long maxPower = 100000;
public int progress;
public int maxProgress = 100;
public boolean isProgressing;
int age = 0;
int consumption = 100;
int speed = 100;
@SideOnly(Side.CLIENT)
public int recipe; //don't initialize this, retard
private AudioWrapper audio;
Random rand = new Random();
public TileEntityMachineAssembler() {
@ -82,52 +56,9 @@ public class TileEntityMachineAssembler extends TileEntityMachineBase implements
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);
this.power = nbt.getLong("powerTime");
this.progress = nbt.getInteger("progress");
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setLong("powerTime", power);
nbt.setInteger("progress", progress);
}
public long getPowerScaled(long i) {
return (power * i) / maxPower;
}
public int getProgressScaled(int i) {
return (progress * i) / maxProgress;
}
@Override
public void updateEntity() {
super.updateEntity();
if(!worldObj.isRemote) {
@ -170,77 +101,6 @@ public class TileEntityMachineAssembler extends TileEntityMachineBase implements
speed /= (overLevel + 1);
consumption *= (overLevel + 1);
isProgressing = false;
power = Library.chargeTEFromItems(slots, 0, power, maxPower);
if(AssemblerRecipes.getOutputFromTempate(slots[4]) != null && AssemblerRecipes.getRecipeFromTempate(slots[4]) != null) {
this.maxProgress = (ItemAssemblyTemplate.getProcessTime(slots[4]) * speed) / 100;
if(power >= consumption && removeItems(AssemblerRecipes.getRecipeFromTempate(slots[4]), cloneItemStackProper(slots))) {
if(slots[5] == null || (slots[5] != null && slots[5].getItem() == AssemblerRecipes.getOutputFromTempate(slots[4]).copy().getItem()) && slots[5].stackSize + AssemblerRecipes.getOutputFromTempate(slots[4]).copy().stackSize <= slots[5].getMaxStackSize()) {
progress++;
isProgressing = true;
if(progress >= maxProgress) {
progress = 0;
if(slots[5] == null) {
slots[5] = AssemblerRecipes.getOutputFromTempate(slots[4]).copy();
} else {
slots[5].stackSize += AssemblerRecipes.getOutputFromTempate(slots[4]).copy().stackSize;
}
removeItems(AssemblerRecipes.getRecipeFromTempate(slots[4]), slots);
if(slots[0] != null && slots[0].getItem() == ModItems.meteorite_sword_alloyed)
slots[0] = new ItemStack(ModItems.meteorite_sword_machined);
}
power -= consumption;
}
} else
progress = 0;
} else
progress = 0;
int meta = worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
TileEntity te1 = null;
TileEntity te2 = null;
if(meta == 14) {
te1 = worldObj.getTileEntity(xCoord - 2, yCoord, zCoord);
te2 = worldObj.getTileEntity(xCoord + 3, yCoord, zCoord - 1);
}
if(meta == 15) {
te1 = worldObj.getTileEntity(xCoord + 2, yCoord, zCoord);
te2 = worldObj.getTileEntity(xCoord - 3, yCoord, zCoord + 1);
}
if(meta == 13) {
te1 = worldObj.getTileEntity(xCoord, yCoord, zCoord + 2);
te2 = worldObj.getTileEntity(xCoord - 1, yCoord, zCoord - 3);
}
if(meta == 12) {
te1 = worldObj.getTileEntity(xCoord, yCoord, zCoord - 2);
te2 = worldObj.getTileEntity(xCoord + 1, yCoord, zCoord + 3);
}
tryExchangeTemplates(te1, te2);
//OUTPUT
if(te1 instanceof TileEntityCrateBase || te1 instanceof TileEntityChest) {
IInventory chest = (IInventory)te1;
tryFillContainer(chest, 5);
}
if(te2 instanceof TileEntityCrateBase || te2 instanceof TileEntityChest) {
IInventory chest = (IInventory)te2;
for(int i = 0; i < chest.getSizeInventory(); i++)
if(tryFillAssembler(chest, i))
break;
}
int rec = -1;
if(AssemblerRecipes.getOutputFromTempate(slots[4]) != null) {
ComparableStack comp = ItemAssemblyTemplate.readType(slots[4]);
@ -249,8 +109,8 @@ public class TileEntityMachineAssembler extends TileEntityMachineBase implements
NBTTagCompound data = new NBTTagCompound();
data.setLong("power", power);
data.setInteger("progress", progress);
data.setInteger("maxProgress", maxProgress);
data.setIntArray("progress", this.progress);
data.setIntArray("maxProgress", this.maxProgress);
data.setBoolean("isProgressing", isProgressing);
data.setInteger("recipe", rec);
this.networkPack(data, 150);
@ -278,6 +138,15 @@ public class TileEntityMachineAssembler extends TileEntityMachineBase implements
}
}
}
@Override
public void networkUnpack(NBTTagCompound nbt) {
this.power = nbt.getLong("power");
this.progress = nbt.getIntArray("progress");
this.maxProgress = nbt.getIntArray("maxProgress");
this.isProgressing = nbt.getBoolean("isProgressing");
this.recipe = nbt.getInteger("recipe");
}
@Override
public AudioWrapper createAudioLoop() {
@ -303,307 +172,65 @@ public class TileEntityMachineAssembler extends TileEntityMachineBase implements
new DirPos(xCoord - rot.offsetX * 2 + dir.offsetX, yCoord, zCoord - rot.offsetZ * 2 + dir.offsetZ, rot.getOpposite())
};
}
public void onChunkUnload() {
if(audio != null) {
audio.stopSound();
audio = null;
}
}
public void invalidate() {
super.invalidate();
if(audio != null) {
audio.stopSound();
audio = null;
}
}
public void networkUnpack(NBTTagCompound nbt) {
this.power = nbt.getLong("power");
this.progress = nbt.getInteger("progress");
this.maxProgress = nbt.getInteger("maxProgress");
this.isProgressing = nbt.getBoolean("isProgressing");
this.recipe = nbt.getInteger("recipe");
}
private boolean removeItems(List<AStack> stack, ItemStack[] array) {
if(stack == null)
return false;
for(int i = 0; i < stack.size(); i++) {
for(int j = 0; j < stack.get(i).stacksize; j++) {
AStack sta = stack.get(i).copy();
sta.stacksize = 1;
if(!canRemoveItemFromArray(sta, array))
return false;
}
}
return true;
}
public boolean canRemoveItemFromArray(AStack stack, ItemStack[] array) {
AStack st = stack.copy();
if(st == null)
return true;
for(int i = 6; i < 18; i++) {
if(array[i] != null) {
ItemStack sta = array[i].copy();
sta.stackSize = 1;
if(sta != null && st.isApplicable(sta) && array[i].stackSize > 0) {
array[i].stackSize--;
if(array[i].stackSize <= 0)
array[i] = null;
return true;
}
}
}
return false;
}
public boolean tryExchangeTemplates(TileEntity te1, TileEntity te2) {
//validateTe sees if it's a valid inventory tile entity
boolean te1Valid = validateTe(te1);
boolean te2Valid = validateTe(te2);
if(te1Valid && te2Valid){
IInventory iTe1 = (IInventory)te1;
IInventory iTe2 = (IInventory)te2;
boolean openSlot = false;
boolean existingTemplate = false;
boolean filledContainer = false;
//Check if there's an existing template and an open slot
for(int i = 0; i < iTe1.getSizeInventory(); i++){
if(iTe1.getStackInSlot(i) == null){
openSlot = true;
}
}
if(this.slots[4] != null){
existingTemplate = true;
}
//Check if there's a template in input
for(int i = 0; i < iTe2.getSizeInventory(); i++){
if(iTe2.getStackInSlot(i) != null && iTe2.getStackInSlot(i).getItem() instanceof ItemAssemblyTemplate){
if(openSlot && existingTemplate){
filledContainer = tryFillContainer(iTe1, 4);
}
if(filledContainer){
ItemStack copy = iTe2.getStackInSlot(i).copy();
iTe2.setInventorySlotContents(i, null);
this.slots[4] = copy;
}
}
}
}
return false;
}
private boolean validateTe(TileEntity te) {
if(te instanceof TileEntityChest) {
return true;
}
if(te instanceof TileEntityHopper) {
return true;
}
if(te instanceof TileEntityCrateIron) {
return true;
}
if(te instanceof TileEntityCrateSteel) {
return true;
}
return false;
}
//I can't believe that worked.
public ItemStack[] cloneItemStackProper(ItemStack[] array) {
ItemStack[] stack = new ItemStack[array.length];
for(int i = 0; i < array.length; i++)
if(array[i] != null)
stack[i] = array[i].copy();
else
stack[i] = null;
return stack;
}
//Unloads output into chests
public boolean tryFillContainer(IInventory inventory, int slot) {
int size = inventory.getSizeInventory();
for(int i = 0; i < size; i++) {
if(inventory.getStackInSlot(i) != null) {
if(slots[slot] == null)
return false;
ItemStack sta1 = inventory.getStackInSlot(i).copy();
ItemStack sta2 = slots[slot].copy();
if(sta1 != null && sta2 != null) {
sta1.stackSize = 1;
sta2.stackSize = 1;
if(ItemStack.areItemStacksEqual(sta1, sta2) && ItemStack.areItemStackTagsEqual(sta1, sta2) && inventory.getStackInSlot(i).stackSize < inventory.getStackInSlot(i).getMaxStackSize()) {
slots[slot].stackSize--;
if(slots[slot].stackSize <= 0)
slots[slot] = null;
ItemStack sta3 = inventory.getStackInSlot(i).copy();
sta3.stackSize++;
inventory.setInventorySlotContents(i, sta3);
return true;
}
}
}
}
for(int i = 0; i < size; i++) {
if(slots[slot] == null)
return false;
ItemStack sta2 = slots[slot].copy();
if(inventory.getStackInSlot(i) == null && sta2 != null) {
sta2.stackSize = 1;
slots[slot].stackSize--;
if(slots[slot].stackSize <= 0)
slots[slot] = null;
inventory.setInventorySlotContents(i, sta2);
return true;
}
}
return false;
}
public boolean tryFillAssembler(IInventory inventory, int slot) {
if(AssemblerRecipes.getOutputFromTempate(slots[4]) == null || AssemblerRecipes.getRecipeFromTempate(slots[4]) == null)
return false;
else {
List<AStack> list = copyItemStackList(AssemblerRecipes.getRecipeFromTempate(slots[4]));
for(int i = 0; i < list.size(); i++)
list.get(i).stacksize = 1;
if(inventory.getStackInSlot(slot) == null)
return false;
ItemStack stack = inventory.getStackInSlot(slot).copy();
stack.stackSize = 1;
boolean flag = false;
for(int i = 0; i < list.size(); i++)
if(list.get(i).isApplicable(stack))
flag = true;
if(!flag)
return false;
}
for(int i = 6; i < 18; i++) {
if(slots[i] != null) {
ItemStack sta1 = inventory.getStackInSlot(slot).copy();
ItemStack sta2 = slots[i].copy();
if(sta1 != null && sta2 != null) {
sta1.stackSize = 1;
sta2.stackSize = 1;
if(sta1.isItemEqual(sta2) && slots[i].stackSize < slots[i].getMaxStackSize()) {
ItemStack sta3 = inventory.getStackInSlot(slot).copy();
sta3.stackSize--;
if(sta3.stackSize <= 0)
sta3 = null;
inventory.setInventorySlotContents(slot, sta3);
slots[i].stackSize++;
return true;
}
}
}
}
for(int i = 6; i < 18; i++) {
ItemStack sta2 = inventory.getStackInSlot(slot).copy();
if(slots[i] == null && sta2 != null) {
sta2.stackSize = 1;
slots[i] = sta2.copy();
ItemStack sta3 = inventory.getStackInSlot(slot).copy();
sta3.stackSize--;
if(sta3.stackSize <= 0)
sta3 = null;
inventory.setInventorySlotContents(slot, sta3);
return true;
}
}
return false;
}
public static List<AStack> copyItemStackList(List<AStack> list){
List<AStack> newList = new ArrayList<AStack>();
if(list == null || list.isEmpty())
return newList;
for(AStack stack : list){
newList.add(stack.copy());
}
return newList;
}
@Override
public void setPower(long i) {
power = i;
public void onChunkUnload() {
if(audio != null) {
audio.stopSound();
audio = null;
}
}
@Override
public long getPower() {
return power;
public void invalidate() {
super.invalidate();
if(audio != null) {
audio.stopSound();
audio = null;
}
}
private AudioWrapper audio;
@Override
public int getRecipeCount() {
return 1;
}
@Override
public int getTemplateIndex(int index) {
return 4;
}
@Override
public int[] getSlotIndicesFromIndex(int index) {
return new int[] {6, 17, 5};
}
@Override
public ChunkCoordinates[] getInputPositions() {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
return new ChunkCoordinates[] {new ChunkCoordinates(xCoord - dir.offsetX * 3 + rot.offsetX, yCoord, zCoord - dir.offsetZ * 3 + rot.offsetZ)};
}
@Override
public ChunkCoordinates[] getOutputPositions() {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
return new ChunkCoordinates[] {new ChunkCoordinates(xCoord + dir.offsetX * 2, yCoord, zCoord + dir.offsetZ * 2)};
}
@Override
public int getPowerSlot() {
return 0;
}
@Override
public long getMaxPower() {
return maxPower;
return 100_000;
}
@Override

View File

@ -9,6 +9,7 @@ import com.hbm.items.machine.ItemAssemblyTemplate;
import com.hbm.lib.Library;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.tileentity.machine.storage.TileEntityCrateTemplate;
import com.hbm.util.InventoryUtil;
import api.hbm.energy.IEnergyUser;
@ -24,6 +25,7 @@ public abstract class TileEntityMachineAssemblerBase extends TileEntityMachineBa
public int[] progress;
public int[] maxProgress;
public boolean isProgressing;
public boolean[] needsTemplateSwitch;
int consumption = 100;
int speed = 100;
@ -35,6 +37,7 @@ public abstract class TileEntityMachineAssemblerBase extends TileEntityMachineBa
progress = new int[count];
maxProgress = new int[count];
needsTemplateSwitch = new boolean[count];
}
@Override
@ -45,11 +48,11 @@ public abstract class TileEntityMachineAssemblerBase extends TileEntityMachineBa
int count = this.getRecipeCount();
this.isProgressing = false;
this.power = Library.chargeTEFromItems(slots, 0, power, this.getMaxPower());
this.power = Library.chargeTEFromItems(slots, getPowerSlot(), power, this.getMaxPower());
for(int i = 0; i < count; i++) {
loadItems(i);
unloadItems(i);
loadItems(i);
}
@ -114,6 +117,7 @@ public abstract class TileEntityMachineAssemblerBase extends TileEntityMachineBa
consumeItems(recipe, index);
produceItems(output, index);
this.progress[index] = 0;
this.needsTemplateSwitch[index] = true;
this.markDirty();
}
}
@ -140,53 +144,76 @@ public abstract class TileEntityMachineAssemblerBase extends TileEntityMachineBa
private void loadItems(int index) {
int template = getTemplateIndex(index);
if(slots[template] == null || slots[template].getItem() != ModItems.assembly_template)
return;
List<AStack> recipe = AssemblerRecipes.getRecipeFromTempate(slots[template]);
if(recipe != null) {
ChunkCoordinates[] positions = getInputPositions();
int[] indices = getSlotIndicesFromIndex(index);
for(ChunkCoordinates coord : positions) {
ChunkCoordinates[] positions = getInputPositions();
int[] indices = getSlotIndicesFromIndex(index);
for(ChunkCoordinates coord : positions) {
TileEntity te = worldObj.getTileEntity(coord.posX, coord.posY, coord.posZ);
TileEntity te = worldObj.getTileEntity(coord.posX, coord.posY, coord.posZ);
if(te instanceof IInventory) {
if(te instanceof IInventory) {
IInventory inv = (IInventory) te;
ISidedInventory sided = inv instanceof ISidedInventory ? (ISidedInventory) inv : null;
boolean templateCrate = te instanceof TileEntityCrateTemplate;
if(templateCrate && slots[template] == null) {
for(int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if(stack != null && stack.getItem() == ModItems.assembly_template && (sided == null || sided.canExtractItem(i, stack, 0))) {
slots[template] = stack.copy();
sided.setInventorySlotContents(i, null);
this.needsTemplateSwitch[index] = false;
break;
}
}
}
IInventory inv = (IInventory) te;
ISidedInventory sided = inv instanceof ISidedInventory ? (ISidedInventory) inv : null;
for(AStack ingredient : recipe) {
if(!InventoryUtil.doesArrayHaveIngredients(slots, indices[0], indices[1], ingredient)) {
for(int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if(ingredient.matchesRecipe(stack, true) && (sided == null || sided.canExtractItem(i, stack, 0))) {
for(int j = indices[0]; j <= indices[1]; j++) {
if(slots[j] != null && slots[j].stackSize < slots[j].getMaxStackSize() & InventoryUtil.doesStackDataMatch(slots[j], stack)) {
inv.decrStackSize(i, 1);
slots[j].stackSize++;
return;
boolean noTemplate = slots[template] == null || slots[template].getItem() != ModItems.assembly_template;
if(!noTemplate) {
List<AStack> recipe = AssemblerRecipes.getRecipeFromTempate(slots[template]);
if(recipe != null) {
for(AStack ingredient : recipe) {
outer: while(!InventoryUtil.doesArrayHaveIngredients(slots, indices[0], indices[1], ingredient)) {
boolean found = false;
for(int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if(ingredient.matchesRecipe(stack, true) && (sided == null || sided.canExtractItem(i, stack, 0))) {
found = true;
for(int j = indices[0]; j <= indices[1]; j++) {
if(slots[j] != null && slots[j].stackSize < slots[j].getMaxStackSize() & InventoryUtil.doesStackDataMatch(slots[j], stack)) {
inv.decrStackSize(i, 1);
slots[j].stackSize++;
continue outer;
}
}
}
for(int j = indices[0]; j <= indices[1]; j++) {
if(slots[j] == null) {
slots[j] = stack.copy();
slots[j].stackSize = 1;
inv.decrStackSize(i, 1);
return;
for(int j = indices[0]; j <= indices[1]; j++) {
if(slots[j] == null) {
slots[j] = stack.copy();
slots[j].stackSize = 1;
inv.decrStackSize(i, 1);
continue outer;
}
}
}
}
if(!found) return;
}
}
}
@ -209,8 +236,13 @@ public abstract class TileEntityMachineAssemblerBase extends TileEntityMachineBa
IInventory inv = (IInventory) te;
int i = indices[2];
ItemStack out = slots[i];
int template = getTemplateIndex(index);
if(this.needsTemplateSwitch[index] && te instanceof TileEntityCrateTemplate && slots[template] != null) {
out = slots[template];
i = template;
}
if(out != null) {
@ -266,4 +298,5 @@ public abstract class TileEntityMachineAssemblerBase extends TileEntityMachineBa
public abstract int[] getSlotIndicesFromIndex(int index);
public abstract ChunkCoordinates[] getInputPositions();
public abstract ChunkCoordinates[] getOutputPositions();
public abstract int getPowerSlot();
}

View File

@ -1,21 +1,15 @@
package com.hbm.tileentity.machine;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.hbm.blocks.BlockDummyable;
import com.hbm.interfaces.IFluidAcceptor;
import com.hbm.interfaces.IFluidSource;
import com.hbm.inventory.UpgradeManager;
import com.hbm.inventory.container.ContainerAssemfac;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank;
import com.hbm.inventory.gui.GUIAssemfac;
import com.hbm.items.machine.ItemMachineUpgrade;
import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType;
import com.hbm.lib.Library;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.fluid.IFluidStandardTransceiver;
@ -31,7 +25,7 @@ import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityMachineAssemfac extends TileEntityMachineAssemblerBase implements IFluidStandardTransceiver, IFluidAcceptor, IFluidSource {
public class TileEntityMachineAssemfac extends TileEntityMachineAssemblerBase implements IFluidStandardTransceiver {
public AssemblerArm[] arms;
@ -46,8 +40,8 @@ public class TileEntityMachineAssemfac extends TileEntityMachineAssemblerBase im
arms[i] = new AssemblerArm(i % 3 == 1 ? 1 : 0); //the second of every group of three becomes a welder
}
water = new FluidTank(Fluids.WATER, 64_000, 0);
steam = new FluidTank(Fluids.SPENTSTEAM, 64_000, 1);
water = new FluidTank(Fluids.WATER, 64_000);
steam = new FluidTank(Fluids.SPENTSTEAM, 64_000);
}
@Override
@ -94,10 +88,6 @@ public class TileEntityMachineAssemfac extends TileEntityMachineAssemblerBase im
this.sendFluid(steam, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
}
if(steam.getFill() > 0) {
this.fillFluidInit(steam.getTankType());
}
NBTTagCompound data = new NBTTagCompound();
data.setLong("power", this.power);
data.setIntArray("progress", this.progress);
@ -402,6 +392,11 @@ public class TileEntityMachineAssemfac extends TileEntityMachineAssemblerBase im
return outpos;
}
@Override
public int getPowerSlot() {
return 0;
}
@Override
public FluidTank[] getSendingTanks() {
return new FluidTank[] { steam };
@ -412,59 +407,6 @@ public class TileEntityMachineAssemfac extends TileEntityMachineAssemblerBase im
return new FluidTank[] { water };
}
@Override
public void setFillForSync(int fill, int index) { }
@Override
public void setFluidFill(int fill, FluidType type) {
if(type == water.getTankType()) water.setFill(fill);
if(type == steam.getTankType()) steam.setFill(fill);
}
@Override
public void setTypeForSync(FluidType type, int index) { }
@Override
public int getFluidFill(FluidType type) {
if(type == water.getTankType()) return water.getFill();
if(type == steam.getTankType()) return steam.getFill();
return 0;
}
@Override
public void fillFluidInit(FluidType type) {
for(DirPos pos : getConPos()) {
this.fillFluid(pos.getX(), pos.getY(), pos.getZ(), this.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 boolean getTact() {
return worldObj.getTotalWorldTime() % 2 == 0;
}
private List<IFluidAcceptor> list = new ArrayList();
@Override
public List<IFluidAcceptor> getFluidList(FluidType type) {
return type == steam.getTankType() ? this.list : new ArrayList();
}
@Override
public void clearFluidList(FluidType type) {
this.list.clear();
}
@Override
public int getMaxFluidFill(FluidType type) {
return type == water.getTankType() ? water.getMaxFill() : 0;
}
@Override
public FluidTank[] getAllTanks() {
return new FluidTank[] { water, steam };

View File

@ -364,7 +364,10 @@ public class TileEntityMachineChemplant extends TileEntityMachineBase implements
for(AStack ingredient : recipe.inputs) {
if(!InventoryUtil.doesArrayHaveIngredients(slots, 13, 16, ingredient)) {
outer:
while(!InventoryUtil.doesArrayHaveIngredients(slots, 13, 16, ingredient)) {
boolean found = false;
for(int i = 0; i < inv.getSizeInventory(); i++) {
@ -376,7 +379,7 @@ public class TileEntityMachineChemplant extends TileEntityMachineBase implements
if(slots[j] != null && slots[j].stackSize < slots[j].getMaxStackSize() & InventoryUtil.doesStackDataMatch(slots[j], stack)) {
inv.decrStackSize(i, 1);
slots[j].stackSize++;
return;
continue outer;
}
}
@ -386,11 +389,13 @@ public class TileEntityMachineChemplant extends TileEntityMachineBase implements
slots[j] = stack.copy();
slots[j].stackSize = 1;
inv.decrStackSize(i, 1);
return;
continue outer;
}
}
}
}
if(!found) return;
}
}
}

View File

@ -214,7 +214,10 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
for(AStack ingredient : recipe.inputs) {
if(!InventoryUtil.doesArrayHaveIngredients(slots, indices[0], indices[1], ingredient)) {
outer:
while(!InventoryUtil.doesArrayHaveIngredients(slots, indices[0], indices[1], ingredient)) {
boolean found = false;
for(int i = 0; i < inv.getSizeInventory(); i++) {
@ -226,7 +229,7 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
if(slots[j] != null && slots[j].stackSize < slots[j].getMaxStackSize() & InventoryUtil.doesStackDataMatch(slots[j], stack)) {
inv.decrStackSize(i, 1);
slots[j].stackSize++;
return;
continue outer;
}
}
@ -236,11 +239,13 @@ public abstract class TileEntityMachineChemplantBase extends TileEntityMachineBa
slots[j] = stack.copy();
slots[j].stackSize = 1;
inv.decrStackSize(i, 1);
return;
continue outer;
}
}
}
}
if(!found) return;
}
}
}

View File

@ -31,6 +31,4 @@ public class TileEntityCrateIron extends TileEntityCrateBase {
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GUICrateIron(player.inventory, this);
}
}

View File

@ -8,10 +8,9 @@ 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.world.World;
public class TileEntityCrateSteel extends TileEntityCrateBase implements ISidedInventory {
public class TileEntityCrateSteel extends TileEntityCrateBase {
public TileEntityCrateSteel() {
super(54);

View File

@ -0,0 +1,34 @@
package com.hbm.tileentity.machine.storage;
import com.hbm.inventory.container.ContainerCrateTemplate;
import com.hbm.inventory.gui.GUICrateTemplate;
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.world.World;
public class TileEntityCrateTemplate extends TileEntityCrateBase {
public TileEntityCrateTemplate() {
super(27);
}
@Override
public String getInventoryName() {
return this.hasCustomInventoryName() ? this.customName : "container.crateTemplate";
}
@Override
public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new ContainerCrateTemplate(player.inventory, this);
}
@Override
@SideOnly(Side.CLIENT)
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GUICrateTemplate(player.inventory, this);
}
}

View File

@ -293,6 +293,7 @@ container.craneUnboxer=Förderband-Entpacker
container.crateDesh=Deshkiste
container.crateIron=Eisenkiste
container.crateSteel=Stahlkiste
container.crateTemplate=Vorlagenkiste
container.crateTungsten=Wolframkiste
container.crystallizer=Erzauflöser
container.cyclotron=Zyklotron
@ -3715,6 +3716,7 @@ tile.crate_lead.name=Gefahrenstoffkiste
tile.crate_metal.name=Maschinenkiste
tile.crate_red.name=Rote Kiste
tile.crate_steel.name=Stahlkiste
tile.crate_template.name=Vorlagenkiste
tile.crate_tungsten.name=Wolframkiste
tile.crate_weapon.name=Waffenkiste
tile.crystal_hardened.name=Gehärteter Dunkler Kristall

View File

@ -629,6 +629,7 @@ container.craneUnboxer=Conveyor Unboxer
container.crateDesh=Desh Crate
container.crateIron=Iron Crate
container.crateSteel=Steel Crate
container.crateTemplate=Template Crate
container.crateTungsten=Tungsten Crate
container.crystallizer=Ore Acidizer
container.cyclotron=Cyclotron
@ -4587,6 +4588,7 @@ tile.crate_lead.name=Hazmat Crate
tile.crate_metal.name=Machine Crate
tile.crate_red.name=Red Crate
tile.crate_steel.name=Steel Crate
tile.crate_template.name=Template Crate
tile.crate_tungsten.name=Tungsten Crate
tile.crate_weapon.name=Weapon Crate
tile.crystal_hardened.name=Hardened Dark Crystal

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB