diff --git a/build.gradle b/build.gradle index 07cca4635..4e7e8f7f4 100644 --- a/build.gradle +++ b/build.gradle @@ -79,6 +79,18 @@ repositories { // name = "CurseForge" // url = "https://minecraft.curseforge.com/api/maven/" //} + maven { + name = "Jitpack" + url = "https://jitpack.io" + } + maven { + name = "CurseMaven" + url = "https://cursemaven.com" + } + maven { + name = "OpenComputers" + url = "https://maven.cil.li/" + } } dependencies { @@ -94,6 +106,8 @@ dependencies { compileOnly "inventorytweaks:InventoryTweaks:1.59-dev:deobf" implementation "li.cil.oc:OpenComputers:MC1.7.10-1.5.+:api" + + compileOnly "com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta.56-GTNH:dev" } processResources { diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 106dbe846..7ecdc698a 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -791,6 +791,7 @@ public class ModBlocks { public static Block fluid_duct_paintable; public static Block fluid_duct_gauge; public static Block fluid_duct_exhaust; + public static Block fluid_duct_paintable_block_exhaust; public static Block fluid_valve; public static Block fluid_switch; public static Block fluid_pump; @@ -1920,6 +1921,7 @@ public class ModBlocks { fluid_duct_neo = new FluidDuctStandard(Material.iron).setBlockName("fluid_duct_neo").setStepSound(ModSoundTypes.pipe).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":pipe_neo"); fluid_duct_box = new FluidDuctBox(Material.iron).setBlockName("fluid_duct_box").setStepSound(ModSoundTypes.pipe).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":fluid_duct_box"); fluid_duct_exhaust = new FluidDuctBoxExhaust(Material.iron).setBlockName("fluid_duct_exhaust").setStepSound(ModSoundTypes.pipe).setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":fluid_duct_box"); + fluid_duct_paintable_block_exhaust = new FluidDuctPaintableBlockExhaust().setBlockName("fluid_duct_paintable_block_exhaust").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); fluid_duct_paintable = new FluidDuctPaintable().setBlockName("fluid_duct_paintable").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); fluid_duct_gauge = new FluidDuctGauge().setBlockName("fluid_duct_gauge").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); fluid_valve = new FluidValve(Material.iron).setBlockName("fluid_valve").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab); @@ -3187,6 +3189,7 @@ public class ModBlocks { register(fluid_duct_neo); register(fluid_duct_box); register(fluid_duct_exhaust); + register(fluid_duct_paintable_block_exhaust); register(fluid_duct_paintable); register(fluid_duct_gauge); register(fluid_valve); diff --git a/src/main/java/com/hbm/blocks/machine/MachineRotaryFurnace.java b/src/main/java/com/hbm/blocks/machine/MachineRotaryFurnace.java index 1f5e3d119..e252c8445 100644 --- a/src/main/java/com/hbm/blocks/machine/MachineRotaryFurnace.java +++ b/src/main/java/com/hbm/blocks/machine/MachineRotaryFurnace.java @@ -1,15 +1,23 @@ package com.hbm.blocks.machine; import com.hbm.blocks.BlockDummyable; +import com.hbm.blocks.ILookOverlay; import com.hbm.tileentity.TileEntityProxyCombo; import com.hbm.tileentity.machine.TileEntityMachineRotaryFurnace; +import com.hbm.util.fauxpointtwelve.DirPos; +import com.hbm.util.i18n.I18nUtil; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; 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; -public class MachineRotaryFurnace extends BlockDummyable { +import java.util.ArrayList; +import java.util.List; + +public class MachineRotaryFurnace extends BlockDummyable implements ILookOverlay { public MachineRotaryFurnace(Material mat) { super(mat); @@ -56,4 +64,54 @@ public class MachineRotaryFurnace extends BlockDummyable { //solid fuel this.makeExtra(world, x + dir.offsetX + rot.offsetX, y, z + dir.offsetZ + rot.offsetZ); } + + @Override + public void printHook(RenderGameOverlayEvent.Pre event, World world, int x, int y, int z) { + + int[] pos = this.findCore(world, x, y, z); + + if(pos == null) return; + + TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]); + + if(!(te instanceof TileEntityMachineRotaryFurnace)) return; + + TileEntityMachineRotaryFurnace furnace = (TileEntityMachineRotaryFurnace) te; + + ForgeDirection dir = ForgeDirection.getOrientation(furnace.getBlockMetadata() - offset); + + List text = new ArrayList<>(); + + //steam + if(hitCheck(dir, pos[0], pos[1], pos[2], -1, -1, 0, x, y, z) || hitCheck(dir, pos[0], pos[1], pos[2], -1, -2, 0, x, y, z)) { + text.add(EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + furnace.tanks[1].getTankType().getLocalizedName()); + text.add(EnumChatFormatting.RED + "<- " + EnumChatFormatting.RESET + furnace.tanks[2].getTankType().getLocalizedName()); + } + + //fluids + if(hitCheck(dir, pos[0], pos[1], pos[2], 1, 2, 0, x, y, z) || hitCheck(dir, pos[0], pos[1], pos[2], -1, 2, 0, x, y, z)) { + text.add(EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + furnace.tanks[0].getTankType().getLocalizedName()); + } + + if(hitCheck(dir, pos[0], pos[1], pos[2], 1, 1, 0, x, y, z)) { + text.add(EnumChatFormatting.YELLOW + "-> " + EnumChatFormatting.RESET + "Fuel"); + } + + + if(!text.isEmpty()) { + ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text); + } + } + + protected boolean hitCheck(ForgeDirection dir, int coreX, int coreY, int coreZ, int exDir, int exRot, int exY, int hitX, int hitY, int hitZ) { + + ForgeDirection turn = dir.getRotation(ForgeDirection.DOWN); + + int iX = coreX + dir.offsetX * exDir + turn.offsetX * exRot; + int iY = coreY + exY; + int iZ = coreZ + dir.offsetZ * exDir + turn.offsetZ * exRot; + + return iX == hitX && iZ == hitZ && iY == hitY; + } + } diff --git a/src/main/java/com/hbm/blocks/network/FluidDuctPaintableBlockExhaust.java b/src/main/java/com/hbm/blocks/network/FluidDuctPaintableBlockExhaust.java new file mode 100644 index 000000000..f57b6f9b1 --- /dev/null +++ b/src/main/java/com/hbm/blocks/network/FluidDuctPaintableBlockExhaust.java @@ -0,0 +1,212 @@ +package com.hbm.blocks.network; + +import api.hbm.block.IToolable; + +import com.hbm.blocks.IBlockMultiPass; +import com.hbm.blocks.ILookOverlay; +import com.hbm.interfaces.ICopiable; +import com.hbm.inventory.fluid.Fluids; +import com.hbm.lib.Library; +import com.hbm.lib.RefStrings; +import com.hbm.render.block.RenderBlockMultipass; +import com.hbm.tileentity.network.TileEntityPipeExhaust; +import com.hbm.util.i18n.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.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.ArrayList; +import java.util.List; + +public class FluidDuctPaintableBlockExhaust extends FluidDuctBase implements IToolable, IBlockMultiPass, ILookOverlay { + + @SideOnly(Side.CLIENT) protected IIcon overlay; + + public FluidDuctPaintableBlockExhaust() { + super(Material.iron); + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEntityPipeExhaustPaintable(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + this.blockIcon = reg.registerIcon(RefStrings.MODID + ":fluid_duct_paintable_block_exhaust"); + this.overlay = reg.registerIcon(RefStrings.MODID + ":fluid_duct_paintable_overlay"); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + TileEntity tile = world.getTileEntity(x, y, z); + + if(tile instanceof TileEntityPipeExhaustPaintable) { + TileEntityPipeExhaustPaintable pipe = (TileEntityPipeExhaustPaintable) tile; + + if(pipe.block != null) { + if(RenderBlockMultipass.currentPass == 1) { + return this.overlay; + } else { + return pipe.block.getIcon(side, pipe.meta); + } + } + } + + return this.blockIcon; + } + + @Override + public boolean onScrew(World world, EntityPlayer player, int x, int y, int z, int side, float fX, float fY, float fZ, ToolType tool) { + + if(tool != ToolType.SCREWDRIVER) return false; + + TileEntity tile = world.getTileEntity(x, y, z); + + if(tile instanceof TileEntityPipeExhaustPaintable) { + TileEntityPipeExhaustPaintable pipe = (TileEntityPipeExhaustPaintable) tile; + + if(pipe.block != null) { + pipe.block = null; + world.markBlockForUpdate(x, y, z); + pipe.markDirty(); + return true; + } + } + + return false; + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float fX, float fY, float fZ) { + + ItemStack stack = player.getHeldItem(); + + if(stack != null && stack.getItem() instanceof ItemBlock) { + ItemBlock ib = (ItemBlock) stack.getItem(); + Block block = ib.field_150939_a; + + if(block.renderAsNormalBlock() && block != this) { + + TileEntity tile = world.getTileEntity(x, y, z); + + if(tile instanceof TileEntityPipeExhaustPaintable) { + TileEntityPipeExhaustPaintable pipe = (TileEntityPipeExhaustPaintable) tile; + + if(pipe.block == null) { + pipe.block = block; + pipe.meta = stack.getItemDamage() & 15; + world.markBlockForUpdate(x, y, z); + pipe.markDirty(); + return true; + } + } + } + } + + return super.onBlockActivated(world, x, y, z, player, side, fX, fY, fZ); + } + + @Override + public int getPasses() { + return 2; + } + + @Override + public int getRenderType(){ + return IBlockMultiPass.getRenderType(); + } + + @Override + public void printHook(Pre event, World world, int x, int y, int z) { + List text = new ArrayList(); + text.add(Fluids.SMOKE.getLocalizedName()); + text.add(Fluids.SMOKE_LEADED.getLocalizedName()); + text.add(Fluids.SMOKE_POISON.getLocalizedName()); + ILookOverlay.printGeneric(event, I18nUtil.resolveKey(getUnlocalizedName() + ".name"), 0xffff00, 0x404000, text); + } + + public static class TileEntityPipeExhaustPaintable extends TileEntityPipeExhaust implements ICopiable { + + private Block block; + private int meta; + private Block lastBlock; + private int lastMeta; + + @Override + public void updateEntity() { + super.updateEntity(); + + if(worldObj.isRemote && (lastBlock != block || lastMeta != meta)) { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + lastBlock = block; + lastMeta = meta; + } + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbt = new NBTTagCompound(); + this.writeToNBT(nbt); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbt); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + this.readFromNBT(pkt.func_148857_g()); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + int id = nbt.getInteger("block"); + this.block = id == 0 ? null : Block.getBlockById(id); + this.meta = nbt.getInteger("meta"); + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + if(block != null) nbt.setInteger("block", Block.getIdFromBlock(block)); + nbt.setInteger("meta", meta); + } + + @Override + public NBTTagCompound getSettings(World world, int x, int y, int z) { + NBTTagCompound nbt = new NBTTagCompound(); + if(block != null) { + nbt.setInteger("paintblock", Block.getIdFromBlock(block)); + nbt.setInteger("paintmeta", meta); + } + return nbt; + } + + @Override + public void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) { + if(nbt.hasKey("paintblock")) { + this.block = Block.getBlockById(nbt.getInteger("paintblock")); + this.meta = nbt.getInteger("paintmeta"); + } + } + } +} diff --git a/src/main/java/com/hbm/config/CommonConfig.java b/src/main/java/com/hbm/config/CommonConfig.java index 7fce253e8..d6ead8f95 100644 --- a/src/main/java/com/hbm/config/CommonConfig.java +++ b/src/main/java/com/hbm/config/CommonConfig.java @@ -81,8 +81,8 @@ public class CommonConfig { prop.comment = comment; return prop.getIntList(); } - public static String[] createConfigStringList(Configuration config, String category, String name, String comment) { - Property prop = config.get(category, name, new String[] { "PLACEHOLDER" }); + public static String[] createConfigStringList(Configuration config, String category, String name, String comment, String[] def) { + Property prop = config.get(category, name, def); prop.comment = comment; return prop.getStringList(); } diff --git a/src/main/java/com/hbm/config/GeneralConfig.java b/src/main/java/com/hbm/config/GeneralConfig.java index 09900f007..c843cde57 100644 --- a/src/main/java/com/hbm/config/GeneralConfig.java +++ b/src/main/java/com/hbm/config/GeneralConfig.java @@ -1,7 +1,7 @@ package com.hbm.config; import net.minecraftforge.common.config.Configuration; - +import com.hbm.lib.RefStrings; public class GeneralConfig { public static boolean enableThermosPreventer = true; @@ -70,6 +70,7 @@ public class GeneralConfig { public static boolean enableLBSMSafeMEDrives = true; public static boolean enableLBSMIGen = true; public static int schrabRate = 20; + public static String[] preferredOutputMod = new String[] {RefStrings.MODID}; public static void loadFromConfig(Configuration config) { @@ -117,7 +118,8 @@ public class GeneralConfig { normalSoundChannels = CommonConfig.createConfigInt(config, CATEGORY_GENERAL, "1.41_normalSoundChannels", "The amount of channels to create while 1.39_enableSoundExtension is enabled.\n" + "Note that a value below 28 or above 200 can cause buggy sounds and issues with other mods running out of sound memory.", 100); - + preferredOutputMod = CommonConfig.createConfigStringList(config,CATEGORY_GENERAL,"1.42_preferredOutputMod", + "The mod which is preferred as output when certain machines autogenerate recipes. Currently used for the shredder", new String[] {RefStrings.MODID}); enableExpensiveMode = config.get(CATEGORY_GENERAL, "1.99_enableExpensiveMode", false, "It does what the name implies.").getBoolean(false); final String CATEGORY_528 = CommonConfig.CATEGORY_528; diff --git a/src/main/java/com/hbm/entity/particle/EntityModFX.java b/src/main/java/com/hbm/entity/particle/EntityModFX.java index e416965d4..16efa997f 100644 --- a/src/main/java/com/hbm/entity/particle/EntityModFX.java +++ b/src/main/java/com/hbm/entity/particle/EntityModFX.java @@ -31,7 +31,6 @@ public class EntityModFX extends Entity public static double interpPosX; public static double interpPosY; public static double interpPosZ; - public static final String __OBFID = "CL_00000914"; float smokeParticleScale; public int particleAge; public int maxAge; @@ -39,7 +38,7 @@ public class EntityModFX extends Entity public EntityModFX(World world) { super(world); } - + protected EntityModFX(World p_i1218_1_, double p_i1218_2_, double p_i1218_4_, double p_i1218_6_) { super(p_i1218_1_); @@ -257,7 +256,7 @@ public class EntityModFX extends Entity { return this.getClass().getSimpleName() + ", Pos (" + this.posX + "," + this.posY + "," + this.posZ + "), RGBA (" + this.particleRed + "," + this.particleGreen + "," + this.particleBlue + "," + this.particleAlpha + "), Age " + this.particleAge; } - + @Override @SideOnly(Side.CLIENT) public boolean isInRangeToRenderDist(double distance) diff --git a/src/main/java/com/hbm/handler/ae2/AE2CompatHandler.java b/src/main/java/com/hbm/handler/ae2/AE2CompatHandler.java new file mode 100644 index 000000000..b40571179 --- /dev/null +++ b/src/main/java/com/hbm/handler/ae2/AE2CompatHandler.java @@ -0,0 +1,18 @@ +package com.hbm.handler.ae2; + +import appeng.api.AEApi; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.Optional; + +public class AE2CompatHandler { + public static void init() { + if (Loader.isModLoaded("appliedenergistics2")) { + registerHandler(); + } + } + + @Optional.Method(modid = "appliedenergistics2") + private static void registerHandler() { + AEApi.instance().registries().externalStorage().addExternalStorageInterface(new MSUExternalStorageHandler()); + } +} diff --git a/src/main/java/com/hbm/handler/ae2/MSUExternalStorageHandler.java b/src/main/java/com/hbm/handler/ae2/MSUExternalStorageHandler.java new file mode 100644 index 000000000..fe82feb00 --- /dev/null +++ b/src/main/java/com/hbm/handler/ae2/MSUExternalStorageHandler.java @@ -0,0 +1,46 @@ +package com.hbm.handler.ae2; + +import com.hbm.tileentity.machine.storage.TileEntityMassStorage; +import com.hbm.util.ItemStackUtil; +import cpw.mods.fml.common.Optional; + +import appeng.api.networking.security.BaseActionSource; +import appeng.api.storage.IExternalStorageHandler; +import appeng.api.storage.IMEInventory; +import appeng.api.storage.StorageChannel; +import appeng.api.storage.data.IAEItemStack; +import appeng.me.storage.MEMonitorIInventory; +import appeng.util.inv.IMEAdaptor; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +@Optional.InterfaceList({@Optional.Interface(iface = "appeng.api.storage.IExternalStorageHandler", modid = "appliedenergistics2")}) +public class MSUExternalStorageHandler implements IExternalStorageHandler { + + public MSUExternalStorageHandler() {} + + @Override + public boolean canHandle(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc) { + return channel == StorageChannel.ITEMS && te instanceof TileEntityMassStorage; + } + + @Override + public IMEInventory getInventory(TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src) { + if (!canHandle(te, d, channel, src)) + return null; + + // Note: apparently I need this, though I'm not sure why. Storage drawers does it. + // Here's a relevant discussion, if anyone wants to dive into that rabbit hole: + // https://github.com/AppliedEnergistics/Applied-Energistics-2/issues/418 + return new MEMonitorIInventory(new IMEAdaptor(new MassStorageMEInventory((TileEntityMassStorage)te), src)) { + @Override + public boolean isPrioritized(IAEItemStack stack) { + ItemStack type = ((TileEntityMassStorage)te).getType(); + + return type != null && ItemStackUtil.areStacksCompatible(stack.getItemStack(), type); + } + }; + } + +} diff --git a/src/main/java/com/hbm/handler/ae2/MassStorageMEInventory.java b/src/main/java/com/hbm/handler/ae2/MassStorageMEInventory.java new file mode 100644 index 000000000..848e2c053 --- /dev/null +++ b/src/main/java/com/hbm/handler/ae2/MassStorageMEInventory.java @@ -0,0 +1,85 @@ +package com.hbm.handler.ae2; + +import com.hbm.tileentity.machine.storage.TileEntityMassStorage; +import com.hbm.util.ItemStackUtil; + +import cpw.mods.fml.common.Optional; + +import appeng.api.AEApi; +import appeng.api.config.Actionable; +import appeng.api.networking.security.BaseActionSource; +import appeng.api.storage.IMEInventory; +import appeng.api.storage.StorageChannel; +import appeng.api.storage.data.IAEItemStack; +import appeng.api.storage.data.IItemList; +import net.minecraft.item.ItemStack; + +@Optional.InterfaceList({@Optional.Interface(iface = "appeng.api.storage.IMEInventory", modid = "appliedenergistics2")}) +public class MassStorageMEInventory implements IMEInventory { + + private TileEntityMassStorage tile; + + public MassStorageMEInventory(TileEntityMassStorage tile) { + this.tile = tile; + } + + @Override + public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionSource src) { + ItemStack typeStack = tile.getType(); + + if (typeStack == null || !ItemStackUtil.areStacksCompatible(input.getItemStack(), typeStack)) + return input; + + // If you're working with amounts greater than MAX_INT, you shouldn't use MSUs in the first place + int remaining = tile.increaseTotalStockpile((int)input.getStackSize(), type == Actionable.MODULATE); + + if (remaining == 0) { + return null; + } + + return AEApi.instance().storage() + .createItemStack(typeStack) + .setStackSize(remaining); + } + + @Override + public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src) { + ItemStack typeStack = tile.getType(); + + if (typeStack == null || !ItemStackUtil.areStacksCompatible(request.getItemStack(), typeStack)) + return null; + + // If you're working with amounts greater than MAX_INT, you shouldn't use MSUs in the first place + int missing = tile.decreaseTotalStockpile((int)request.getStackSize(), mode == Actionable.MODULATE); + long fulfilled = request.getStackSize() - missing; + + if (fulfilled == 0) { + return null; + } + + return AEApi.instance().storage() + .createItemStack(typeStack) + .setStackSize(fulfilled); + } + + @Override + public IItemList getAvailableItems(IItemList out) { + ItemStack typeStack = tile.getType(); + + if (typeStack != null) { + out.add( + AEApi.instance().storage() + .createItemStack(typeStack) + .setStackSize(tile.getTotalStockpile()) + ); + } + + return out; + } + + @Override + public StorageChannel getChannel() { + return StorageChannel.ITEMS; + } + +} diff --git a/src/main/java/com/hbm/inventory/recipes/ShredderRecipes.java b/src/main/java/com/hbm/inventory/recipes/ShredderRecipes.java index efd778696..908804a5e 100644 --- a/src/main/java/com/hbm/inventory/recipes/ShredderRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/ShredderRecipes.java @@ -360,9 +360,9 @@ public class ShredderRecipes extends SerializableRecipe { /* AR COMPAT */ Block arMoonTurf = Compat.tryLoadBlock(Compat.MOD_AR, "turf"); - if(arMoonTurf != null && gcMoonBlock != Blocks.air) ShredderRecipes.setRecipe(arMoonTurf, new ItemStack(ModBlocks.moon_turf)); //i assume it's moon turf + if(arMoonTurf != null && arMoonTurf != Blocks.air) ShredderRecipes.setRecipe(arMoonTurf, new ItemStack(ModBlocks.moon_turf)); //i assume it's moon turf Block arMoonTurfDark = Compat.tryLoadBlock(Compat.MOD_AR, "turfDark"); - if(arMoonTurfDark != null && gcMoonBlock != Blocks.air) ShredderRecipes.setRecipe(arMoonTurfDark, new ItemStack(ModBlocks.moon_turf)); //probably moon dirt? would have helped if i had ever played AR for more than 5 seconds + if(arMoonTurfDark != null && arMoonTurfDark != Blocks.air) ShredderRecipes.setRecipe(arMoonTurfDark, new ItemStack(ModBlocks.moon_turf)); //probably moon dirt? would have helped if i had ever played AR for more than 5 seconds } /** @@ -374,8 +374,9 @@ public class ShredderRecipes extends SerializableRecipe { List matches = OreDictionary.getOres("dust" + name); - if(matches != null && !matches.isEmpty()) - return matches.get(0).copy(); + if(matches != null && !matches.isEmpty()) { + return Compat.getPreferredOreOutput(matches); + } return new ItemStack(ModItems.scrap); } diff --git a/src/main/java/com/hbm/main/CraftingManager.java b/src/main/java/com/hbm/main/CraftingManager.java index 76646f307..86a280f16 100644 --- a/src/main/java/com/hbm/main/CraftingManager.java +++ b/src/main/java/com/hbm/main/CraftingManager.java @@ -604,6 +604,7 @@ public class CraftingManager { addRecipeAuto(new ItemStack(ModBlocks.fluid_duct_neo, 8, 1), new Object[] { "IAI", " ", "IAI", 'I', IRON.plate(), 'A', AL.plate() }); addRecipeAuto(new ItemStack(ModBlocks.fluid_duct_neo, 8, 2), new Object[] { "ASA", " ", "ASA", 'S', STEEL.plate(), 'A', AL.plate() }); addRecipeAuto(new ItemStack(ModBlocks.fluid_duct_paintable, 8), new Object[] { "SAS", "A A", "SAS", 'S', STEEL.ingot(), 'A', AL.plate() }); + addRecipeAuto(new ItemStack(ModBlocks.fluid_duct_paintable_block_exhaust, 8), new Object[] { "SAS", "A A", "SAS", 'S', IRON.ingot(), 'A', ModItems.plate_polymer}); addShapelessAuto(new ItemStack(ModBlocks.fluid_duct_gauge), new Object[] { ModBlocks.fluid_duct_paintable, STEEL.ingot(), DictFrame.fromOne(ModItems.circuit, EnumCircuitType.BASIC) }); addRecipeAuto(new ItemStack(ModBlocks.fluid_valve, 1), new Object[] { "S", "W", 'S', Blocks.lever, 'W', ModBlocks.fluid_duct_paintable }); addRecipeAuto(new ItemStack(ModBlocks.fluid_switch, 1), new Object[] { "S", "W", 'S', REDSTONE.dust(), 'W', ModBlocks.fluid_duct_paintable }); diff --git a/src/main/java/com/hbm/main/MainRegistry.java b/src/main/java/com/hbm/main/MainRegistry.java index 0826c53bd..c4a5a3d4a 100644 --- a/src/main/java/com/hbm/main/MainRegistry.java +++ b/src/main/java/com/hbm/main/MainRegistry.java @@ -13,6 +13,7 @@ import com.hbm.entity.grenade.*; import com.hbm.entity.logic.IChunkLoader; import com.hbm.entity.mob.siege.SiegeTier; import com.hbm.handler.*; +import com.hbm.handler.ae2.AE2CompatHandler; import com.hbm.handler.imc.IMCBlastFurnace; import com.hbm.handler.imc.IMCCentrifuge; import com.hbm.handler.imc.IMCCrystallizer; @@ -881,6 +882,9 @@ public class MainRegistry { // Load compatibility for OC. CompatHandler.init(); + // Load compatibility for AE2. + AE2CompatHandler.init(); + //expand for the largest entity we have (currently Quackos who is 17.5m in diameter, that's one fat duck) World.MAX_ENTITY_RADIUS = Math.max(World.MAX_ENTITY_RADIUS, 8.75); diff --git a/src/main/java/com/hbm/tileentity/TileMappings.java b/src/main/java/com/hbm/tileentity/TileMappings.java index c883e8a05..20e51d5fc 100644 --- a/src/main/java/com/hbm/tileentity/TileMappings.java +++ b/src/main/java/com/hbm/tileentity/TileMappings.java @@ -35,6 +35,7 @@ import com.hbm.blocks.network.CableDiode.TileEntityDiode; import com.hbm.blocks.network.CranePartitioner.TileEntityCranePartitioner; import com.hbm.blocks.network.FluidDuctGauge.TileEntityPipeGauge; import com.hbm.blocks.network.FluidDuctPaintable.TileEntityPipePaintable; +import com.hbm.blocks.network.FluidDuctPaintableBlockExhaust.TileEntityPipeExhaustPaintable; import com.hbm.blocks.network.FluidPump.TileEntityFluidPump; import com.hbm.blocks.rail.RailStandardSwitch.TileEntityRailSwitch; import com.hbm.tileentity.bomb.*; @@ -412,6 +413,7 @@ public class TileMappings { put(TileEntityPipePaintable.class, "tileentity_pipe_paintable"); put(TileEntityPipeGauge.class, "tileentity_pipe_gauge"); put(TileEntityPipeExhaust.class, "tileentity_pipe_exhaust"); + put(TileEntityPipeExhaustPaintable.class, "tileentity_pipe_exhaust_paintable"); put(TileEntityFluidValve.class, "tileentity_pipe_valve"); put(TileEntityFluidPump.class, "tileentity_pipe_pump"); diff --git a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java index 8d939f523..6290254ff 100644 --- a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java +++ b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java @@ -7,6 +7,7 @@ import com.hbm.tileentity.IBufPacketReceiver; import com.hbm.tileentity.IControlReceiverFilter; import com.hbm.util.BufferUtil; +import com.hbm.util.ItemStackUtil; import api.hbm.redstoneoverradio.IRORInteractive; import api.hbm.redstoneoverradio.IRORValueProvider; @@ -15,6 +16,7 @@ import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; @@ -133,6 +135,109 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements IBufPa return result; } + // Note: the following three methods are used for AE2 integration, and aren't meant to be called in any other context by default + + public int getTotalStockpile() { + ItemStack type = getType(); + if (type == null) + return 0; + + int result = getStockpile(); + + ItemStack inStack = slots[0]; + if (inStack != null && ItemStackUtil.areStacksCompatible(type, inStack)) { + result += inStack.stackSize; + } + + ItemStack outStack = slots[2]; + if (outStack != null && ItemStackUtil.areStacksCompatible(type, outStack)) { + result += outStack.stackSize; + } + + return result; + } + + // Returns the remainder that didn't fit. + // If `actually` is false, only predicts the outcome, but doesn't change the state + public int increaseTotalStockpile(int amount, boolean actually) { + return changeTotalStockpile(amount, actually, +1); + } + + // Returns the remainder that couldn't be extracted. + // If `actually` is false, only predicts the outcome, but doesn't change the state + public int decreaseTotalStockpile(int amount, boolean actually) { + return changeTotalStockpile(amount, actually, -1); + } + + private int changeTotalStockpile(int amount, boolean actually, int sign) { + ItemStack type = getType(); + + if (type == null) + return amount; + + int stockpileAvail = sign > 0 ? getCapacity() - getStockpile() : getStockpile(); + + if (amount > 0 && stockpileAvail > 0) { + int depositStockpile = Math.min(amount, stockpileAvail); + if (actually) { + this.stack += sign * depositStockpile; + } + amount -= depositStockpile; + } + + int inputAvail = 0; + ItemStack inStack = slots[0]; + if (inStack != null && ItemStackUtil.areStacksCompatible(type, inStack)) { + inputAvail = sign > 0 ? inStack.getMaxStackSize() - inStack.stackSize : inStack.stackSize; + } else if (inStack == null) { + inputAvail = sign > 0 ? type.getMaxStackSize() : 0; + } + + if (amount > 0 && inputAvail > 0) { + int depositInput = Math.min(amount, inputAvail); + if (actually) { + if (slots[0] == null) { // Only possible with sign == +1 + slots[0] = slots[1].copy(); + slots[0].stackSize = 0; + } + slots[0].stackSize += sign * depositInput; + if (slots[0].stackSize == 0) { + slots[0] = null; + } + } + amount -= depositInput; + } + + int outputAvail = 0; + ItemStack outStack = slots[2]; + if (outStack != null && ItemStackUtil.areStacksCompatible(type, outStack)) { + outputAvail = sign > 0 ? outStack.getMaxStackSize() - outStack.stackSize : outStack.stackSize; + } else if (outStack == null) { + outputAvail = sign > 0 ? type.getMaxStackSize() : 0; + } + + if (amount > 0 && outputAvail > 0) { + int depositOutput = Math.min(amount, outputAvail); + if (actually) { + if (slots[2] == null) { // Only possible with sign == +1 + slots[2] = slots[1].copy(); + slots[2].stackSize = 0; + } + slots[2].stackSize += sign * depositOutput; + if (slots[2].stackSize == 0) { + slots[2] = null; + } + } + amount -= depositOutput; + } + + if (actually) { + this.markDirty(); + } + + return amount; + } + @Override public void serialize(ByteBuf buf) { buf.writeInt(this.stack); diff --git a/src/main/java/com/hbm/util/Compat.java b/src/main/java/com/hbm/util/Compat.java index cac127f1a..db59a6026 100644 --- a/src/main/java/com/hbm/util/Compat.java +++ b/src/main/java/com/hbm/util/Compat.java @@ -49,7 +49,29 @@ public class Compat { private static String getReg(String domain, String name) { return domain + ":" + name; } - + + public static ItemStack getPreferredOreOutput(List oreList) { + int lowestPref = -1; + ItemStack preferredStack = null; + + for(ItemStack item : oreList) { + String modid = ItemStackUtil.getModIdFromItemStack(item); + for(int i = 0; i < GeneralConfig.preferredOutputMod.length; i++) { + if (modid.equals(GeneralConfig.preferredOutputMod[i])){ + if (lowestPref<0 || i