Merge branch 'master' of https://github.com/TechReborn/TechReborn
This commit is contained in:
commit
57b85450e6
17 changed files with 708 additions and 29 deletions
|
@ -0,0 +1,23 @@
|
|||
package techreborn.api.recipe.machines;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.api.recipe.BaseRecipe;
|
||||
import techreborn.lib.Reference;
|
||||
|
||||
public class AssemblingMachineRecipe extends BaseRecipe {
|
||||
|
||||
public AssemblingMachineRecipe(ItemStack input1, ItemStack input2, ItemStack output1, int tickTime, int euPerTick) {
|
||||
super(Reference.assemblingMachineRecipe, tickTime, euPerTick);
|
||||
if (input1 != null)
|
||||
inputs.add(input1);
|
||||
if (input2 != null)
|
||||
inputs.add(input2);
|
||||
if (output1 != null)
|
||||
addOutput(output1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserFreindlyName() {
|
||||
return "Assembling Machine";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package techreborn.blocks.machine;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ic2.api.item.IC2Items;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.Core;
|
||||
import techreborn.blocks.BlockMachineBase;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.tiles.TileAssemblingMachine;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockAssemblingMachine extends BlockMachineBase {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconFront;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconTop;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconFrontOn;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconBottom;
|
||||
|
||||
public BlockAssemblingMachine(Material material) {
|
||||
super(material);
|
||||
setBlockName("techreborn.assemblingmachine");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister icon) {
|
||||
this.blockIcon = icon.registerIcon("techreborn:machine/machine_side");
|
||||
this.iconFront = icon.registerIcon("techreborn:machine/assembling_machine_front_off");
|
||||
this.iconFrontOn = icon.registerIcon("techreborn:machine/assembling_machine_front_on");
|
||||
this.iconTop = icon.registerIcon("techreborn:machine/assembling_machine_top");
|
||||
this.iconBottom = icon.registerIcon("techreborn:machine/machine_bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
|
||||
return new TileAssemblingMachine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z,
|
||||
EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
if (!player.isSneaking())
|
||||
player.openGui(Core.INSTANCE, GuiHandler.assemblingmachineID, world, x, y,
|
||||
z);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(IBlockAccess blockAccess, int x, int y, int z, int side) {
|
||||
int metadata = getTileRotation(blockAccess, x, y, z);
|
||||
if (side == metadata && blockAccess.getBlockMetadata(x, y, z) == 1) {
|
||||
return this.iconFrontOn;
|
||||
}
|
||||
return metadata == 0 && side == 3 ? this.iconFront
|
||||
: side == 1 ? this.iconTop :
|
||||
side == 0 ? this.iconBottom : (side == 0 ? this.iconTop
|
||||
: (side == metadata ? this.iconFront : this.blockIcon));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
if(side == 1){
|
||||
return this.iconTop;
|
||||
} else if(side == 3){
|
||||
return this.iconFront;
|
||||
} else {
|
||||
return this.blockIcon;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@ public class GuiHandler implements IGuiHandler {
|
|||
public static final int matterfabID = 9;
|
||||
public static final int pdaID = 10;
|
||||
public static final int chunkloaderID = 11;
|
||||
public static final int assemblingmachineID = 12;
|
||||
public static final int dieselGeneratorID = 15;
|
||||
public static final int industrialElectrolyzerID = 16;
|
||||
public static final int aesuID = 17;
|
||||
|
@ -85,7 +86,10 @@ public class GuiHandler implements IGuiHandler {
|
|||
} else if (ID == chunkloaderID) {
|
||||
return new ContainerChunkloader(
|
||||
(TileChunkLoader) world.getTileEntity(x, y, z), player);
|
||||
} else if (ID == dieselGeneratorID) {
|
||||
} else if (ID == assemblingmachineID) {
|
||||
return new ContainerAssemblingMachine(
|
||||
(TileAssemblingMachine) world.getTileEntity(x, y, z), player);
|
||||
}else if (ID == dieselGeneratorID) {
|
||||
return new ContainerDieselGenerator(
|
||||
(TileDieselGenerator) world.getTileEntity(x, y, z), player);
|
||||
} else if (ID == industrialElectrolyzerID) {
|
||||
|
@ -164,7 +168,10 @@ public class GuiHandler implements IGuiHandler {
|
|||
} else if (ID == chunkloaderID) {
|
||||
return new GuiChunkLoader(player,
|
||||
(TileChunkLoader) world.getTileEntity(x, y, z));
|
||||
} else if (ID == dieselGeneratorID) {
|
||||
} else if (ID == assemblingmachineID) {
|
||||
return new GuiAssemblingMachine(player,
|
||||
(TileAssemblingMachine) world.getTileEntity(x, y, z));
|
||||
}else if (ID == dieselGeneratorID) {
|
||||
return new GuiDieselGenerator(player,
|
||||
(TileDieselGenerator) world.getTileEntity(x, y, z));
|
||||
} else if (ID == industrialElectrolyzerID) {
|
||||
|
|
|
@ -16,35 +16,36 @@ public class StackToolTipEvent {
|
|||
|
||||
@SubscribeEvent
|
||||
public void handleItemTooltipEvent(ItemTooltipEvent event) {
|
||||
if(event.itemStack.getItem() instanceof IListInfoProvider){
|
||||
if (event.itemStack.getItem() instanceof IListInfoProvider) {
|
||||
((IListInfoProvider) event.itemStack.getItem()).addInfo(event.toolTip, false);
|
||||
} else if (event.itemStack.getItem() instanceof IEnergyInterfaceItem){
|
||||
int percentage = percentage((int)((IEnergyInterfaceItem) event.itemStack.getItem()).getMaxPower(event.itemStack), (int)((IEnergyInterfaceItem) event.itemStack.getItem()).getEnergy(event.itemStack));
|
||||
ChatFormatting color;
|
||||
if(percentage<= 10){
|
||||
color = ChatFormatting.RED;
|
||||
} else if(percentage >= 75){
|
||||
color = ChatFormatting.GREEN;
|
||||
} else {
|
||||
color = ChatFormatting.YELLOW;
|
||||
}
|
||||
event.toolTip.add(color + "" + (int)((IEnergyInterfaceItem) event.itemStack.getItem()).getEnergy(event.itemStack) + ChatFormatting.LIGHT_PURPLE + " stored eu");
|
||||
event.toolTip.add(Color.GREEN + "" + (int)((IEnergyInterfaceItem) event.itemStack.getItem()).getMaxPower(event.itemStack) + ChatFormatting.LIGHT_PURPLE + " max eu");
|
||||
if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)){
|
||||
event.toolTip.add(ChatFormatting.GREEN +"" + percentage + "%" + ChatFormatting.LIGHT_PURPLE +" charged");
|
||||
event.toolTip.add(Color.GREEN + "" + (int)((IEnergyInterfaceItem) event.itemStack.getItem()).getMaxTransfer(event.itemStack) + ChatFormatting.LIGHT_PURPLE + " eu/tick in/out");
|
||||
} else if (event.itemStack.getItem() instanceof IEnergyInterfaceItem) {
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
|
||||
int percentage = percentage((int) ((IEnergyInterfaceItem) event.itemStack.getItem()).getMaxPower(event.itemStack), (int) ((IEnergyInterfaceItem) event.itemStack.getItem()).getEnergy(event.itemStack));
|
||||
ChatFormatting color;
|
||||
if (percentage <= 10) {
|
||||
color = ChatFormatting.RED;
|
||||
} else if (percentage >= 75) {
|
||||
color = ChatFormatting.GREEN;
|
||||
} else {
|
||||
color = ChatFormatting.YELLOW;
|
||||
}
|
||||
event.toolTip.add(color + "" + (int) ((IEnergyInterfaceItem) event.itemStack.getItem()).getEnergy(event.itemStack) + ChatFormatting.LIGHT_PURPLE + " stored eu");
|
||||
event.toolTip.add(Color.GREEN + "" + (int) ((IEnergyInterfaceItem) event.itemStack.getItem()).getMaxPower(event.itemStack) + ChatFormatting.LIGHT_PURPLE + " max eu");
|
||||
event.toolTip.add(ChatFormatting.GREEN + "" + percentage + "%" + ChatFormatting.LIGHT_PURPLE + " charged");
|
||||
event.toolTip.add(Color.GREEN + "" + (int) ((IEnergyInterfaceItem) event.itemStack.getItem()).getMaxTransfer(event.itemStack) + ChatFormatting.LIGHT_PURPLE + " eu/tick in/out");
|
||||
}
|
||||
} else {
|
||||
Block block = Block.getBlockFromItem(event.itemStack.getItem());
|
||||
if(block != null && block instanceof BlockContainer && block.getClass().getCanonicalName().startsWith("techreborn.")){
|
||||
if (block != null && block instanceof BlockContainer && block.getClass().getCanonicalName().startsWith("techreborn.")) {
|
||||
TileEntity tile = block.createTileEntity(Minecraft.getMinecraft().theWorld, event.itemStack.getItemDamage());
|
||||
if(tile instanceof IListInfoProvider){
|
||||
if (tile instanceof IListInfoProvider) {
|
||||
((IListInfoProvider) tile).addInfo(event.toolTip, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int percentage(int MaxValue, int CurrentValue) {
|
||||
if (CurrentValue == 0)
|
||||
return 0;
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotOutput;
|
||||
import techreborn.tiles.TileAssemblingMachine;
|
||||
|
||||
public class ContainerAssemblingMachine extends ContainerCrafting {
|
||||
|
||||
EntityPlayer player;
|
||||
|
||||
TileAssemblingMachine tile;
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int tickTime;
|
||||
|
||||
public ContainerAssemblingMachine(TileAssemblingMachine tileAssemblingMachine,
|
||||
EntityPlayer player) {
|
||||
super(tileAssemblingMachine.crafter);
|
||||
tile = tileAssemblingMachine;
|
||||
this.player = player;
|
||||
|
||||
// input
|
||||
this.addSlotToContainer(new Slot(tileAssemblingMachine.inventory, 0, 47, 17));
|
||||
this.addSlotToContainer(new Slot(tileAssemblingMachine.inventory, 1, 65, 17));
|
||||
// outputs
|
||||
this.addSlotToContainer(new SlotOutput(tileAssemblingMachine.inventory, 2, 116, 35));
|
||||
// power
|
||||
this.addSlotToContainer(new Slot(tileAssemblingMachine.inventory, 3, 56, 53));
|
||||
// upgrades
|
||||
this.addSlotToContainer(new Slot(tileAssemblingMachine.inventory, 4, 152, 8));
|
||||
this.addSlotToContainer(new Slot(tileAssemblingMachine.inventory, 5, 152, 26));
|
||||
this.addSlotToContainer(new Slot(tileAssemblingMachine.inventory, 6, 152, 44));
|
||||
this.addSlotToContainer(new Slot(tileAssemblingMachine.inventory, 7, 152, 62));
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
|
||||
+ 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
|
||||
142));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotFake;
|
||||
import techreborn.client.SlotOutput;
|
||||
|
@ -9,6 +12,8 @@ import techreborn.tiles.TileDieselGenerator;
|
|||
public class ContainerDieselGenerator extends TechRebornContainer {
|
||||
public TileDieselGenerator tiledieselGenerator;
|
||||
public EntityPlayer player;
|
||||
public int energy;
|
||||
public int fluid;
|
||||
|
||||
public ContainerDieselGenerator(TileDieselGenerator tiledieselGenerator,
|
||||
EntityPlayer player) {
|
||||
|
@ -42,4 +47,36 @@ public class ContainerDieselGenerator extends TechRebornContainer {
|
|||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < this.crafters.size(); i++) {
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get(i);
|
||||
if (this.energy != (int) tiledieselGenerator.getEnergy()) {
|
||||
icrafting.sendProgressBarUpdate(this, 0, (int) tiledieselGenerator.getEnergy());
|
||||
}
|
||||
if (this.fluid != tiledieselGenerator.tank.getFluidAmount()) {
|
||||
icrafting.sendProgressBarUpdate(this, 1, tiledieselGenerator.tank.getFluidAmount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting crafting) {
|
||||
super.addCraftingToCrafters(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 0, (int) tiledieselGenerator.getEnergy());
|
||||
crafting.sendProgressBarUpdate(this, 1, tiledieselGenerator.tank.getFluidAmount());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int id, int value) {
|
||||
if (id == 0) {
|
||||
this.energy = value;
|
||||
}else
|
||||
if (id == 1) {
|
||||
this.fluid = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import techreborn.client.container.ContainerAssemblingMachine;
|
||||
import techreborn.tiles.TileAssemblingMachine;
|
||||
|
||||
public class GuiAssemblingMachine extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/assembling_machine.png");
|
||||
|
||||
TileAssemblingMachine assemblingmachine;
|
||||
ContainerAssemblingMachine containerAssemblingMachine;
|
||||
|
||||
public GuiAssemblingMachine(EntityPlayer player, TileAssemblingMachine tileassemblinmachine) {
|
||||
super(new ContainerAssemblingMachine(tileassemblinmachine, player));
|
||||
containerAssemblingMachine = (ContainerAssemblingMachine) this.inventorySlots;
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
assemblingmachine = tileassemblinmachine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
this.mc.getTextureManager().bindTexture(texture);
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
int j = 0;
|
||||
|
||||
j = assemblingmachine.getProgressScaled(20);
|
||||
if (j > 0) {
|
||||
this.drawTexturedModalRect(k + 86, l + 34, 176, 14, j + 1, 16);
|
||||
}
|
||||
|
||||
j = assemblingmachine.getEnergyScaled(12);
|
||||
if (j > 0) {
|
||||
this.drawTexturedModalRect(k + 56, l + 36 + 12 - j, 176, 12 - j, 14, j + 2);
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
|
||||
String name = StatCollector.translateToLocal("tile.techreborn.assemblinmachine.name");
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
}
|
|
@ -15,11 +15,14 @@ public class GuiDieselGenerator extends GuiContainer {
|
|||
|
||||
TileDieselGenerator tile;
|
||||
|
||||
ContainerDieselGenerator containerDieselGenerator;
|
||||
|
||||
public GuiDieselGenerator(EntityPlayer player, TileDieselGenerator tile) {
|
||||
super(new ContainerDieselGenerator(tile, player));
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
this.tile = tile;
|
||||
containerDieselGenerator = (ContainerDieselGenerator) this.inventorySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,7 +42,11 @@ public class GuiDieselGenerator extends GuiContainer {
|
|||
I18n.format("container.inventory", new Object[0]), 8,
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
this.fontRendererObj.drawString("Liquid Amount", 10, 20, 16448255);
|
||||
this.fontRendererObj.drawString(tile.tank.getFluidAmount() + "", 10,
|
||||
this.fontRendererObj.drawString(containerDieselGenerator.fluid + "", 10,
|
||||
30, 16448255);
|
||||
|
||||
this.fontRendererObj.drawString("EU Amount", 10, 40, 16448255);
|
||||
this.fontRendererObj.drawString(containerDieselGenerator.energy + "", 10,
|
||||
50, 16448255);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
package techreborn.compat.minetweaker;
|
||||
|
||||
import minetweaker.IUndoableAction;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.api.item.IIngredient;
|
||||
import minetweaker.api.item.IItemStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
import techreborn.api.recipe.IBaseRecipeType;
|
||||
import techreborn.api.recipe.RecipeHandler;
|
||||
import techreborn.api.recipe.machines.AssemblingMachineRecipe;
|
||||
import techreborn.lib.Reference;
|
||||
import techreborn.util.ItemUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ZenClass("mods.techreborn.assemblingMachine")
|
||||
public class MTAssemblingMachine {
|
||||
|
||||
@ZenMethod
|
||||
public static void addRecipe(IItemStack output, IIngredient input1, IIngredient input2, int ticktime, int euTick) {
|
||||
ItemStack oInput1 = (ItemStack) MinetweakerCompat.toObject(input1);
|
||||
ItemStack oInput2 = (ItemStack) MinetweakerCompat.toObject(input2);
|
||||
|
||||
AssemblingMachineRecipe r = new AssemblingMachineRecipe(oInput1, oInput2, MinetweakerCompat.toStack(output), ticktime, euTick);
|
||||
|
||||
MineTweakerAPI.apply(new Add(r));
|
||||
}
|
||||
|
||||
private static class Add implements IUndoableAction {
|
||||
private final AssemblingMachineRecipe recipe;
|
||||
|
||||
public Add(AssemblingMachineRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
RecipeHandler.addRecipe(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUndo() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo() {
|
||||
RecipeHandler.recipeList.remove(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Adding Assembling Machine Recipe for " + recipe.getOutput(0).getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describeUndo() {
|
||||
return "Removing Assembling Machine Recipe for " + recipe.getOutput(0).getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getOverrideKey() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IItemStack output)
|
||||
{
|
||||
MineTweakerAPI.apply(new Remove(MinetweakerCompat.toStack(output)));
|
||||
}
|
||||
private static class Remove implements IUndoableAction
|
||||
{
|
||||
private final ItemStack output;
|
||||
List<AssemblingMachineRecipe> removedRecipes = new ArrayList<AssemblingMachineRecipe>();
|
||||
public Remove(ItemStack output)
|
||||
{
|
||||
this.output = output;
|
||||
}
|
||||
@Override
|
||||
public void apply()
|
||||
{
|
||||
for(IBaseRecipeType recipeType : RecipeHandler.getRecipeClassFromName(Reference.assemblingMachineRecipe)){
|
||||
for(ItemStack stack : recipeType.getOutputs()){
|
||||
if(ItemUtils.isItemEqual(stack, output, true, false)){
|
||||
removedRecipes.add((AssemblingMachineRecipe) recipeType);
|
||||
RecipeHandler.recipeList.remove(recipeType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void undo()
|
||||
{
|
||||
if(removedRecipes!=null){
|
||||
for(AssemblingMachineRecipe recipe : removedRecipes){
|
||||
if(recipe!=null){
|
||||
RecipeHandler.addRecipe(recipe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public String describe()
|
||||
{
|
||||
return "Removing Assembling Machine Recipe for " + output.getDisplayName();
|
||||
}
|
||||
@Override
|
||||
public String describeUndo()
|
||||
{
|
||||
return "Re-Adding Assembling Machine Recipe for " + output.getDisplayName();
|
||||
}
|
||||
@Override
|
||||
public Object getOverrideKey()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean canUndo()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,6 +33,7 @@ public class MinetweakerCompat implements ICompatModule {
|
|||
@Override
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
MineTweakerAPI.registerClass(MTAlloySmelter.class);
|
||||
MineTweakerAPI.registerClass(MTAssemblingMachine.class);
|
||||
MineTweakerAPI.registerClass(MTBlastFurnace.class);
|
||||
MineTweakerAPI.registerClass(MTCentrifuge.class);
|
||||
MineTweakerAPI.registerClass(MTChemicalReactor.class);
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package techreborn.compat.nei.recipes;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import techreborn.api.recipe.IBaseRecipeType;
|
||||
import techreborn.client.gui.GuiAssemblingMachine;
|
||||
import techreborn.lib.Reference;
|
||||
import techreborn.util.ItemUtils;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
public class AssemblingMachineRecipeHandler extends GenericRecipeHander implements INeiBaseRecipe {
|
||||
@Override
|
||||
public void addPositionedStacks(List<PositionedStack> input, List<PositionedStack> outputs, IBaseRecipeType recipeType) {
|
||||
int offset = 4;
|
||||
if (recipeType.getInputs().size() > 0) {
|
||||
PositionedStack pStack = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(0)), 47 - offset, 17 - offset, false);
|
||||
input.add(pStack);
|
||||
}
|
||||
if (recipeType.getInputs().size() > 1) {
|
||||
PositionedStack pStack2 = new PositionedStack(ItemUtils.getStackWithAllOre(recipeType.getInputs().get(1)), 65 - offset, 17 - offset, false);
|
||||
input.add(pStack2);
|
||||
}
|
||||
|
||||
if (recipeType.getOutputsSize() > 0) {
|
||||
PositionedStack pStack3 = new PositionedStack(recipeType.getOutput(0), 116 - offset, 35 - offset, false);
|
||||
outputs.add(pStack3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRecipeName() {
|
||||
return Reference.assemblingMachineRecipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGuiTexture() {
|
||||
return "techreborn:textures/gui/assembling_machine.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiContainer> getGuiClass() {
|
||||
return GuiAssemblingMachine.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public INeiBaseRecipe getNeiBaseRecipe() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadTransferRects() {
|
||||
this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(
|
||||
new Rectangle(80, 20, 20, 20), getNeiBaseRecipe().getRecipeName(), new Object[0]));
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ public class ModBlocks {
|
|||
public static Block HighAdvancedMachineBlock;
|
||||
public static Block Dragoneggenergysiphoner;
|
||||
public static Block Magicenergeyconverter;
|
||||
public static Block AssemblyMachine;
|
||||
public static Block DieselGenerator;
|
||||
public static Block IndustrialElectrolyzer;
|
||||
public static Block MagicalAbsorber;
|
||||
|
@ -142,10 +143,10 @@ public class ModBlocks {
|
|||
|
||||
Magicenergeyconverter = new BlockMagicEnergyConverter(Material.rock);
|
||||
GameRegistry.registerBlock(Magicenergeyconverter, "magicenergyconverter");
|
||||
//NOT NEEDED
|
||||
// AssemblyMachine = new BlockAssemblingMachine(Material.rock);
|
||||
// GameRegistry.registerBlock(AssemblyMachine, "assemblymachine");
|
||||
// GameRegistry.registerTileEntity(TileAssemblingMachine.class, "TileAssemblyMachineTR");
|
||||
|
||||
AssemblyMachine = new BlockAssemblingMachine(Material.rock);
|
||||
GameRegistry.registerBlock(AssemblyMachine, "assemblymachine");
|
||||
GameRegistry.registerTileEntity(TileAssemblingMachine.class, "TileAssemblyMachineTR");
|
||||
|
||||
DieselGenerator = new BlockDieselGenerator(Material.rock);
|
||||
GameRegistry.registerBlock(DieselGenerator, "dieselgenerator");
|
||||
|
|
|
@ -35,7 +35,7 @@ public class ItemCells extends ItemTR {
|
|||
return stack;
|
||||
}
|
||||
} else {
|
||||
LogHelper.error("Could not find " + "fluid" + name + " in the fluid registry!");
|
||||
LogHelper.debug("Could not find " + "fluid" + name + " in the fluid registry!");
|
||||
}
|
||||
}
|
||||
int index = -1;
|
||||
|
|
|
@ -227,7 +227,7 @@ public abstract class TilePowerAcceptor extends RFProviderTile implements
|
|||
double energyReceived = Math.min(getMaxPower() - energy, Math.min(this.getMaxPower(), energy));
|
||||
|
||||
if (!simulate) {
|
||||
setEnergy(energy + energyReceived);
|
||||
setEnergy(getEnergy() + energyReceived);
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
|
|
210
src/main/java/techreborn/tiles/TileAssemblingMachine.java
Normal file
210
src/main/java/techreborn/tiles/TileAssemblingMachine.java
Normal file
|
@ -0,0 +1,210 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
import ic2.api.tile.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import techreborn.api.recipe.RecipeCrafter;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.lib.Reference;
|
||||
import techreborn.powerSystem.TilePowerAcceptor;
|
||||
import techreborn.util.Inventory;
|
||||
|
||||
public class TileAssemblingMachine extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
|
||||
|
||||
public int tickTime;
|
||||
public Inventory inventory = new Inventory(8, "TileAssemblingMachine", 64);
|
||||
public RecipeCrafter crafter;
|
||||
|
||||
public TileAssemblingMachine() {
|
||||
super(2);
|
||||
//Input slots
|
||||
int[] inputs = new int[2];
|
||||
inputs[0] = 0;
|
||||
inputs[1] = 1;
|
||||
int[] outputs = new int[1];
|
||||
outputs[0] = 2;
|
||||
crafter = new RecipeCrafter(Reference.assemblingMachineRecipe, this, 2, 2, inventory, inputs, outputs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
crafter.updateEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getFacing() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFacing(short facing) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
|
||||
if (entityPlayer.isSneaking()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate() {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
|
||||
return new ItemStack(ModBlocks.AssemblyMachine, 1);
|
||||
}
|
||||
|
||||
public boolean isComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
inventory.readFromNBT(tagCompound);
|
||||
crafter.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
inventory.writeToNBT(tagCompound);
|
||||
crafter.writeToNBT(tagCompound);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inventory.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return inventory.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
return inventory.decrStackSize(slot, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
return inventory.getStackInSlotOnClosing(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory.setInventorySlotContents(slot, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return inventory.getInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return inventory.hasCustomInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return inventory.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return inventory.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
inventory.openInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
inventory.closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
return inventory.isItemValidForSlot(slot, stack);
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return side == ForgeDirection.DOWN.ordinal() ? new int[]{0, 1, 2} : new int[]{0, 1, 2};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, int side) {
|
||||
if (slotIndex == 2)
|
||||
return false;
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, int side) {
|
||||
return slotIndex == 2;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void addWailaInfo(List<String> info)
|
||||
// {
|
||||
// super.addWailaInfo(info);
|
||||
// info.add("Power Stored " + energy.getEnergyStored() +" EU");
|
||||
// if(crafter.currentRecipe !=null){
|
||||
// info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t");
|
||||
// }
|
||||
// }
|
||||
|
||||
public int getProgressScaled(int scale) {
|
||||
if (crafter.currentTickTime != 0) {
|
||||
return crafter.currentTickTime * scale / crafter.currentNeededTicks;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxPower() {
|
||||
return 10000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(ForgeDirection direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(ForgeDirection direction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxInput() {
|
||||
return 128;
|
||||
}
|
||||
}
|
|
@ -89,11 +89,13 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl
|
|||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
System.out.println("hi");
|
||||
return FluidPowerManager.fluidPowerValues.containsKey(fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
System.out.println("hi");
|
||||
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
|
||||
|
@ -149,9 +151,10 @@ public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchabl
|
|||
if (!tank.isEmpty()) {
|
||||
double powerIn = FluidPowerManager.fluidPowerValues.get(tank.getFluidType());
|
||||
if(getFreeSpace() >= powerIn){
|
||||
addEnergy(powerIn);
|
||||
addEnergy(powerIn, false);
|
||||
tank.drain(1, true);
|
||||
}
|
||||
System.out.println(getEnergy() + ":" + tank.getFluidAmount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ tile.techreborn.magicenergyconverter.name=Magic Energy Converter
|
|||
tile.techreborn.dieselgenerator.name=Diesel Generator
|
||||
tile.techreborn.industrialelectrolyzer.name=Industrial Electrolyzer
|
||||
tile.techreborn.magicenergyabsorber.name=Magic Energy Absorber
|
||||
tile.techreborn.assemblingmachine.name=Assembling Machine
|
||||
tile.techreborn.semifluidgenerator.name=Semifluid Generator
|
||||
tile.techreborn.alloyfurnace.name=Iron Alloy Furnace
|
||||
tile.techreborn.chemicalreactor.name=Chemical Reactor
|
||||
|
|
Loading…
Reference in a new issue