Drop upgrades when machine is broken, shift right-click to add into machine.

This commit is contained in:
modmuss50 2017-04-12 18:31:26 +01:00
parent d9af8309b1
commit 1c1f540a26
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
5 changed files with 71 additions and 2 deletions

View file

@ -75,6 +75,7 @@ public class GuiSideConfig extends GuiBase {
protected void actionPerformed(GuiButton button) throws IOException {
super.actionPerformed(button);
NetworkManager.sendToServer(new PacketSyncSideConfig(slotID, button.id, tileEntity.getPos()));
Minecraft.getMinecraft().displayGuiScreen(null);
}
@Override

View file

@ -40,9 +40,11 @@ import net.minecraftforge.items.IItemHandler;
import reborncore.api.tile.IUpgrade;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.recipes.RecipeCrafter;
import reborncore.common.tile.IMachineSlotProvider;
import reborncore.common.tile.TileLegacyMachineBase;
import reborncore.common.util.InventoryHelper;
import reborncore.common.util.ItemNBTHelper;
import techreborn.Core;
import techreborn.client.TechRebornCreativeTabMisc;
import techreborn.client.container.builder.BuiltContainer;
import techreborn.client.container.builder.ContainerBuilder;
@ -102,6 +104,10 @@ public class ItemUpgrades extends ItemTRNoDestroy implements IUpgrade {
super.addInformation(stack, playerIn, tooltip, advanced);
if(stack.getItemDamage() == 4 || stack.getItemDamage() == 5){
tooltip.add("Facing: " + getFacing(stack).getName());
String text = Core.proxy.getUpgradeConfigText();
if(!text.isEmpty()){
tooltip.add(text);
}
}
}
@ -135,8 +141,31 @@ public class ItemUpgrades extends ItemTRNoDestroy implements IUpgrade {
}
}
}
} else if (machineBase instanceof IMachineSlotProvider){
IMachineSlotProvider slotProvider = (IMachineSlotProvider) machineBase;
for(Integer outSlot : slotProvider.getOuputSlots()){
ItemStack outputStack = slotProvider.getMachineInv().getStackInSlot(outSlot);
if(!outputStack.isEmpty()){
int amount = InventoryHelper.testInventoryInsertion((IInventory) tileEntity, outputStack, dir);
if(amount > 0){
InventoryHelper.insertItemIntoInventory((IInventory) tileEntity,outputStack);
slotProvider.getMachineInv().decrStackSize(outSlot, amount);
}
}
}
} else {
IInventory inventory = machineBase;
for (int outSlot = 0; outSlot < inventory.getSizeInventory(); outSlot++) {
ItemStack outputStack = inventory.getStackInSlot(outSlot);
if(!outputStack.isEmpty()){
int amount = InventoryHelper.testInventoryInsertion((IInventory) tileEntity, outputStack, dir);
if(amount > 0){
InventoryHelper.insertItemIntoInventory((IInventory) tileEntity,outputStack);
inventory.decrStackSize(outSlot, amount);
}
}
}
}
//TODO fix when crafter is null
}
} else if (stack.getItemDamage() == 5){
if(machineBase.getWorld().getTotalWorldTime() % 10 != 0){

View file

@ -26,6 +26,7 @@ package techreborn.proxies;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.DefaultStateMapper;
@ -35,7 +36,9 @@ import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry;
@ -44,6 +47,7 @@ import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import reborncore.RebornCore;
import reborncore.api.tile.IUpgradeable;
import reborncore.client.hud.StackInfoHUD;
import reborncore.client.multiblock.MultiblockRenderEvent;
import reborncore.common.blocks.BlockMachineBase;
@ -55,6 +59,7 @@ import techreborn.client.ClientMultiBlocks;
import techreborn.client.IconSupplier;
import techreborn.client.RegisterItemJsons;
import techreborn.client.StackToolTipEvent;
import techreborn.client.gui.GuiBase;
import techreborn.client.keybindings.KeyBindings;
import techreborn.client.render.ModelDynamicCell;
import techreborn.client.render.entitys.RenderNukePrimed;
@ -227,4 +232,16 @@ public class ClientProxy extends CommonProxy {
}
}
@Override
public String getUpgradeConfigText() {
if(Minecraft.getMinecraft().currentScreen instanceof GuiBase){
GuiBase base = (GuiBase) Minecraft.getMinecraft().currentScreen;
if(base.tile instanceof IUpgradeable){
if(((IUpgradeable) base.tile).canBeUpgraded()){
return TextFormatting.LIGHT_PURPLE + "Right click to configure";
}
}
}
return super.getUpgradeConfigText();
}
}

View file

@ -84,4 +84,9 @@ public class CommonProxy implements ICompatModule {
return false;
}
public String getUpgradeConfigText(){
return "";
}
}

View file

@ -26,6 +26,7 @@ package techreborn.tiles.teir1;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.util.EnumFacing;
@ -36,6 +37,7 @@ import reborncore.api.tile.IInventoryProvider;
import reborncore.common.IWrenchable;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.powerSystem.TilePowerAcceptor;
import reborncore.common.tile.IMachineSlotProvider;
import reborncore.common.util.Inventory;
import techreborn.client.container.IContainerProvider;
@ -44,7 +46,7 @@ import techreborn.client.container.builder.ContainerBuilder;
import techreborn.init.ModBlocks;
public class TileElectricFurnace extends TilePowerAcceptor
implements IWrenchable, IInventoryProvider, IContainerProvider {
implements IWrenchable, IInventoryProvider, IContainerProvider, IMachineSlotProvider {
public Inventory inventory = new Inventory(6, "TileElectricFurnace", 64, this);
public int capacity = 1000;
@ -246,4 +248,19 @@ public class TileElectricFurnace extends TilePowerAcceptor
.tile(this).slot(0, 55, 45).outputSlot(1, 101, 45).syncEnergyValue()
.syncIntegerValue(this::getBurnTime, this::setBurnTime).addInventory().create();
}
@Override
public int[] getInputSlots() {
return new int[]{input1};
}
@Override
public int[] getOuputSlots() {
return new int[]{output};
}
@Override
public IInventory getMachineInv() {
return inventory;
}
}