Skip to content

Commit

Permalink
Added backpack attachment.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSVK12 committed Feb 1, 2024
1 parent b8e0fa0 commit 93f08bd
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,17 @@
import sunsetsatellite.signalindustries.interfaces.mixins.IKeybinds;
import sunsetsatellite.signalindustries.inventories.*;
import sunsetsatellite.signalindustries.inventories.base.TileEntityWithName;
import sunsetsatellite.signalindustries.inventories.item.InventoryBackpack;
import sunsetsatellite.signalindustries.inventories.item.InventoryHarness;
import sunsetsatellite.signalindustries.inventories.item.InventoryPulsar;
import sunsetsatellite.signalindustries.inventories.machines.*;
import sunsetsatellite.signalindustries.items.*;
import sunsetsatellite.signalindustries.items.abilities.ItemWithAbility;
import sunsetsatellite.signalindustries.items.attachments.ItemAttachment;
import sunsetsatellite.signalindustries.items.attachments.ItemWingsAttachment;
import sunsetsatellite.signalindustries.items.attachments.*;
import sunsetsatellite.signalindustries.items.containers.ItemFuelCell;
import sunsetsatellite.signalindustries.items.containers.ItemSignalumCrystal;
import sunsetsatellite.signalindustries.items.containers.ItemSignalumDrill;
import sunsetsatellite.signalindustries.items.containers.ItemSignalumSaber;
import sunsetsatellite.signalindustries.items.attachments.ItemPulsarAttachment;
import sunsetsatellite.signalindustries.items.attachments.ItemTieredAttachment;
import sunsetsatellite.signalindustries.misc.SignalIndustriesAchievementPage;
import sunsetsatellite.signalindustries.powersuit.GuiPowerSuit;
import sunsetsatellite.signalindustries.render.*;
Expand Down Expand Up @@ -781,7 +779,10 @@ public class SignalIndustries implements ModInitializer, GameStartEntrypoint {
//public static final Item testingAttachment = ItemHelper.createItem(MOD_ID,new ItemAttachment(config.getInt("ItemIDs.testingAttachment"), listOf(AttachmentPoint.ANY)),"attachment.testingAttachment","energyorb.png");
public static final Item pulsarAttachment = ItemHelper.createItem(MOD_ID,new ItemPulsarAttachment("reinforced.attachment.pulsar",config.getInt("ItemIDs.pulsarAttachment"), listOf(AttachmentPoint.ARM_FRONT), Tier.REINFORCED),"pulsar_attachment.png").setMaxStackSize(1);
public static final Item extendedEnergyPack = ItemHelper.createItem(MOD_ID,new ItemTieredAttachment("reinforced.attachment.extendedEnergyPack",config.getInt("ItemIDs.extendedEnergyPack"), listOf(AttachmentPoint.CORE_BACK), Tier.REINFORCED),"extended_energy_pack.png").setMaxStackSize(1);
public static final Item crystalWings = ItemHelper.createItem(MOD_ID,new ItemWingsAttachment("reinforced.attachment.wings",config.getInt("ItemIDs.crystalWings"), listOf(AttachmentPoint.CORE_BACK), Tier.REINFORCED),"wings.png").setMaxStackSize(1);
public static final Item crystalWings = ItemHelper.createItem(MOD_ID,new ItemWingsAttachment("reinforced.attachment.wings",config.getInt("ItemIDs.crystalWings"), listOf(AttachmentPoint.CORE_BACK), Tier.REINFORCED),"wings.png").setMaxStackSize(1);
public static final Item basicBackpack = ItemHelper.createItem(MOD_ID,new ItemBackpackAttachment("basic.attachment.backpack",config.getInt("ItemIDs.basicBackpack"), listOf(AttachmentPoint.CORE_BACK), Tier.BASIC),"basic_backpack.png").setMaxStackSize(1);
public static final Item reinforcedBackpack = ItemHelper.createItem(MOD_ID,new ItemBackpackAttachment("reinforced.attachment.backpack",config.getInt("ItemIDs.reinforcedBackpack"), listOf(AttachmentPoint.CORE_BACK), Tier.REINFORCED),"reinforced_backpack.png").setMaxStackSize(1);;


public static final SuitBaseAbility testAbility = new TestingAbility();
public static final SuitBaseEffectAbility testEffectAbility = new TestingEffectAbility();
Expand Down Expand Up @@ -1019,6 +1020,7 @@ public SignalIndustries(){

addToNameGuiMap("The Pulsar", GuiPulsar.class, InventoryPulsar.class);
addToNameGuiMap("Signalum Prototype Harness", GuiHarness.class, InventoryHarness.class);
addToNameGuiMap("Backpack", GuiBackpack.class, InventoryBackpack.class);

EntityHelper.Core.createTileEntity(TileEntityRecipeMaker.class,"Recipe Maker");
EntityHelper.Core.createTileEntity(TileEntityWrathBeacon.class,"Wrath Beacon");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package sunsetsatellite.signalindustries.containers;

import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.player.inventory.IInventory;
import net.minecraft.core.player.inventory.InventoryPlayer;
import net.minecraft.core.player.inventory.slot.Slot;
import sunsetsatellite.catalyst.fluids.impl.ContainerItemFluid;
import sunsetsatellite.catalyst.fluids.impl.ItemInventoryFluid;
import sunsetsatellite.catalyst.fluids.util.FluidStack;
import sunsetsatellite.catalyst.fluids.util.SlotFluid;
import sunsetsatellite.signalindustries.inventories.item.InventoryBackpack;
import sunsetsatellite.signalindustries.inventories.item.InventoryPulsar;
import sunsetsatellite.signalindustries.items.ItemPulsar;
import sunsetsatellite.signalindustries.items.attachments.ItemBackpackAttachment;
import sunsetsatellite.signalindustries.util.NBTHelper;
import sunsetsatellite.signalindustries.util.SlotBackpack;

public class ContainerBackpack extends ContainerItemFluid {
ItemStack backpack;

public ContainerBackpack(InventoryPlayer inventoryPlayer, ItemStack backpack){
super(inventoryPlayer,new InventoryBackpack(backpack));
this.backpack = backpack;

if(backpack.getItem() instanceof ItemBackpackAttachment){
NBTHelper.loadInvFromNBT(backpack,inv,27*2,4);
}

for (int y = 0; y < 4; y++) {
addFluidSlot(new SlotFluid(inv,y,174,36 + 18 * y));
}

int numberOfRows = (27 * 2) / 9;
int i = (numberOfRows - 4) * 18;
for (int j = 0; j < numberOfRows; j++) {
for (int i1 = 0; i1 < 9; i1++) {
addSlot(new SlotBackpack(inv, i1 + j * 9, 8 + i1 * 18, 18 + j * 18));
}

}

for (int k = 0; k < 3; k++) {
for (int j1 = 0; j1 < 9; j1++) {
addSlot(new Slot(inventoryPlayer, j1 + k * 9 + 9, 8 + j1 * 18, 103 + k * 18 + i));
}

}

for (int l = 0; l < 9; l++) {
addSlot(new Slot(inventoryPlayer, l, 8 + l * 18, 161 + i));
}
}

@Override
public FluidStack clickFluidSlot(int slotID, int button, boolean shift, boolean control, EntityPlayer entityplayer) {
return super.clickFluidSlot(slotID, button, shift, control, entityplayer);
}

@Override
public boolean isUsableByPlayer(EntityPlayer entityPlayer) {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package sunsetsatellite.signalindustries.gui;


import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.player.inventory.InventoryPlayer;
import org.lwjgl.opengl.GL11;
import sunsetsatellite.catalyst.fluids.impl.GuiItemFluid;
import sunsetsatellite.signalindustries.containers.ContainerBackpack;
import sunsetsatellite.signalindustries.containers.ContainerPulsar;
import sunsetsatellite.signalindustries.items.ItemPulsar;
import sunsetsatellite.signalindustries.items.attachments.ItemBackpackAttachment;
import sunsetsatellite.signalindustries.util.NBTHelper;

public class GuiBackpack extends GuiItemFluid {

ItemStack backpack;
EntityPlayer player;
public GuiBackpack(InventoryPlayer inventoryPlayer, ItemStack backpack) {
super(new ContainerBackpack(inventoryPlayer,backpack),inventoryPlayer);
this.backpack = backpack;
this.player = inventoryPlayer.player;
ySize = 223;
xSize = 198;
}

protected void drawGuiContainerBackgroundLayer(float f)
{
int i = mc.renderEngine.getTexture("assets/signalindustries/gui/reinforced_backpack.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(i);
int j = (width - xSize) / 2;
int k = (height - ySize) / 2;
drawTexturedModalRect(j, k, 0, 0, xSize, ySize);

}

protected void drawGuiContainerForegroundLayer()
{
super.drawGuiContainerForegroundLayer();
fontRenderer.drawCenteredString("Reinforced Backpack", 90, 6, 0xFFCC0000);
}

@Override
public void onClosed() {
if(backpack.getItem() instanceof ItemBackpackAttachment){
NBTHelper.saveInvToNBT(backpack,((ContainerBackpack)inventorySlots).inv);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package sunsetsatellite.signalindustries.inventories.item;

import net.minecraft.core.block.BlockFluid;
import net.minecraft.core.item.ItemStack;
import sunsetsatellite.catalyst.CatalystFluids;
import sunsetsatellite.catalyst.fluids.impl.ItemInventoryFluid;
import sunsetsatellite.catalyst.fluids.util.FluidStack;
import sunsetsatellite.signalindustries.SignalIndustries;

import java.util.ArrayList;
import java.util.Arrays;


public class InventoryBackpack extends ItemInventoryFluid {

private final ItemStack backpack;

public InventoryBackpack(ItemStack backpack) {
super(backpack);
this.backpack = backpack;
contents = new ItemStack[27 * 2];
fluidContents = new FluidStack[4];
fluidCapacity = new int[4];
Arrays.fill(fluidCapacity,4000);
acceptedFluids.clear();
for (FluidStack ignored : fluidContents) {
acceptedFluids.add(new ArrayList<>());
}
for (BlockFluid fluid : CatalystFluids.FLUIDS.getAllFluids()) {
if(fluid != SignalIndustries.energyFlowing) {
acceptedFluids.get(0).add(fluid);
}
}
}

public String getInvName() {
return "The Pulsar";
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package sunsetsatellite.signalindustries.items.attachments;

import net.minecraft.core.entity.player.EntityPlayer;
import net.minecraft.core.item.ItemStack;
import net.minecraft.core.util.helper.Side;
import net.minecraft.core.world.World;
import sunsetsatellite.signalindustries.SignalIndustries;
import sunsetsatellite.signalindustries.containers.ContainerBackpack;
import sunsetsatellite.signalindustries.containers.ContainerPulsar;
import sunsetsatellite.signalindustries.gui.GuiBackpack;
import sunsetsatellite.signalindustries.gui.GuiPulsar;
import sunsetsatellite.signalindustries.inventories.item.InventoryBackpack;
import sunsetsatellite.signalindustries.inventories.item.InventoryPulsar;
import sunsetsatellite.signalindustries.powersuit.SignalumPowerSuit;
import sunsetsatellite.signalindustries.util.AttachmentPoint;
import sunsetsatellite.signalindustries.util.Tier;

import java.util.List;

public class ItemBackpackAttachment extends ItemTieredAttachment{

public ItemBackpackAttachment(String name, int id, List<AttachmentPoint> attachmentPoints, Tier tier) {
super(name, id, attachmentPoints, tier);
}

@Override
public void activate(ItemStack stack, SignalumPowerSuit signalumPowerSuit, EntityPlayer entityplayer, World world) {
SignalIndustries.displayGui(entityplayer,new GuiBackpack(entityplayer.inventory,stack),new ContainerBackpack(entityplayer.inventory,stack),new InventoryBackpack(stack),stack);
}

@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int blockX, int blockY, int blockZ, Side side, double xPlaced, double yPlaced) {
SignalIndustries.displayGui(entityplayer,new GuiBackpack(entityplayer.inventory,entityplayer.inventory.getCurrentItem()),new ContainerBackpack(entityplayer.inventory,entityplayer.inventory.getCurrentItem()),new InventoryBackpack(entityplayer.inventory.getCurrentItem()),itemstack);
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package sunsetsatellite.signalindustries.util;

import net.minecraft.core.item.ItemStack;
import net.minecraft.core.player.inventory.IInventory;
import net.minecraft.core.player.inventory.slot.Slot;
import sunsetsatellite.signalindustries.SignalIndustries;
import sunsetsatellite.signalindustries.inventories.item.InventoryBackpack;
import sunsetsatellite.signalindustries.items.attachments.ItemBackpackAttachment;

public class SlotBackpack extends Slot {
public SlotBackpack(IInventory inventory, int id, int x, int y) {
super(inventory, id, x, y);
}

@Override
public boolean canPutStackInSlot(ItemStack itemstack) {
if(itemstack.getItem() instanceof ItemBackpackAttachment){
return false;
}
return super.canPutStackInSlot(itemstack);
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 93f08bd

Please sign in to comment.