diff --git a/src/main/java/sunsetsatellite/signalindustries/SignalIndustries.java b/src/main/java/sunsetsatellite/signalindustries/SignalIndustries.java index 02cb9fdb..42aab8c1 100644 --- a/src/main/java/sunsetsatellite/signalindustries/SignalIndustries.java +++ b/src/main/java/sunsetsatellite/signalindustries/SignalIndustries.java @@ -19,6 +19,7 @@ import net.minecraft.core.block.*; import net.minecraft.core.block.material.Material; import net.minecraft.core.block.tag.BlockTags; +import net.minecraft.core.data.registry.recipe.RecipeSymbol; import net.minecraft.core.data.tag.Tag; import net.minecraft.core.entity.player.EntityPlayer; import net.minecraft.core.item.Item; @@ -663,6 +664,15 @@ public class SignalIndustries implements ModInitializer, GameStartEntrypoint { .setSideTextures("infuser_basic_side_inactive.png") .build(new BlockInfuser("basic.infuser",config.getInt("BlockIDs.basicInfuser"), Tier.BASIC,Material.metal)); + public static final Block basicAssembler = new BlockBuilder(MOD_ID) + .setHardness(1) + .setResistance(3) + .setBlockSound(BlockSounds.METAL) + .setTextures("basic_assembler_side.png") + .setNorthTexture("basic_assembler_front.png") + .build(new BlockAssembler("basic.assembler",config.getInt("BlockIDs.basicAssembler"), Tier.BASIC, Material.metal)); + + public static final Block basicWrathBeacon = new BlockBuilder(MOD_ID) .setHardness(2) .setResistance(500) @@ -1246,6 +1256,8 @@ public void onInitialize() { textures.put(Tier.BASIC.name()+".externalIo",new BlockTexture(MOD_ID).setAll("external_io_blank.png").setTopTexture("external_io_input.png").setBottomTexture("external_io_output.png").setNorthTexture("external_io_both.png")); textures.put(Tier.REINFORCED.name()+".externalIo",new BlockTexture(MOD_ID).setAll("reinforced_external_io_blank.png").setTopTexture("reinforced_external_io_input.png").setBottomTexture("reinforced_external_io_output.png").setNorthTexture("reinforced_external_io_both.png")); + textures.put(Tier.BASIC.name()+".assembler.active",new BlockTexture(MOD_ID).setAll("basic_assembler_side_active.png").setNorthTexture("basic_assembler_front_active.png")); + textures.put(Tier.BASIC.name()+".assembler.active.overlay",new BlockTexture(MOD_ID).setAll("assembler_overlay_side.png").setNorthTexture("assembler_overlay_front.png")); textures.put(Tier.REINFORCED.name()+".centrifuge.active",new BlockTexture(MOD_ID).setAll("reinforced_blank.png").setTopTexture("reinforced_centrifuge_closed.png").setNorthTexture("reinforced_centrifuge_front_active.png")); textures.put(Tier.REINFORCED.name()+".centrifuge.active.overlay",new BlockTexture(MOD_ID).setNorthTexture("centrifuge_overlay.png")); @@ -1318,6 +1330,14 @@ public SignalIndustries(){ EntityHelper.Core.createEntity(EntityFallingMeteor.class,50,"fallingMeteor"); EntityHelper.Client.assignEntityRenderer(EntityFallingMeteor.class,new FallingMeteorRenderer()); + addEntities(); + //crafting recipes in RecipeHandlerCraftingSI + + } + + //idea got *too smart* recently and now considers anything after accessor stubs "unreachable" due to the throw statement in them that will never be triggered + @SuppressWarnings("UnreachableCode") + private void addEntities(){ EntityHelper.Core.createSpecialTileEntity(TileEntityConduit.class, new RenderFluidInConduit(),"Conduit"); EntityHelper.Core.createSpecialTileEntity(TileEntityFluidConduit.class, new RenderFluidInConduit(),"Fluid Conduit"); @@ -1364,6 +1384,9 @@ public SignalIndustries(){ EntityHelper.Core.createTileEntity(TileEntityPump.class,"Pump"); addToNameGuiMap("Pump", GuiPump.class, TileEntityCrystalChamber.class); + EntityHelper.Core.createSpecialTileEntity(TileEntityAssembler.class, new RenderAssemblerItemSprite3D(),"Assembler"); + addToNameGuiMap("Assembler", GuiAssembler.class, TileEntityAssembler.class); + EntityHelper.Core.createSpecialTileEntity(TileEntityDimensionalAnchor.class,new RenderMultiblock(),"Dimensional Anchor"); addToNameGuiMap("Dimensional Anchor", GuiDimAnchor.class, TileEntityDimensionalAnchor.class); @@ -1422,8 +1445,6 @@ public SignalIndustries(){ EntityHelper.Core.createEntity(EntityInfernal.class,config.getInt("EntityIDs.infernalId"),"Infernal"); EntityHelper.Client.assignEntityRenderer(EntityInfernal.class,new MobRenderer(new ModelZombie(),0.5F)); - //crafting recipes in RecipeHandlerCraftingSI - } public static Map mapOf(K[] keys, V[] values){ @@ -1540,6 +1561,25 @@ public static ArrayList condenseList(List list){ return stacks; } + public static boolean hasItems(List symbols, List available){ + symbols.removeIf(Objects::isNull); + List copy = available.stream().map(ItemStack::copy).collect(Collectors.toList()); + int s = 0; + int sReq = (int) symbols.stream().filter(Objects::nonNull).count(); + label: + for (RecipeSymbol symbol : symbols) { + for (ItemStack stack : copy) { + if(symbol.matches(stack)){ + if(stack == null || stack.stackSize <= 0) continue; + stack.stackSize--; + s++; + continue label; + } + } + } + return s == sReq; + } + public static void usePortal(int dim) { Minecraft mc = Minecraft.getMinecraft(Minecraft.class); Dimension lastDim = Dimension.getDimensionList().get(mc.thePlayer.dimension); diff --git a/src/main/java/sunsetsatellite/signalindustries/api/impl/btwaila/tooltip/MachineTooltip.java b/src/main/java/sunsetsatellite/signalindustries/api/impl/btwaila/tooltip/MachineTooltip.java index 9a0cf5c0..393ae347 100644 --- a/src/main/java/sunsetsatellite/signalindustries/api/impl/btwaila/tooltip/MachineTooltip.java +++ b/src/main/java/sunsetsatellite/signalindustries/api/impl/btwaila/tooltip/MachineTooltip.java @@ -23,6 +23,7 @@ public void initTooltip() { addClass(TileEntitySignalumDynamo.class); addClass(TileEntityPump.class); addClass(TileEntityAutoMiner.class); + addClass(TileEntityAssembler.class); } @Override diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/BlockEnergyCell.java b/src/main/java/sunsetsatellite/signalindustries/blocks/BlockEnergyCell.java index 3620890e..e0bc39ed 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/BlockEnergyCell.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/BlockEnergyCell.java @@ -9,13 +9,11 @@ import sunsetsatellite.catalyst.core.util.Connection; import sunsetsatellite.catalyst.core.util.Direction; import sunsetsatellite.catalyst.fluids.impl.containers.ContainerFluidTank; -import sunsetsatellite.catalyst.fluids.impl.tiles.TileEntityFluidContainer; import sunsetsatellite.catalyst.fluids.impl.tiles.TileEntityFluidPipe; import sunsetsatellite.signalindustries.SignalIndustries; import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered; import sunsetsatellite.signalindustries.gui.GuiEnergyCell; import sunsetsatellite.signalindustries.inventories.TileEntityEnergyCell; -import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; import sunsetsatellite.signalindustries.util.IOPreview; import sunsetsatellite.signalindustries.util.Tier; import turniplabs.halplibe.helper.TextureHelper; @@ -41,7 +39,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/BlockSIFluidTank.java b/src/main/java/sunsetsatellite/signalindustries/blocks/BlockSIFluidTank.java index eb222de3..e9607715 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/BlockSIFluidTank.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/BlockSIFluidTank.java @@ -13,9 +13,7 @@ import sunsetsatellite.signalindustries.SignalIndustries; import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered; import sunsetsatellite.signalindustries.gui.GuiSIFluidTank; -import sunsetsatellite.signalindustries.inventories.TileEntityEnergyCell; import sunsetsatellite.signalindustries.inventories.TileEntitySIFluidTank; -import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; import sunsetsatellite.signalindustries.util.IOPreview; import sunsetsatellite.signalindustries.util.Tier; import turniplabs.halplibe.helper.TextureHelper; @@ -46,7 +44,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockAlloySmelter.java b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockAlloySmelter.java index 5209e9fb..fcdbb4dc 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockAlloySmelter.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockAlloySmelter.java @@ -115,7 +115,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockAssembler.java b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockAssembler.java new file mode 100644 index 00000000..21a15844 --- /dev/null +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockAssembler.java @@ -0,0 +1,164 @@ +package sunsetsatellite.signalindustries.blocks.machines; + +import net.minecraft.core.block.entity.TileEntity; +import net.minecraft.core.block.material.Material; +import net.minecraft.core.entity.EntityItem; +import net.minecraft.core.entity.player.EntityPlayer; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.util.helper.Side; +import net.minecraft.core.util.helper.Sides; +import net.minecraft.core.world.World; +import net.minecraft.core.world.WorldSource; +import sunsetsatellite.catalyst.core.util.Connection; +import sunsetsatellite.catalyst.core.util.Direction; +import sunsetsatellite.catalyst.fluids.impl.tiles.TileEntityFluidPipe; +import sunsetsatellite.signalindustries.SignalIndustries; +import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered; +import sunsetsatellite.signalindustries.containers.ContainerAssembler; +import sunsetsatellite.signalindustries.gui.GuiAssembler; +import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; +import sunsetsatellite.signalindustries.inventories.machines.TileEntityAssembler; +import sunsetsatellite.signalindustries.util.IOPreview; +import sunsetsatellite.signalindustries.util.Tier; +import turniplabs.halplibe.helper.TextureHelper; + +import java.util.ArrayList; +import java.util.Random; + +public class BlockAssembler extends BlockContainerTiered { + public BlockAssembler(String key, int i, Tier tier, Material material) { + super(key, i, tier, material); + hasOverbright = true; + } + + @Override + public void onBlockRemoved(World world, int i, int j, int k, int data) { + TileEntityAssembler tile = (TileEntityAssembler) world.getBlockTileEntity(i, j, k); + if (tile != null) { + for (Direction dir : Direction.values()) { + TileEntity tile2 = dir.getTileEntity(world, tile); + if (tile2 instanceof TileEntityFluidPipe) { + tile.unpressurizePipes((TileEntityFluidPipe) tile2, new ArrayList<>()); + } + } + Random random = new Random(); + for (int l = 0; l < tile.getSizeInventory(); ++l) { + ItemStack itemstack = tile.getStackInSlot(l); + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + float f2 = random.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) { + int i1 = random.nextInt(21) + 10; + if (i1 > itemstack.stackSize) { + i1 = itemstack.stackSize; + } + + itemstack.stackSize -= i1; + EntityItem entityitem = new EntityItem(world, (float) i + f, (float) j + f1, (float) k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getMetadata())); + float f3 = 0.05F; + entityitem.xd = (float) random.nextGaussian() * f3; + entityitem.yd = (float) random.nextGaussian() * f3 + 0.2F; + entityitem.zd = (float) random.nextGaussian() * f3; + world.entityJoinedWorld(entityitem); + } + } + } + for (int l = 0; l < tile.template.getSizeInventory(); ++l) { + ItemStack itemstack = tile.template.getStackInSlot(l); + if (itemstack != null) { + float f = random.nextFloat() * 0.8F + 0.1F; + float f1 = random.nextFloat() * 0.8F + 0.1F; + float f2 = random.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) { + int i1 = random.nextInt(21) + 10; + if (i1 > itemstack.stackSize) { + i1 = itemstack.stackSize; + } + + itemstack.stackSize -= i1; + EntityItem entityitem = new EntityItem(world, (float) i + f, (float) j + f1, (float) k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getMetadata())); + float f3 = 0.05F; + entityitem.xd = (float) random.nextGaussian() * f3; + entityitem.yd = (float) random.nextGaussian() * f3 + 0.2F; + entityitem.zd = (float) random.nextGaussian() * f3; + world.entityJoinedWorld(entityitem); + } + } + } + } + + super.onBlockRemoved(world, i, j, k, data); + } + + @Override + public int getBlockTexture(WorldSource blockAccess, int x, int y, int z, Side side) { + TileEntityTieredMachineBase tile = (TileEntityTieredMachineBase) blockAccess.getBlockTileEntity(x,y,z); + int meta = blockAccess.getBlockMetadata(x,y,z); + int index = Sides.orientationLookUpHorizontal[6 * meta + side.getId()]; + if(tile.isBurning() && tile.tier == tier){ + return SignalIndustries.textures.get(tile.tier.name()+".assembler.active").getTexture(Side.getSideById(index)); + } + return this.atlasIndices[index]; + } + + @Override + public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) + { + if(world.isClientSide) + { + return true; + } else + { + TileEntityAssembler tile = (TileEntityAssembler) world.getBlockTileEntity(i, j, k); + if(tile != null) { + SignalIndustries.displayGui(entityplayer,new GuiAssembler(entityplayer.inventory, tile),new ContainerAssembler(entityplayer.inventory,tile),tile,i,j,k); + } + return true; + } + } + + @Override + public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int z, int side) { + TileEntityTieredMachineBase tile = (TileEntityTieredMachineBase) blockAccess.getBlockTileEntity(x,y,z); + if(tile.preview != IOPreview.NONE){ + Direction dir = Direction.getDirectionFromSide(side); + Connection con = Connection.NONE; + switch (tile.preview){ + case ITEM: { + con = tile.itemConnections.get(dir); + break; + } + case FLUID: { + con = tile.fluidConnections.get(dir); + break; + } + } + switch (con){ + case INPUT: + return TextureHelper.getOrCreateBlockTextureIndex(SignalIndustries.MOD_ID,"input_overlay.png"); + case OUTPUT: + return TextureHelper.getOrCreateBlockTextureIndex(SignalIndustries.MOD_ID,"output_overlay.png"); + case BOTH: + return TextureHelper.getOrCreateBlockTextureIndex(SignalIndustries.MOD_ID,"both_io_overlay.png"); + case NONE: + return -1; + } + } else { + int meta = blockAccess.getBlockMetadata(x,y,z); + int index = Sides.orientationLookUpHorizontal[6 * meta + side]; + if(tile.isBurning() && tile.tier == tier){ + return SignalIndustries.textures.get(tile.tier.name()+".assembler.active.overlay").getTexture(Side.getSideById(index)); + } + return -1; + } + return -1; + } + + @Override + protected TileEntity getNewBlockEntity() { + return new TileEntityAssembler(); + } +} diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockAutoMiner.java b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockAutoMiner.java index 9daa9d61..3e52abc5 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockAutoMiner.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockAutoMiner.java @@ -17,7 +17,6 @@ import sunsetsatellite.signalindustries.containers.ContainerAutoMiner; import sunsetsatellite.signalindustries.gui.GuiAutoMiner; import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; -import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineSimple; import sunsetsatellite.signalindustries.inventories.machines.TileEntityAutoMiner; import sunsetsatellite.signalindustries.util.IOPreview; import sunsetsatellite.signalindustries.util.Tier; @@ -44,7 +43,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCentrifuge.java b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCentrifuge.java index 0a622c2c..bb94a07c 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCentrifuge.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCentrifuge.java @@ -17,7 +17,6 @@ import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered; import sunsetsatellite.signalindustries.containers.ContainerCentrifuge; import sunsetsatellite.signalindustries.gui.GuiCentrifuge; -import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineSimple; import sunsetsatellite.signalindustries.inventories.machines.TileEntityCentrifuge; import sunsetsatellite.signalindustries.util.IOPreview; @@ -116,7 +115,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCrusher.java b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCrusher.java index 887294e0..98d62587 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCrusher.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCrusher.java @@ -17,7 +17,6 @@ import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered; import sunsetsatellite.signalindustries.containers.ContainerCrusher; import sunsetsatellite.signalindustries.gui.GuiCrusher; -import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineSimple; import sunsetsatellite.signalindustries.inventories.machines.TileEntityCrusher; import sunsetsatellite.signalindustries.util.IOPreview; @@ -118,7 +117,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCrystalChamber.java b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCrystalChamber.java index 0e7fabac..dff3e888 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCrystalChamber.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCrystalChamber.java @@ -17,7 +17,6 @@ import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered; import sunsetsatellite.signalindustries.containers.ContainerCrystalChamber; import sunsetsatellite.signalindustries.gui.GuiCrystalChamber; -import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineSimple; import sunsetsatellite.signalindustries.inventories.machines.TileEntityCrystalChamber; import sunsetsatellite.signalindustries.util.IOPreview; @@ -117,7 +116,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCrystalCutter.java b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCrystalCutter.java index 8e2510a0..5d0e895a 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCrystalCutter.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockCrystalCutter.java @@ -17,7 +17,6 @@ import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered; import sunsetsatellite.signalindustries.containers.ContainerCrystalCutter; import sunsetsatellite.signalindustries.gui.GuiCrystalCutter; -import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineSimple; import sunsetsatellite.signalindustries.inventories.machines.TileEntityCrystalCutter; import sunsetsatellite.signalindustries.util.IOPreview; @@ -51,7 +50,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockDilithiumBooster.java b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockDilithiumBooster.java index 4ea08082..1420fccc 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockDilithiumBooster.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockDilithiumBooster.java @@ -115,7 +115,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockDilithiumStabilizer.java b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockDilithiumStabilizer.java index 1541af1f..33c089bb 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockDilithiumStabilizer.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockDilithiumStabilizer.java @@ -147,7 +147,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockDimensionalAnchor.java b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockDimensionalAnchor.java index 48c8633f..735b5b42 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockDimensionalAnchor.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockDimensionalAnchor.java @@ -143,7 +143,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockExtractor.java b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockExtractor.java index b26e15ca..62f6c582 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockExtractor.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockExtractor.java @@ -25,7 +25,6 @@ import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; import sunsetsatellite.signalindustries.inventories.machines.TileEntityExtractor; import sunsetsatellite.signalindustries.inventories.machines.TileEntityReinforcedExtractor; -import sunsetsatellite.signalindustries.inventories.machines.TileEntityReinforcedWrathBeacon; import sunsetsatellite.signalindustries.misc.SignalIndustriesAchievementPage; import sunsetsatellite.signalindustries.util.IOPreview; import sunsetsatellite.signalindustries.util.Tier; @@ -149,7 +148,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockInfuser.java b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockInfuser.java index 77ccb519..069b807e 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockInfuser.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockInfuser.java @@ -17,7 +17,6 @@ import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered; import sunsetsatellite.signalindustries.containers.ContainerInfuser; import sunsetsatellite.signalindustries.gui.GuiInfuser; -import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineSimple; import sunsetsatellite.signalindustries.inventories.machines.TileEntityInfuser; import sunsetsatellite.signalindustries.util.IOPreview; @@ -117,7 +116,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockPlateFormer.java b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockPlateFormer.java index 0bf629f4..6ed5735c 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockPlateFormer.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockPlateFormer.java @@ -17,7 +17,6 @@ import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered; import sunsetsatellite.signalindustries.containers.ContainerPlateFormer; import sunsetsatellite.signalindustries.gui.GuiPlateFormer; -import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineSimple; import sunsetsatellite.signalindustries.inventories.machines.TileEntityPlateFormer; import sunsetsatellite.signalindustries.util.IOPreview; @@ -117,7 +116,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockPump.java b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockPump.java index 091dcfe5..c58b7533 100644 --- a/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockPump.java +++ b/src/main/java/sunsetsatellite/signalindustries/blocks/machines/BlockPump.java @@ -50,7 +50,7 @@ public int getBlockOverbrightTexture(WorldSource blockAccess, int x, int y, int break; } case FLUID: { - con = tile.connections.get(dir); + con = tile.fluidConnections.get(dir); break; } } diff --git a/src/main/java/sunsetsatellite/signalindustries/containers/ContainerAssembler.java b/src/main/java/sunsetsatellite/signalindustries/containers/ContainerAssembler.java new file mode 100644 index 00000000..3697812e --- /dev/null +++ b/src/main/java/sunsetsatellite/signalindustries/containers/ContainerAssembler.java @@ -0,0 +1,60 @@ +package sunsetsatellite.signalindustries.containers; + + +import net.minecraft.core.crafting.ICrafting; +import net.minecraft.core.entity.player.EntityPlayer; +import net.minecraft.core.player.inventory.IInventory; +import net.minecraft.core.player.inventory.slot.Slot; +import sunsetsatellite.catalyst.fluids.impl.ContainerFluid; +import sunsetsatellite.catalyst.fluids.impl.tiles.TileEntityFluidItemContainer; +import sunsetsatellite.catalyst.fluids.util.SlotFluid; +import sunsetsatellite.signalindustries.inventories.machines.TileEntityAlloySmelter; +import sunsetsatellite.signalindustries.inventories.machines.TileEntityAssembler; + +public class ContainerAssembler extends ContainerFluid { + + private final TileEntityAssembler machine = ((TileEntityAssembler) tile); + + public ContainerAssembler(IInventory iInventory, TileEntityFluidItemContainer tileEntity){ + super(iInventory, tileEntity); + tile = tileEntity; + + SlotFluid slot = new SlotFluid(tileEntity, 0, 152,35); //116 35 + addFluidSlot(slot); + + + this.addSlot(new Slot(tileEntity, 0, 120, 35)); + + for(int l = 0; l < 3; l++) + { + for(int k1 = 0; k1 < 3; k1++) + { + addSlot(new Slot(machine.template, k1 + l * 3, 26 + k1 * 18, 17 + l * 18)); + } + + } + + for(int j = 0; j < 2; j++) + { + for(int i1 = 0; i1 < 9; i1++) + { + addSlot(new Slot(tileEntity, 1 + (i1 + j * 9), 8 + i1 * 18, 84 + j * 18)); + } + + } + + for(int j = 0; j < 3; j++) + { + for(int i1 = 0; i1 < 9; i1++) + { + addSlot(new Slot(iInventory, i1 + j * 9 + 9, 8 + i1 * 18, 133 + j * 18)); + } + + } + + for(int k = 0; k < 9; k++) + { + addSlot(new Slot(iInventory, k, 8 + k * 18, 191)); + } + } +} diff --git a/src/main/java/sunsetsatellite/signalindustries/gui/GuiAssembler.java b/src/main/java/sunsetsatellite/signalindustries/gui/GuiAssembler.java new file mode 100644 index 00000000..77b257da --- /dev/null +++ b/src/main/java/sunsetsatellite/signalindustries/gui/GuiAssembler.java @@ -0,0 +1,139 @@ +package sunsetsatellite.signalindustries.gui; + +import net.minecraft.client.entity.player.EntityPlayerSP; +import net.minecraft.client.gui.GuiButton; +import sunsetsatellite.signalindustries.util.GuiRenderFakeItem; +import net.minecraft.core.block.entity.TileEntity; +import net.minecraft.core.entity.player.EntityPlayer; +import net.minecraft.core.lang.I18n; +import net.minecraft.core.player.inventory.InventoryPlayer; +import net.minecraft.core.player.inventory.slot.Slot; +import net.minecraft.server.entity.player.EntityPlayerMP; +import org.lwjgl.opengl.GL11; +import sunsetsatellite.catalyst.fluids.impl.GuiFluid; +import sunsetsatellite.catalyst.fluids.impl.tiles.TileEntityFluidItemContainer; +import sunsetsatellite.signalindustries.SignalIndustries; +import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered; +import sunsetsatellite.signalindustries.containers.ContainerAssembler; +import sunsetsatellite.signalindustries.inventories.machines.TileEntityAssembler; + +public class GuiAssembler extends GuiFluid { + public String name = "Assembler"; + public EntityPlayer entityplayer; + public TileEntityAssembler tile; + + + public GuiAssembler(InventoryPlayer inventoryPlayer, TileEntity tile) { + super(new ContainerAssembler(inventoryPlayer, (TileEntityFluidItemContainer) tile),inventoryPlayer); + this.tile = (TileEntityAssembler) tile; + this.entityplayer = inventoryPlayer.player; + ySize = 215; + } + + @Override + public void drawScreen(int i1, int i2, float f3) { + super.drawScreen(i1, i2, f3); + int i = (width - xSize) / 2; + int j = (height - ySize) / 2; + Slot slot = this.inventorySlots.inventorySlots.get(0); + GuiRenderFakeItem guiRenderFakeItem = new GuiRenderFakeItem(mc); + if(tile.recipe != null && slot.getStack() == null){ + guiRenderFakeItem.render(tile.recipe.getOutput(),i+slot.xDisplayPosition,j+slot.yDisplayPosition); + } + } + + @Override + public void mouseClicked(int x, int y, int button) { + int i = (width - xSize) / 2; + int j = (height - ySize) / 2; + if(x > i+80 && x < i+94) { + if (y > j + 40 && y < j + 46) { + I18n translator = I18n.getInstance(); + String name = translator.translateKey(tile.getBlockType().getLanguageKey(0)+".name"); + ////GuidebookPlusPlus.nameFocus = ">"+ name; + if(entityplayer instanceof EntityPlayerSP){ + ((EntityPlayerSP)entityplayer).displayGUIGuidebook(); + } else if (entityplayer instanceof EntityPlayerMP) { + ((EntityPlayerMP)entityplayer).displayGUIGuidebook(); + } + } + } + super.mouseClicked(x, y, button); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f1) { + int i2 = this.mc.renderEngine.getTexture("/assets/signalindustries/gui/basic_assembler_gui.png"); + /*switch (((BlockContainerTiered)tile.getBlockType()).tier){ + case PROTOTYPE: + i2 = this.mc.renderEngine.getTexture("/assets/signalindustries/gui/generic_prototype_machine_double.png"); + break; + case BASIC: + i2 = this.mc.renderEngine.getTexture("/assets/signalindustries/gui/generic_basic_machine_double.png"); + break; + case REINFORCED: + case AWAKENED: + break; + }*/ + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(i2); + int i3 = (this.width - this.xSize) / 2; + int i4 = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(i3, i4, 0, 0, this.xSize, this.ySize); + int i5; + if(this.tile.isBurning()) { + i5 = this.tile.getBurnTimeRemainingScaled(12); + this.drawTexturedModalRect(i3 + 153, i4 + 18 + 12 - i5, 176, 28 - i5, 14, i5 + 2); + } + + i5 = this.tile.getProgressScaled(24); + this.drawTexturedModalRect(i3 + 85, i4 + 35, 176, 0, i5 + 1, 16); + if(this.tile.speedMultiplier > 1){ + this.drawString(fontRenderer, this.tile.speedMultiplier+"x",i3 + 6,i4 + 6,tile.speedMultiplier >= 3 ? 0xFFFFA500 : (tile.speedMultiplier >= 2 ? 0xFFFF00FF : 0xFFFF8080)); + } + + //this.drawString(fontRenderer,tile.recipe == null ? "null" : tile.recipe.toString(),i3+2,i4+120,0xFFFF0000); + } + + protected void drawGuiContainerForegroundLayer() + { + super.drawGuiContainerForegroundLayer(); + int color = 0xFFFFFFFF; + switch (((BlockContainerTiered)tile.getBlockType()).tier){ + case PROTOTYPE: + break; + case BASIC: + color = 0xFFFF8080; + break; + case REINFORCED: + color = 0xFFFF0000; + break; + case AWAKENED: + color = 0xFFFFA500; + break; + } + fontRenderer.drawCenteredString(name, 90, 6, color); + } + protected void buttonPressed(GuiButton guibutton) { + if (!guibutton.enabled) { + return; + } + switch (guibutton.id){ + case 0: + SignalIndustries.displayGui(entityplayer, new GuiFluidIOConfig(entityplayer,inventorySlots, tile, this), inventorySlots, tile,tile.x,tile.y,tile.z); + break; + case 1: + SignalIndustries.displayGui(entityplayer, new GuiItemIOConfig(entityplayer,inventorySlots, tile, this), inventorySlots, tile,tile.x,tile.y,tile.z); + break; + default: + break; + } + } + + public void init() + { + controlList.add(new GuiButton(0, Math.round(width / 2) + 40, Math.round(height / 2) - 50, 20, 20, "F")); + controlList.add(new GuiButton(1, Math.round(width / 2) + 60, Math.round(height / 2) - 50, 20, 20, "I")); + super.init(); + } +} diff --git a/src/main/java/sunsetsatellite/signalindustries/gui/GuiFluidIOConfig.java b/src/main/java/sunsetsatellite/signalindustries/gui/GuiFluidIOConfig.java index 18a1045c..3368be69 100644 --- a/src/main/java/sunsetsatellite/signalindustries/gui/GuiFluidIOConfig.java +++ b/src/main/java/sunsetsatellite/signalindustries/gui/GuiFluidIOConfig.java @@ -17,7 +17,6 @@ import sunsetsatellite.signalindustries.SignalIndustries; import sunsetsatellite.signalindustries.interfaces.IHasIOPreview; import sunsetsatellite.signalindustries.inventories.TileEntityEnergyConnector; -import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; import sunsetsatellite.signalindustries.util.IOPreview; @@ -53,7 +52,7 @@ public void mouseClicked(int x, int y, int button) { public void action2Performed(GuiButton guibutton) { if(guibutton.id > 5){ - Direction dir = Direction.values()[guibutton.id-6]; + Direction dir = Direction.values()[Math.min(6,Math.max(0,guibutton.id-6))]; Integer currentValue = tile.activeFluidSlots.get(dir); if(currentValue > 0){ tile.activeFluidSlots.put(dir,currentValue-1); @@ -110,12 +109,12 @@ public void init() { int centerX = (width - xSize) / 2; int centerY = (height - ySize) / 2; - controlList.add(new GuiButton(2, (width / 2) - 10, (height / 2) - 63, 15, 15, tile.connections.get(Direction.Y_POS).getLetter())); //Y+ - controlList.add(new GuiButton(4, (width / 2) - 10, (height / 2) - 48, 15, 15, tile.connections.get(Direction.Z_POS).getLetter())); //Z+ - controlList.add(new GuiButton(3, (width / 2) - 10, (height / 2) - 33, 15, 15, tile.connections.get(Direction.Y_NEG).getLetter())); //Y- - controlList.add(new GuiButton(0, (width / 2) + 4, (height / 2) - 48, 15, 15, tile.connections.get(Direction.X_POS).getLetter())); //X+ - controlList.add(new GuiButton(1, (width / 2) - 24, (height / 2) - 48, 15, 15, tile.connections.get(Direction.X_NEG).getLetter())); //X- - controlList.add(new GuiButton(5, (width / 2) + 4, (height / 2) - 33, 15, 15, tile.connections.get(Direction.Z_NEG).getLetter())); //Z- + controlList.add(new GuiButton(2, (width / 2) - 10, (height / 2) - 63, 15, 15, tile.fluidConnections.get(Direction.Y_POS).getLetter())); //Y+ + controlList.add(new GuiButton(4, (width / 2) - 10, (height / 2) - 48, 15, 15, tile.fluidConnections.get(Direction.Z_POS).getLetter())); //Z+ + controlList.add(new GuiButton(3, (width / 2) - 10, (height / 2) - 33, 15, 15, tile.fluidConnections.get(Direction.Y_NEG).getLetter())); //Y- + controlList.add(new GuiButton(0, (width / 2) + 4, (height / 2) - 48, 15, 15, tile.fluidConnections.get(Direction.X_POS).getLetter())); //X+ + controlList.add(new GuiButton(1, (width / 2) - 24, (height / 2) - 48, 15, 15, tile.fluidConnections.get(Direction.X_NEG).getLetter())); //X- + controlList.add(new GuiButton(5, (width / 2) + 4, (height / 2) - 33, 15, 15, tile.fluidConnections.get(Direction.Z_NEG).getLetter())); //Z- controlList.add(new GuiButton(8, (width / 2) - 10 + 50, (height / 2) - 63, 15, 15, String.valueOf(tile.activeFluidSlots.get(Direction.Y_POS)))); controlList.add(new GuiButton(10, (width / 2) - 10 + 50, (height / 2) - 48, 15, 15, String.valueOf(tile.activeFluidSlots.get(Direction.Z_POS)))); @@ -152,30 +151,30 @@ public void init() { protected void buttonPressed(GuiButton guibutton) { if(tile != null) { if (guibutton.id >= 0 && guibutton.id < 6) { - switch (tile.connections.get(Direction.values()[guibutton.id])) { + switch (tile.fluidConnections.get(Direction.values()[guibutton.id])) { case NONE: if (tile.getBlockType() == SignalIndustries.infiniteEnergyCell) { - tile.connections.replace(Direction.values()[guibutton.id], Connection.OUTPUT); + tile.fluidConnections.replace(Direction.values()[guibutton.id], Connection.OUTPUT); break; } - tile.connections.replace(Direction.values()[guibutton.id], Connection.INPUT); + tile.fluidConnections.replace(Direction.values()[guibutton.id], Connection.INPUT); break; case INPUT: - tile.connections.replace(Direction.values()[guibutton.id], Connection.OUTPUT); + tile.fluidConnections.replace(Direction.values()[guibutton.id], Connection.OUTPUT); break; case OUTPUT: if (tile.getBlockType() == SignalIndustries.infiniteEnergyCell) { - tile.connections.replace(Direction.values()[guibutton.id], Connection.NONE); + tile.fluidConnections.replace(Direction.values()[guibutton.id], Connection.NONE); break; } - tile.connections.replace(Direction.values()[guibutton.id], Connection.BOTH); + tile.fluidConnections.replace(Direction.values()[guibutton.id], Connection.BOTH); break; case BOTH: - tile.connections.replace(Direction.values()[guibutton.id], Connection.NONE); + tile.fluidConnections.replace(Direction.values()[guibutton.id], Connection.NONE); break; } - guibutton.displayString = tile.connections.get(Direction.values()[guibutton.id]).getLetter(); + guibutton.displayString = tile.fluidConnections.get(Direction.values()[guibutton.id]).getLetter(); } if (guibutton.id > 5 && guibutton.id < 12) { @@ -189,21 +188,21 @@ protected void buttonPressed(GuiButton guibutton) { } if (guibutton.id == 12) { for (Direction direction : Direction.values()) { - tile.connections.replace(direction, Connection.INPUT); + tile.fluidConnections.replace(direction, Connection.INPUT); } for (GuiButton button : controlList) { if (button.id >= 0 && button.id < 6) { - button.displayString = tile.connections.get(Direction.values()[button.id]).getLetter(); + button.displayString = tile.fluidConnections.get(Direction.values()[button.id]).getLetter(); } } } if (guibutton.id == 13) { for (Direction direction : Direction.values()) { - tile.connections.replace(direction, Connection.OUTPUT); + tile.fluidConnections.replace(direction, Connection.OUTPUT); } for (GuiButton button : controlList) { if (button.id >= 0 && button.id < 6) { - button.displayString = tile.connections.get(Direction.values()[button.id]).getLetter(); + button.displayString = tile.fluidConnections.get(Direction.values()[button.id]).getLetter(); } } } diff --git a/src/main/java/sunsetsatellite/signalindustries/gui/GuiItemIOConfig.java b/src/main/java/sunsetsatellite/signalindustries/gui/GuiItemIOConfig.java index 7c974cdb..7d47e41a 100644 --- a/src/main/java/sunsetsatellite/signalindustries/gui/GuiItemIOConfig.java +++ b/src/main/java/sunsetsatellite/signalindustries/gui/GuiItemIOConfig.java @@ -54,9 +54,9 @@ public void action2Performed(GuiButton guibutton) { if(guibutton.id > 5){ Direction dir = Direction.values()[guibutton.id-6]; Integer currentValue = tile.activeItemSlots.get(dir); - if(currentValue > 0){ + if(currentValue > -1){ tile.activeItemSlots.put(dir,currentValue-1); - guibutton.displayString = String.valueOf(tile.activeItemSlots.get(dir)); + guibutton.displayString = tile.activeItemSlots.get(dir) == -1 ? "*" : String.valueOf(tile.activeItemSlots.get(dir)); } } @@ -112,12 +112,12 @@ public void init() { controlList.add(new GuiButton(1, Math.round(width / 2) - 24, Math.round(height / 2) - 48, 15, 15, tile.itemConnections.get(Direction.X_NEG).getLetter())); //X- controlList.add(new GuiButton(5, Math.round(width / 2) + 4, Math.round(height / 2) - 33, 15, 15, tile.itemConnections.get(Direction.Z_NEG).getLetter())); //Z- - controlList.add(new GuiButton(8, Math.round(width / 2) - 10 + 50, Math.round(height / 2) - 63, 15, 15, String.valueOf(tile.activeItemSlots.get(Direction.Y_POS)))); - controlList.add(new GuiButton(10, Math.round(width / 2) - 10 + 50, Math.round(height / 2) - 48, 15, 15, String.valueOf(tile.activeItemSlots.get(Direction.Z_POS)))); - controlList.add(new GuiButton(9, Math.round(width / 2) - 10 + 50, Math.round(height / 2) - 33, 15, 15, String.valueOf(tile.activeItemSlots.get(Direction.Y_NEG)))); - controlList.add(new GuiButton(6, Math.round(width / 2) + 4 + 50, Math.round(height / 2) - 48, 15, 15, String.valueOf(tile.activeItemSlots.get(Direction.X_POS)))); - controlList.add(new GuiButton(7, Math.round(width / 2) - 24 + 50, Math.round(height / 2) - 48, 15, 15, String.valueOf(tile.activeItemSlots.get(Direction.X_NEG)))); - controlList.add(new GuiButton(11, Math.round(width / 2) + 4 + 50, Math.round(height / 2) - 33, 15, 15, String.valueOf(tile.activeItemSlots.get(Direction.Z_NEG)))); + controlList.add(new GuiButton(8, Math.round(width / 2) - 10 + 50, Math.round(height / 2) - 63, 15, 15, tile.activeItemSlots.get(Direction.Y_POS) == -1 ? "*" : String.valueOf(tile.activeItemSlots.get(Direction.Y_POS)))); + controlList.add(new GuiButton(10, Math.round(width / 2) - 10 + 50, Math.round(height / 2) - 48, 15, 15, tile.activeItemSlots.get(Direction.Z_POS) == -1 ? "*" : String.valueOf(tile.activeItemSlots.get(Direction.Z_POS)))); + controlList.add(new GuiButton(9, Math.round(width / 2) - 10 + 50, Math.round(height / 2) - 33, 15, 15, tile.activeItemSlots.get(Direction.Y_NEG) == -1 ? "*" : String.valueOf(tile.activeItemSlots.get(Direction.Y_NEG)))); + controlList.add(new GuiButton(6, Math.round(width / 2) + 4 + 50, Math.round(height / 2) - 48, 15, 15, tile.activeItemSlots.get(Direction.X_POS) == -1 ? "*" : String.valueOf(tile.activeItemSlots.get(Direction.X_POS)))); + controlList.add(new GuiButton(7, Math.round(width / 2) - 24 + 50, Math.round(height / 2) - 48, 15, 15, tile.activeItemSlots.get(Direction.X_NEG) == -1 ? "*" : String.valueOf(tile.activeItemSlots.get(Direction.X_NEG)))); + controlList.add(new GuiButton(11, Math.round(width / 2) + 4 + 50, Math.round(height / 2) - 33, 15, 15, tile.activeItemSlots.get(Direction.Z_NEG) == -1 ? "*" : String.valueOf(tile.activeItemSlots.get(Direction.Z_NEG)))); controlList.add(new GuiButton(12,(width / 2) - 85, (height / 2)-12, 30, 15, "All I")); controlList.add(new GuiButton(13, (width / 2) - 55, (height / 2)-12, 30, 15, "All O")); diff --git a/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityEnergyCell.java b/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityEnergyCell.java index fc2048b4..8c5e2bc7 100644 --- a/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityEnergyCell.java +++ b/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityEnergyCell.java @@ -12,7 +12,6 @@ import sunsetsatellite.signalindustries.SignalIndustries; import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered; import sunsetsatellite.signalindustries.interfaces.IHasIOPreview; -import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; import sunsetsatellite.signalindustries.util.IOPreview; import sunsetsatellite.signalindustries.util.Tier; @@ -27,8 +26,8 @@ public class TileEntityEnergyCell extends TileEntityFluidItemContainer implement public TileEntityEnergyCell(){ fluidCapacity[0] = 8000; transferSpeed = 50; - connections.replace(Direction.Y_POS, Connection.INPUT); - connections.replace(Direction.Y_NEG, Connection.OUTPUT); + fluidConnections.replace(Direction.Y_POS, Connection.INPUT); + fluidConnections.replace(Direction.Y_NEG, Connection.OUTPUT); acceptedFluids.get(0).add((BlockFluid) SignalIndustries.energyFlowing); } @@ -40,7 +39,7 @@ public TileEntityEnergyCell(){ public void tick() { if(getBlockType() != null){ if(((BlockContainerTiered)getBlockType()).tier == Tier.INFINITE){ - for (Map.Entry entry : connections.entrySet()) { + for (Map.Entry entry : fluidConnections.entrySet()) { if(isInfiniteSource){ if(entry.getValue() == Connection.INPUT || entry.getValue() == Connection.BOTH){ entry.setValue(Connection.OUTPUT); @@ -100,7 +99,7 @@ public String getInvName() { } public void extractFluids(){ - for (Map.Entry e : connections.entrySet()) { + for (Map.Entry e : fluidConnections.entrySet()) { Direction dir = e.getKey(); Connection connection = e.getValue(); TileEntity tile = dir.getTileEntity(worldObj,this); diff --git a/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityEnergyConnector.java b/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityEnergyConnector.java index 6a2305bf..e18e2ef9 100644 --- a/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityEnergyConnector.java +++ b/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityEnergyConnector.java @@ -22,7 +22,7 @@ public TileEntityEnergyConnector(){ fluidCapacity = new int[1]; fluidCapacity[0] = 16000; acceptedFluids.get(0).add((BlockFluid) SignalIndustries.energyFlowing); - connections.put(Direction.Y_POS, Connection.OUTPUT); + fluidConnections.put(Direction.Y_POS, Connection.OUTPUT); } @Override diff --git a/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityExternalIO.java b/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityExternalIO.java index c945389a..4acbb3f3 100644 --- a/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityExternalIO.java +++ b/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityExternalIO.java @@ -211,6 +211,33 @@ public int getActiveFluidSlot(Direction dir) { return 0; } + @Override + public int getActiveItemSlotForSide(Direction dir, ItemStack stack) { + if(externalTile instanceof IInventory){ + if(activeItemSlots.get(dir) == -1){ + if(itemConnections.get(dir) == Connection.INPUT){ + for (int i = 0; i < ((IInventory) externalTile).getSizeInventory(); i++) { + ItemStack content = ((IInventory) externalTile).getStackInSlot(i); + if (content == null || content.isItemEqual(stack)) { + return i; + } + } + } else if(itemConnections.get(dir) == Connection.OUTPUT) { + for (int i = 0; i < ((IInventory) externalTile).getSizeInventory(); i++) { + ItemStack content = ((IInventory) externalTile).getStackInSlot(i); + if (content != null) { + return i; + } + } + } + return 0; + } else { + return activeItemSlots.get(dir); + } + } + return 0; + } + @Override public void tick() { super.tick(); diff --git a/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityIgnitor.java b/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityIgnitor.java index 06f38d38..1c20ce2b 100644 --- a/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityIgnitor.java +++ b/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityIgnitor.java @@ -30,7 +30,7 @@ public TileEntityIgnitor(){ } acceptedFluids.get(0).add((BlockFluid) SignalIndustries.energyFlowing); for (Direction dir : Direction.values()) { - connections.put(dir, Connection.INPUT); + fluidConnections.put(dir, Connection.INPUT); activeFluidSlots.put(dir,0); } transferSpeed = 10; @@ -66,13 +66,13 @@ public void work(){ public void spreadFluids(Direction dir) { for (Direction direction : Direction.values()) { - connections.put(dir, Connection.BOTH); + fluidConnections.put(dir, Connection.BOTH); } if(getFluidInSlot(0) != null){ this.give(dir); } for (Direction direction : Direction.values()) { - connections.put(dir, Connection.INPUT); + fluidConnections.put(dir, Connection.INPUT); } } @@ -89,7 +89,7 @@ public boolean isReady(){ } public void extractFluids(){ - for (Map.Entry e : connections.entrySet()) { + for (Map.Entry e : fluidConnections.entrySet()) { Direction dir = e.getKey(); Connection connection = e.getValue(); TileEntity tile = dir.getTileEntity(worldObj,this); diff --git a/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityItemConduit.java b/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityItemConduit.java index 4754b243..555b218d 100644 --- a/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityItemConduit.java +++ b/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntityItemConduit.java @@ -438,7 +438,7 @@ public void insertItem(){ IItemIO io = ((IItemIO) tileEntity); IInventory inv = ((IInventory) tileEntity); if(io.getItemIOForSide(entry) == Connection.INPUT || io.getItemIOForSide(entry) == Connection.BOTH){ - int slot = io.getActiveItemSlotForSide(entry); + int slot = io.getActiveItemSlotForSide(entry,stack); ItemStack tileStack = inv.getStackInSlot(slot); if(tileStack == null || (tileStack.isItemEqual(stack) && tileStack.stackSize+stack.stackSize <= tileStack.getMaxStackSize())){ if(tileStack == null){ diff --git a/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntitySIFluidTank.java b/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntitySIFluidTank.java index bb0c2b9d..66564343 100644 --- a/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntitySIFluidTank.java +++ b/src/main/java/sunsetsatellite/signalindustries/inventories/TileEntitySIFluidTank.java @@ -24,8 +24,8 @@ public class TileEntitySIFluidTank extends TileEntityFluidItemContainer implemen public TileEntitySIFluidTank(){ fluidCapacity[0] = 8000; transferSpeed = 50; - connections.replace(Direction.Y_POS, Connection.INPUT); - connections.replace(Direction.Y_NEG, Connection.OUTPUT); + fluidConnections.replace(Direction.Y_POS, Connection.INPUT); + fluidConnections.replace(Direction.Y_NEG, Connection.OUTPUT); for (BlockFluid fluid : CatalystFluids.FLUIDS.getAllFluids()) { if(fluid != SignalIndustries.energyFlowing) { acceptedFluids.get(0).add(fluid); @@ -49,7 +49,7 @@ public String getInvName() { } public void extractFluids(){ - for (Map.Entry e : connections.entrySet()) { + for (Map.Entry e : fluidConnections.entrySet()) { Direction dir = e.getKey(); Connection connection = e.getValue(); TileEntity tile = dir.getTileEntity(worldObj,this); diff --git a/src/main/java/sunsetsatellite/signalindustries/inventories/base/TileEntityTieredContainer.java b/src/main/java/sunsetsatellite/signalindustries/inventories/base/TileEntityTieredContainer.java index 41ac84e7..c91bcc77 100644 --- a/src/main/java/sunsetsatellite/signalindustries/inventories/base/TileEntityTieredContainer.java +++ b/src/main/java/sunsetsatellite/signalindustries/inventories/base/TileEntityTieredContainer.java @@ -24,7 +24,7 @@ public void tick() { } public void extractFluids(){ - for (Map.Entry e : connections.entrySet()) { + for (Map.Entry e : fluidConnections.entrySet()) { Direction dir = e.getKey(); Connection connection = e.getValue(); TileEntity tile = dir.getTileEntity(worldObj,this); diff --git a/src/main/java/sunsetsatellite/signalindustries/inventories/base/TileEntityTieredMachineBase.java b/src/main/java/sunsetsatellite/signalindustries/inventories/base/TileEntityTieredMachineBase.java index c4c5fc8c..310c1745 100644 --- a/src/main/java/sunsetsatellite/signalindustries/inventories/base/TileEntityTieredMachineBase.java +++ b/src/main/java/sunsetsatellite/signalindustries/inventories/base/TileEntityTieredMachineBase.java @@ -3,6 +3,7 @@ import com.mojang.nbt.CompoundTag; import net.minecraft.core.block.entity.TileEntity; +import net.minecraft.core.item.ItemStack; import sunsetsatellite.catalyst.core.util.Connection; import sunsetsatellite.catalyst.core.util.Direction; import sunsetsatellite.catalyst.core.util.IFluidIO; @@ -98,12 +99,55 @@ public int getActiveFluidSlotForSide(Direction dir) { @Override public Connection getFluidIOForSide(Direction dir) { - return connections.get(dir); + return fluidConnections.get(dir); } @Override public int getActiveItemSlotForSide(Direction dir) { - return activeItemSlots.get(dir); + if(activeItemSlots.get(dir) == -1){ + if(itemConnections.get(dir) == Connection.INPUT){ + for (int i = 0; i < itemContents.length; i++) { + ItemStack content = itemContents[i]; + if (content == null) { + return i; + } + } + } else if(itemConnections.get(dir) == Connection.OUTPUT) { + for (int i = 0; i < itemContents.length; i++) { + ItemStack content = itemContents[i]; + if (content != null) { + return i; + } + } + } + return 0; + } else { + return activeItemSlots.get(dir); + } + } + + @Override + public int getActiveItemSlotForSide(Direction dir, ItemStack stack) { + if(activeItemSlots.get(dir) == -1){ + if(itemConnections.get(dir) == Connection.INPUT){ + for (int i = 0; i < itemContents.length; i++) { + ItemStack content = itemContents[i]; + if (content == null || content.isItemEqual(stack)) { + return i; + } + } + } else if(itemConnections.get(dir) == Connection.OUTPUT) { + for (int i = 0; i < itemContents.length; i++) { + ItemStack content = itemContents[i]; + if (content != null) { + return i; + } + } + } + return 0; + } else { + return activeItemSlots.get(dir); + } } @Override diff --git a/src/main/java/sunsetsatellite/signalindustries/inventories/machines/TileEntityAssembler.java b/src/main/java/sunsetsatellite/signalindustries/inventories/machines/TileEntityAssembler.java new file mode 100644 index 00000000..00720585 --- /dev/null +++ b/src/main/java/sunsetsatellite/signalindustries/inventories/machines/TileEntityAssembler.java @@ -0,0 +1,365 @@ +package sunsetsatellite.signalindustries.inventories.machines; + +import com.mojang.nbt.CompoundTag; +import com.mojang.nbt.IntTag; +import com.mojang.nbt.ListTag; +import net.minecraft.core.InventoryAction; +import net.minecraft.core.block.BlockFluid; +import net.minecraft.core.block.entity.TileEntity; +import net.minecraft.core.data.registry.Registries; +import net.minecraft.core.data.registry.recipe.RecipeSymbol; +import net.minecraft.core.data.registry.recipe.entry.RecipeEntryCrafting; +import net.minecraft.core.data.registry.recipe.entry.RecipeEntryCraftingDynamic; +import net.minecraft.core.data.registry.recipe.entry.RecipeEntryCraftingShaped; +import net.minecraft.core.data.registry.recipe.entry.RecipeEntryCraftingShapeless; +import net.minecraft.core.entity.EntityItem; +import net.minecraft.core.entity.player.EntityPlayer; +import net.minecraft.core.item.Item; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.player.inventory.Container; +import net.minecraft.core.player.inventory.IInventory; +import net.minecraft.core.player.inventory.InventoryCrafting; +import net.minecraft.core.player.inventory.slot.Slot; +import net.minecraft.core.world.World; +import sunsetsatellite.catalyst.core.util.Connection; +import sunsetsatellite.catalyst.core.util.Direction; +import sunsetsatellite.catalyst.core.util.IFluidIO; +import sunsetsatellite.catalyst.core.util.IItemIO; +import sunsetsatellite.catalyst.fluids.util.FluidStack; +import sunsetsatellite.signalindustries.SignalIndustries; +import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered; +import sunsetsatellite.signalindustries.containers.ContainerAssembler; +import sunsetsatellite.signalindustries.interfaces.IBoostable; +import sunsetsatellite.signalindustries.inventories.TileEntityExternalIO; +import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; + +import java.util.*; +import java.util.stream.Collectors; + +public class TileEntityAssembler extends TileEntityTieredMachineBase implements IBoostable { + + public final AssemblerTemplate template = new AssemblerTemplate(); + public RecipeEntryCrafting recipe; + + public TileEntityAssembler() { + itemContents = new ItemStack[19]; + fluidContents = new FluidStack[1]; + fluidCapacity = new int[1]; + fluidCapacity[0] = 2000; + acceptedFluids.get(0).add((BlockFluid) SignalIndustries.energyFlowing); + } + + @Override + public String getInvName() { + return "Assembler"; + } + + @Override + public void tick() { + super.tick(); + extractFluids(); + worldObj.markBlocksDirty(x,y,z,x,y,z); + BlockContainerTiered block = (BlockContainerTiered) getBlockType(); + if(block != null){ + work(); + } + } + + @Override + public void applyModifiers() { + super.applyModifiers(); + yield = 1; + if(speedMultiplier > 1){ + speedMultiplier *= 1.25f; + } + } + + private void work() { + boolean update = false; + if(fuelBurnTicks > 0){ + fuelBurnTicks--; + } + if(!canProcess()){ + progressTicks = 0; + } else + if(canProcess()) { + progressMaxTicks = (int) (90 / speedMultiplier); + } + if(!worldObj.isClientSide){ + if (progressTicks == 0 && canProcess()){ + update = fuel(); + } + if(isBurning() && canProcess()){ + progressTicks++; + if(progressTicks >= progressMaxTicks){ + progressTicks = 0; + processItem(); + update = true; + } + } else if(canProcess()){ + fuel(); + if(fuelBurnTicks > 0){ + fuelBurnTicks++; + } + } + } + + if(update) { + this.onInventoryChanged(); + } + } + + public void processItem() { + if(!canProcess()) return; + if(recipe == null) return; + ArrayList condensedInv = SignalIndustries.condenseList(Arrays.asList(itemContents)); + ArrayList recipeInputs = new ArrayList<>(); + if(recipe.getInput() instanceof RecipeSymbol[]){ + recipeInputs = new ArrayList<>(Arrays.asList(((RecipeSymbol[]) recipe.getInput()))); + } else if (recipe.getInput() instanceof List) { + recipeInputs = (ArrayList) recipe.getInput(); + } + if(recipeInputs.isEmpty()) return; + recipeInputs.removeIf(Objects::isNull); + if(!(SignalIndustries.hasItems(recipeInputs,condensedInv))){ + return; + } + int s = 0; + int sReq = (int) recipeInputs.stream().filter(Objects::nonNull).count(); + label: + for (RecipeSymbol symbol : recipeInputs) { + for (ItemStack stack : itemContents) { + if(symbol.matches(stack)){ + if(stack == null || stack.stackSize <= 0) continue; + stack.stackSize--; + if(stack.getItem().hasContainerItem()){ + ItemStack container = new ItemStack(stack.getItem().getContainerItem()); + boolean added = false; + for (int i = 1; i < itemContents.length; i++) { + ItemStack content = itemContents[i]; + if (content == null) { + setInventorySlotContents(i, container); + added = true; + break; + } else if (content.isItemEqual(container) && content.stackSize < content.getMaxStackSize()) { + itemContents[i].stackSize++; + added = true; + break; + } + } + if(!added){ + EntityItem entityitem = new EntityItem(worldObj, (float) x, (float)y+1, (float)z, container); + worldObj.entityJoinedWorld(entityitem); + } + } + s++; + continue label; + } + } + } + itemContents = Arrays.stream(itemContents).filter((S)->S == null || S.stackSize > 0).toArray((A)-> new ItemStack[19]); + if(s == sReq){ + final int multiplier = 1; + /*float fraction = Float.parseFloat("0."+(String.valueOf(yield).split("\\.")[1])); + if(fraction <= 0) fraction = 1; + if(yield > 1 && Math.random() <= fraction){ + multiplier = (int) Math.ceil(yield); + }*/ + ItemStack output = recipe.getOutput().copy(); + if(itemContents[0] != null && (!(itemContents[0].isItemEqual(output)) || itemContents[0].stackSize+(output.stackSize*multiplier) > itemContents[0].getMaxStackSize())) return; + if(itemContents[0] == null){ + output.stackSize *= multiplier; + itemContents[0] = output; + } else { + itemContents[0].stackSize += (output.stackSize * multiplier); + } + } + } + + public boolean canProcess(){ + if(recipe == null) return false; + final int multiplier = 1; + /*float fraction = Float.parseFloat("0."+(String.valueOf(yield).split("\\.")[1])); + if(fraction <= 0) fraction = 1; + if(yield > 1 && Math.random() <= fraction){ + multiplier = (int) Math.ceil(yield); + }*/ + ItemStack output = recipe.getOutput().copy(); + if(itemContents[0] != null && (!(itemContents[0].isItemEqual(output)) || itemContents[0].stackSize+(output.stackSize*multiplier) > itemContents[0].getMaxStackSize())) return false; + ArrayList condensedInv = SignalIndustries.condenseList(Arrays.asList(itemContents)); + ArrayList recipeInputs = new ArrayList<>(); + if(recipe.getInput() instanceof RecipeSymbol[]){ + recipeInputs = new ArrayList<>(Arrays.asList(((RecipeSymbol[]) recipe.getInput()))); + } else if (recipe.getInput() instanceof List) { + recipeInputs = (ArrayList) recipe.getInput(); + } + if(recipeInputs.isEmpty()) return false; + recipeInputs.removeIf(Objects::isNull); + return SignalIndustries.hasItems(recipeInputs,condensedInv); + } + + public boolean fuel(){ + int burn = SignalIndustries.getEnergyBurnTime(fluidContents[0]); + if(burn > 0 && canProcess() && recipe != null){ + if(fluidContents[0].amount >= 100){ + progressMaxTicks = (int) (90 / speedMultiplier); + fuelMaxBurnTicks = fuelBurnTicks = burn; + fluidContents[0].amount -= 100; + if (fluidContents[0].amount == 0) { + fluidContents[0] = null; + } + return true; + } + } + return false; + } + + @Override + public void writeToNBT(CompoundTag nBTTagCompound1) { + super.writeToNBT(nBTTagCompound1); + CompoundTag templateTag = new CompoundTag(); + template.writeToNBT(templateTag); + nBTTagCompound1.put("Template", templateTag); + } + + @Override + public void readFromNBT(CompoundTag nBTTagCompound1) { + super.readFromNBT(nBTTagCompound1); + template.readFromNBT(nBTTagCompound1.getCompound("Template")); + template.onInventoryChanged(); + } + + @Override + public int getActiveItemSlotForSide(Direction dir, ItemStack stack) { + if(activeItemSlots.get(dir) == -1) { + if (itemConnections.get(dir) == Connection.INPUT) { + for (int i = 1; i < itemContents.length; i++) { + ItemStack content = itemContents[i]; + if (content == null || content.isItemEqual(stack)) { + return i; + } + } + } + } + return super.getActiveItemSlotForSide(dir,stack); + } + + //extending inventorycrafting is a dirty hack lmao + public class AssemblerTemplate extends InventoryCrafting implements IInventory { + + public ItemStack[] itemContents = new ItemStack[9]; + + public AssemblerTemplate() { + super(null, 3, 3); + } + + @Override + public int getSizeInventory() { + return itemContents.length; + } + + @Override + public ItemStack getStackInSlot(int i1) { + return this.itemContents[i1]; + } + + @Override + public ItemStack decrStackSize(int i1, int i2) { + if(this.itemContents[i1] != null) { + ItemStack itemStack3; + if(this.itemContents[i1].stackSize <= i2) { + itemStack3 = this.itemContents[i1]; + this.itemContents[i1] = null; + this.onInventoryChanged(); + return itemStack3; + } else { + itemStack3 = this.itemContents[i1].splitStack(i2); + if(this.itemContents[i1].stackSize == 0) { + this.itemContents[i1] = null; + } + + this.onInventoryChanged(); + return itemStack3; + } + } else { + return null; + } + } + + @Override + public void setInventorySlotContents(int i1, ItemStack itemStack2) { + this.itemContents[i1] = itemStack2; + if(itemStack2 != null && itemStack2.stackSize > this.getInventoryStackLimit()) { + itemStack2.stackSize = this.getInventoryStackLimit(); + } + + this.onInventoryChanged(); + } + + @Override + public String getInvName() { + return "Assembler Template Grid"; + } + + public void readFromNBT(CompoundTag CompoundTag1) { + ListTag nBTTagList2 = CompoundTag1.getList("Items"); + this.itemContents = new ItemStack[this.getSizeInventory()]; + + for(int i3 = 0; i3 < nBTTagList2.tagCount(); ++i3) { + CompoundTag CompoundTag4 = (CompoundTag)nBTTagList2.tagAt(i3); + int i5 = CompoundTag4.getByte("Slot") & 255; + if(i5 >= 0 && i5 < this.itemContents.length) { + this.itemContents[i5] = ItemStack.readItemStackFromNbt(CompoundTag4); + } + } + } + + public void writeToNBT(CompoundTag CompoundTag1) { + ListTag nbtTagList = new ListTag(); + + for(int i3 = 0; i3 < this.itemContents.length; ++i3) { + if(this.itemContents[i3] != null) { + CompoundTag CompoundTag4 = new CompoundTag(); + CompoundTag4.putByte("Slot", (byte)i3); + this.itemContents[i3].writeToNBT(CompoundTag4); + nbtTagList.addTag(CompoundTag4); + } + } + + CompoundTag1.put("Items", nbtTagList); + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public void onInventoryChanged() { + TileEntityAssembler.this.recipe = findMatchingRecipe(this); + } + + @Override + public boolean canInteractWith(EntityPlayer entityPlayer1) { + return true; + } + + @Override + public void sortInventory() { + + } + + public RecipeEntryCrafting findMatchingRecipe(AssemblerTemplate template){ + for(int i = 0; i < Registries.RECIPES.getAllCraftingRecipes().size(); i++) + { + RecipeEntryCrafting recipe = Registries.RECIPES.getAllCraftingRecipes().get(i); + if(recipe.matches(template) && !(recipe instanceof RecipeEntryCraftingDynamic)) + { + return (RecipeEntryCrafting) recipe; + } + } + + return null; + } + } +} diff --git a/src/main/java/sunsetsatellite/signalindustries/inventories/machines/TileEntityBooster.java b/src/main/java/sunsetsatellite/signalindustries/inventories/machines/TileEntityBooster.java index 87855bcd..f6b5ca43 100644 --- a/src/main/java/sunsetsatellite/signalindustries/inventories/machines/TileEntityBooster.java +++ b/src/main/java/sunsetsatellite/signalindustries/inventories/machines/TileEntityBooster.java @@ -18,8 +18,6 @@ import sunsetsatellite.signalindustries.entities.fx.EntityColorParticleFX; import sunsetsatellite.signalindustries.interfaces.IBoostable; import sunsetsatellite.signalindustries.interfaces.IHasIOPreview; -import sunsetsatellite.signalindustries.recipes.legacy.InfuserRecipes; -import sunsetsatellite.signalindustries.recipes.legacy.MachineRecipesBase; import sunsetsatellite.signalindustries.util.IOPreview; import sunsetsatellite.signalindustries.util.Tier; @@ -209,7 +207,7 @@ public boolean isBurning(){ } public void extractFluids(){ - for (Map.Entry e : connections.entrySet()) { + for (Map.Entry e : fluidConnections.entrySet()) { Direction dir = e.getKey(); Connection connection = e.getValue(); TileEntity tile = dir.getTileEntity(worldObj,this); diff --git a/src/main/java/sunsetsatellite/signalindustries/inventories/machines/TileEntityStabilizer.java b/src/main/java/sunsetsatellite/signalindustries/inventories/machines/TileEntityStabilizer.java index 7735f15f..205b31a2 100644 --- a/src/main/java/sunsetsatellite/signalindustries/inventories/machines/TileEntityStabilizer.java +++ b/src/main/java/sunsetsatellite/signalindustries/inventories/machines/TileEntityStabilizer.java @@ -182,7 +182,7 @@ public boolean isBurning(){ } public void extractFluids(){ - for (Map.Entry e : connections.entrySet()) { + for (Map.Entry e : fluidConnections.entrySet()) { Direction dir = e.getKey(); Connection connection = e.getValue(); TileEntity tile = dir.getTileEntity(worldObj,this); diff --git a/src/main/java/sunsetsatellite/signalindustries/render/RenderAssemblerItemSprite3D.java b/src/main/java/sunsetsatellite/signalindustries/render/RenderAssemblerItemSprite3D.java new file mode 100644 index 00000000..5e60c83d --- /dev/null +++ b/src/main/java/sunsetsatellite/signalindustries/render/RenderAssemblerItemSprite3D.java @@ -0,0 +1,93 @@ +package sunsetsatellite.signalindustries.render; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiRenderItem; +import net.minecraft.client.render.ItemRenderer; +import net.minecraft.client.render.Lighting; +import net.minecraft.client.render.tileentity.TileEntityRenderer; +import net.minecraft.core.block.Block; +import net.minecraft.core.block.entity.TileEntity; +import net.minecraft.core.item.ItemStack; +import net.minecraft.core.lang.I18n; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; +import sunsetsatellite.signalindustries.inventories.machines.TileEntityAssembler; + +public class RenderAssemblerItemSprite3D extends TileEntityRenderer { + + private final GuiRenderItem itemRenderer = new GuiRenderItem(Minecraft.getMinecraft(this)); + @Override + public void doRender(TileEntityAssembler tileEntity, double x, double y, double z, float g) { + GL11.glPushMatrix(); + float scale = 0.6666667F; + float rot; + int i16 = tileEntity.getMovedData(); + rot = 0.0F; + if(i16 == 2) { + rot = 180.0F; + } + + if(i16 == 4) { + rot = 90.0F; + } + + if(i16 == 5) { + rot = -90.0F; + } + + GL11.glTranslatef((float)x + 0.5F, (float)y + 0.75F * scale, (float)z + 0.5F); + GL11.glRotatef(-rot, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, -0.3125F, -0.4375F); + + GL11.glPushMatrix(); + GL11.glScalef(scale, -scale, -scale); + GL11.glPopMatrix(); + rot = 0.016666668F * scale; + GL11.glTranslatef(0.0F, 0.5F * scale, 0.07F * scale); + GL11.glScalef(rot, -rot, rot); + GL11.glNormal3f(0.0F, 0.0F, -1.0F * rot); + GL11.glDepthMask(false); + GL11.glDisable(GL11.GL_LIGHTING); + int color = 0xFFFFFFFF; + ItemStack stack = null; + String name = ""; + String amount = ""; + + if(tileEntity.recipe != null) { + stack = tileEntity.recipe.getOutput(); + name = stack.getDisplayName(); + //amount = ((Integer) tileEntity.storedAmount).toString(); + } + int i14 = -6; + GL11.glTranslatef(0,28,82); + getFontRenderer().drawString(name, - getFontRenderer().getStringWidth(name) / 2, i14 * 10 - 5, color); + getFontRenderer().drawString(amount, - getFontRenderer().getStringWidth(amount) / 2, i14 * 10 + 64, color); + GL11.glTranslatef(0,-28,-82); + GL11.glScalef(2.5f,2.5f,0.3f); + GL11.glTranslatef(0,0,240); + drawItemStack(stack,-8, -8); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthMask(true); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glPopMatrix(); + } + + + private void drawItemStack(ItemStack stack, int x, int y) { + if(stack != null) { + GL11.glPushMatrix(); + GL11.glRotatef(120.0F, 1.0F, 0.0F, 0.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glTranslatef(0.0F, 0.0F, 32.0F); + itemRenderer.render(stack, x, y); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); + } + } +} \ No newline at end of file diff --git a/src/main/java/sunsetsatellite/signalindustries/util/GuiRenderFakeItem.java b/src/main/java/sunsetsatellite/signalindustries/util/GuiRenderFakeItem.java new file mode 100644 index 00000000..213d350b --- /dev/null +++ b/src/main/java/sunsetsatellite/signalindustries/util/GuiRenderFakeItem.java @@ -0,0 +1,113 @@ +package sunsetsatellite.signalindustries.util; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.core.Global; +import net.minecraft.core.WeightedRandomBag; +import net.minecraft.core.WeightedRandomLootObject; +import net.minecraft.core.data.registry.recipe.entry.RecipeEntryTrommel; +import net.minecraft.core.item.ItemStack; +import net.minecraft.client.render.Lighting; +import net.minecraft.client.render.entity.ItemEntityRenderer; +import net.minecraft.core.player.inventory.slot.Slot; +import net.minecraft.client.render.TextureFX; +import net.minecraft.core.player.inventory.slot.SlotGuidebook; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +public class GuiRenderFakeItem extends Gui +{ + static ItemEntityRenderer itemRenderer = new ItemEntityRenderer(); + + Minecraft mc; + + public GuiRenderFakeItem(Minecraft mc) + { + this.mc = mc; + } + + public void render(ItemStack itemStack, int x, int y, boolean isSelected, Slot slot) + { + boolean hasDrawnSlotBackground = false; + float alpha = 0.5f; + + // Do setup + Lighting.enableInventoryLight(); + GL11.glColor4f(1, 1, 1, alpha); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + // Draw slot background + if (slot != null) + { + final int iconIndex = slot.getBackgroundIconIndex(); + if (iconIndex >= 0 && itemStack == null) + { + GL11.glDisable(GL11.GL_LIGHTING); + mc.renderEngine.bindTexture(mc.renderEngine.getTexture("/gui/items.png")); + drawTexturedModalRect(x, y, + (iconIndex % Global.TEXTURE_ATLAS_WIDTH_TILES) * TextureFX.tileWidthItems, + (iconIndex / Global.TEXTURE_ATLAS_WIDTH_TILES) * TextureFX.tileWidthItems, + 16, 16, + TextureFX.tileWidthItems, + 1 / (float) (Global.TEXTURE_ATLAS_WIDTH_TILES * TextureFX.tileWidthItems)); + GL11.glEnable(GL11.GL_LIGHTING); + hasDrawnSlotBackground = true; + } + } + + // Draw item + if (!hasDrawnSlotBackground) + { + GL11.glEnable(GL11.GL_DEPTH_TEST); + itemRenderer.renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, itemStack, x, y, 1.0f, alpha); + if(slot instanceof SlotGuidebook){ + if(((SlotGuidebook) slot).recipe instanceof RecipeEntryTrommel && ((SlotGuidebook) slot).item != null && ((SlotGuidebook) slot).isOutput){ + WeightedRandomBag loot = ((RecipeEntryTrommel)((SlotGuidebook) slot).recipe).getOutput(); + int index = slot.id; + if(((SlotGuidebook) slot).recipeAmount > 8){ + index = slot.id + (9 * ((SlotGuidebook) slot).recipeIndex); + } + WeightedRandomLootObject lootObject = loot.getEntries().get(index); + String s; + if(lootObject.isRandom()){ + s = String.format("%d-%d",lootObject.getMinYield(),lootObject.getMaxYield()); + } else { + s = String.valueOf(lootObject.getFixedYield()); + } + itemRenderer.renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, itemStack, x, y, s, alpha); + } else { + itemRenderer.renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, itemStack, x, y, null, alpha); + } + } else { + itemRenderer.renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, itemStack, x, y, null, alpha); + } + GL11.glDisable(GL11.GL_DEPTH_TEST); + } + + // Draw selection overlay + if (isSelected) + { + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + drawRect(x, y, x + 16, y + 16, 0x80FFFFFF); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + // Clean up + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + Lighting.disable(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + } + + public void render(ItemStack itemStack, int x, int y, boolean isSelected) + { + render(itemStack, x, y, isSelected, null); + } + + public void render(ItemStack itemStack, int x, int y) + { + render(itemStack, x, y, false); + } +} diff --git a/src/main/java/sunsetsatellite/signalindustries/weather/WeatherMeteorShower.java b/src/main/java/sunsetsatellite/signalindustries/weather/WeatherMeteorShower.java index ff15294c..71ebdb73 100644 --- a/src/main/java/sunsetsatellite/signalindustries/weather/WeatherMeteorShower.java +++ b/src/main/java/sunsetsatellite/signalindustries/weather/WeatherMeteorShower.java @@ -24,13 +24,13 @@ public float[] modifyFogColor(float r, float g, float b, float intensity) { @Override public void doEnvironmentUpdate(World world, Random rand, int x, int z) { int y = world.getHeightValue(x, z); - EntityPlayer player = world.getClosestPlayer(x,y,z,32); + EntityPlayer player = world.getClosestPlayer(x,y,z,64); if(rand.nextInt(50) == 0 && player != null){ EntityFallingMeteor meteor; if(rand.nextInt(25) == 0){ - meteor = new EntityFallingMeteor(world, x, y + 32, z, SignalIndustries.signalumOre.id); + meteor = new EntityFallingMeteor(world, x, 255, z, SignalIndustries.signalumOre.id); } else { - meteor = new EntityFallingMeteor(world, x, y + 32, z, Block.basalt.id); + meteor = new EntityFallingMeteor(world, x, 255, z, Block.basalt.id); } world.entityJoinedWorld(meteor); } diff --git a/src/main/resources/assets/signalindustries/block/assembler_overlay_front.png b/src/main/resources/assets/signalindustries/block/assembler_overlay_front.png new file mode 100644 index 00000000..081a36fc Binary files /dev/null and b/src/main/resources/assets/signalindustries/block/assembler_overlay_front.png differ diff --git a/src/main/resources/assets/signalindustries/block/assembler_overlay_side.png b/src/main/resources/assets/signalindustries/block/assembler_overlay_side.png new file mode 100644 index 00000000..0be5c1c8 Binary files /dev/null and b/src/main/resources/assets/signalindustries/block/assembler_overlay_side.png differ diff --git a/src/main/resources/assets/signalindustries/block/basic_assembler_front.png b/src/main/resources/assets/signalindustries/block/basic_assembler_front.png new file mode 100644 index 00000000..649c2575 Binary files /dev/null and b/src/main/resources/assets/signalindustries/block/basic_assembler_front.png differ diff --git a/src/main/resources/assets/signalindustries/block/basic_assembler_front_active.png b/src/main/resources/assets/signalindustries/block/basic_assembler_front_active.png new file mode 100644 index 00000000..bf221410 Binary files /dev/null and b/src/main/resources/assets/signalindustries/block/basic_assembler_front_active.png differ diff --git a/src/main/resources/assets/signalindustries/block/basic_assembler_side.png b/src/main/resources/assets/signalindustries/block/basic_assembler_side.png new file mode 100644 index 00000000..e7d15670 Binary files /dev/null and b/src/main/resources/assets/signalindustries/block/basic_assembler_side.png differ diff --git a/src/main/resources/assets/signalindustries/block/basic_assembler_side_active.png b/src/main/resources/assets/signalindustries/block/basic_assembler_side_active.png new file mode 100644 index 00000000..190afdca Binary files /dev/null and b/src/main/resources/assets/signalindustries/block/basic_assembler_side_active.png differ diff --git a/src/main/resources/assets/signalindustries/block/container_prototype_front.png b/src/main/resources/assets/signalindustries/block/container_prototype_front.png new file mode 100644 index 00000000..6fa4799b Binary files /dev/null and b/src/main/resources/assets/signalindustries/block/container_prototype_front.png differ diff --git a/src/main/resources/assets/signalindustries/block/container_prototype_side.png b/src/main/resources/assets/signalindustries/block/container_prototype_side.png new file mode 100644 index 00000000..ffd1617b Binary files /dev/null and b/src/main/resources/assets/signalindustries/block/container_prototype_side.png differ diff --git a/src/main/resources/assets/signalindustries/gui/basic_assembler_gui.png b/src/main/resources/assets/signalindustries/gui/basic_assembler_gui.png new file mode 100644 index 00000000..45bcacac Binary files /dev/null and b/src/main/resources/assets/signalindustries/gui/basic_assembler_gui.png differ diff --git a/src/main/resources/assets/signalindustries/recipes/workbench.json b/src/main/resources/assets/signalindustries/recipes/workbench.json index 41f73a04..26ca2f6b 100644 --- a/src/main/resources/assets/signalindustries/recipes/workbench.json +++ b/src/main/resources/assets/signalindustries/recipes/workbench.json @@ -4967,5 +4967,62 @@ "meta": 0 }, "consumeContainers": false + }, + { + "name": "signalindustries:workbench/basic_assembler", + "type": "minecraft:crafting/shaped", + "pattern": [ + "CSC", + "WMW", + "CEC" + ], + "symbols": [ + { + "symbol": "W", + "stack": { + "key": "tile.workbench", + "amount": 1, + "meta": 0 + } + }, + { + "symbol": "M", + "stack": { + "key": "tile.signalindustries.basic.machine", + "amount": 1, + "meta": 0 + } + }, + { + "symbol": "E", + "stack": { + "key": "item.signalindustries.basicEnergyCore", + "amount": 1, + "meta": 0 + } + }, + { + "symbol": "C", + "stack": { + "key": "item.signalindustries.crystalAlloyPlate", + "amount": 1, + "meta": 0 + } + }, + { + "symbol": "S", + "stack": { + "key": "item.signalindustries.saturatedSignalumAlloyPlate", + "amount": 1, + "meta": 0 + } + } + ], + "result": { + "key": "tile.signalindustries.basic.assembler", + "amount": 1, + "meta": 0 + }, + "consumeContainers": false } ] \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 8f19547a..b1be69b0 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -39,6 +39,9 @@ ], "terrain-api": [ "sunsetsatellite.signalindustries.api.impl.terrainapi.TerrainAPISignalIndustriesPlugin" + ], + "btwaila": [ + "sunsetsatellite.signalindustries.api.impl.btwaila.BTWailaSIPlugin" ] }, "mixins": [ diff --git a/src/main/resources/lang/signalindustries/en_US.lang b/src/main/resources/lang/signalindustries/en_US.lang index efc12ed9..a33539c6 100644 --- a/src/main/resources/lang/signalindustries/en_US.lang +++ b/src/main/resources/lang/signalindustries/en_US.lang @@ -314,6 +314,9 @@ tile.signalindustries.reinforced.crusher.desc=Crushes almost anything into nano- tile.signalindustries.awakened.crusher.name=Awakened Macerating Atomizer Controller tile.signalindustries.awakened.crusher.desc=Will it blend? Only one way to find out! +tile.signalindustries.basic.assembler.name=Basic Assembler +tile.signalindustries.basic.assembler.desc=Crafts items, automatically! + tile.signalindustries.basic.wrathBeacon.name=Basic Wrath Beacon tile.signalindustries.basic.wrathBeacon.desc=A terrible machine capable of unleashing the evil from an [Evil Catalyst]. tile.signalindustries.reinforced.wrathBeacon.name=Reinforced Wrath Beacon