Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inventory System #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/java/com/gtnewhorizons/mutecore/MuTECore.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.cleanroommc.modularui.factory.GuiManager;
import com.gtnewhorizons.mutecore.api.data.Coordinates;
import com.gtnewhorizons.mutecore.api.data.GUIEvent;
import com.gtnewhorizons.mutecore.api.data.WorldStateValidator;
Expand All @@ -16,7 +17,6 @@
import com.gtnewhorizons.mutecore.api.tile.MultiTileEntity;
import com.gtnewhorizons.mutecore.api.utils.PlayerHelper;
import com.gtnewhorizons.mutecore.test.TestRegistry;
import com.cleanroommc.modularui.factory.GuiManager;

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
Expand Down Expand Up @@ -44,7 +44,9 @@ public class MuTECore {
public static final Logger LOG = LogManager.getLogger(MODID);
public static final String DEPENDENCIES = "required-after:gtnhlib@[0.2.7,);" + "required-after:modularui;"
+ "after:appliedenegistics2";
@SidedProxy(clientSide = "com.gtnewhorizons.mutecore.ClientProxy", serverSide = "com.gtnewhorizons.mutecore.CommonProxy")
@SidedProxy(
clientSide = "com.gtnewhorizons.mutecore.ClientProxy",
serverSide = "com.gtnewhorizons.mutecore.CommonProxy")
public static CommonProxy proxy;
public static Dominion ENGINE;
public static boolean ENABLE_TESTS;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/gtnewhorizons/mutecore/MuTENetwork.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

import org.jetbrains.annotations.Nullable;

import com.cleanroommc.modularui.network.IPacket;
import com.gtnewhorizons.mutecore.api.block.MultiTileEntityBlock;
import com.gtnewhorizons.mutecore.api.data.Coordinates;
import com.gtnewhorizons.mutecore.api.data.WorldStateValidator;
import com.gtnewhorizons.mutecore.api.registry.MultiTileContainer;
import com.gtnewhorizons.mutecore.api.registry.MultiTileEntityRegistry;
import com.gtnewhorizons.mutecore.api.tile.MultiTileEntity;
import com.cleanroommc.modularui.network.IPacket;

import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public static void registerSystems(Runnable... systems) {
* Register any amount of systems. The systems registered this way will be ran in parallel
*/
public static void registerSystemsParallel(Runnable... systems) {
int processors = Runtime.getRuntime().availableProcessors();
int processors = Runtime.getRuntime()
.availableProcessors();
Runnable[] parallel = new Runnable[processors];
int count = 0;
for (Runnable system : systems) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
import com.gtnewhorizons.mutecore.MuTENetwork;
import com.gtnewhorizons.mutecore.MuTENetwork.MuTEPacket;
import com.gtnewhorizons.mutecore.api.data.Coordinates;
import com.gtnewhorizons.mutecore.api.registry.EventRegistry;
import com.gtnewhorizons.mutecore.api.registry.MultiTileContainer.Id;
import com.gtnewhorizons.mutecore.api.registry.MultiTileEntityRegistry;
import com.gtnewhorizons.mutecore.api.event.BlockBreakEvent;
import com.gtnewhorizons.mutecore.api.event.BlockPlaceEvent;
import com.gtnewhorizons.mutecore.api.event.NeighborBlockChangeEvent;
import com.gtnewhorizons.mutecore.api.event.NeighborTileChangeEvent;
import com.gtnewhorizons.mutecore.api.event.PlayerInteractionEvent;
import com.gtnewhorizons.mutecore.api.registry.EventRegistry;
import com.gtnewhorizons.mutecore.api.registry.MultiTileContainer.Id;
import com.gtnewhorizons.mutecore.api.registry.MultiTileEntityRegistry;
import com.gtnewhorizons.mutecore.api.tile.MultiTileEntity;
import com.gtnewhorizons.mutecore.client.MultiTileBlockRenderer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import dev.dominion.ecs.api.Entity;

public class BlockBreakEvent implements Comparable<BlockBreakEvent>{
public class BlockBreakEvent implements Comparable<BlockBreakEvent> {

private int priority;
private BlockBreak interaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import dev.dominion.ecs.api.Entity;

public class BlockPlaceEvent implements Comparable<BlockPlaceEvent>{
public class BlockPlaceEvent implements Comparable<BlockPlaceEvent> {

private int priority;
private BlockPlace interaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import javax.annotation.Nonnull;

import dev.dominion.ecs.api.Entity;
import net.minecraft.block.Block;

public class NeighborBlockChangeEvent implements Comparable<NeighborBlockChangeEvent>{
import dev.dominion.ecs.api.Entity;

public class NeighborBlockChangeEvent implements Comparable<NeighborBlockChangeEvent> {

private int priority;
private NeighborBlockChange interaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import javax.annotation.Nonnull;

import dev.dominion.ecs.api.Entity;
import net.minecraft.tileentity.TileEntity;

public class NeighborTileChangeEvent implements Comparable<NeighborTileChangeEvent>{
import dev.dominion.ecs.api.Entity;

public class NeighborTileChangeEvent implements Comparable<NeighborTileChangeEvent> {

private int priority;
private NeighborTileChange interaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

import org.jetbrains.annotations.NotNull;

import com.gtnewhorizons.mutecore.MuTECore;
import com.cleanroommc.modularui.api.IGuiHolder;
import com.cleanroommc.modularui.factory.AbstractUIFactory;
import com.cleanroommc.modularui.factory.GuiManager;
import com.gtnewhorizons.mutecore.MuTECore;

public class MultiTileEntityGuiFactory extends AbstractUIFactory<ComponentData> {

Expand Down
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a getter for size of inventory and max contained per slot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those are maxSlots and maxPerSlot respectively, public fields so didnt think it needed getters

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.gtnewhorizons.mutecore.api.inventories;

import java.util.UUID;

public class InventoryBase {

// Config related data
public int maxPerSlot;
public int maxSlots;

// Identifiers
private UUID KEY;
public String name;

public InventoryBase(int maxPerSlot, int maxSlots) {
this.maxPerSlot = maxPerSlot;
this.maxSlots = maxSlots;
}

public UUID getKey() {
return this.KEY;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.gtnewhorizons.mutecore.api.inventories;

import com.cleanroommc.modularui.utils.fluid.FluidTankLong;
import com.gtnewhorizons.mutecore.api.data.WorldStateValidator;
import net.minecraft.nbt.NBTTagCompound;

public class InventoryFluid extends InventoryBase implements WorldStateValidator {

private FluidTankLong[] fluids;

private final String NBTTAG_KEY = "MuTEFluidInventory";

public InventoryFluid(int maxPerSlot, int maxSlots) {
super(maxPerSlot, maxSlots);
this.fluids = new FluidTankLong[maxSlots];
}

@Override
public void save(NBTTagCompound nbt) {

}

@Override
public void load(NBTTagCompound nbt) {

}

public FluidTankLong getFluid(int index) {
return this.fluids[index];
}

public void setFluid(int index, FluidTankLong fluid) {
this.fluids[index] = fluid;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.gtnewhorizons.mutecore.api.inventories;

public class InventoryInputFluid extends InventoryFluid {
public InventoryInputFluid(int maxPerSlot, int maxSlots) {
super(maxPerSlot, maxSlots);
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.gtnewhorizons.mutecore.api.inventories;

/*
* For logic
*/
public class InventoryManager {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.gtnewhorizons.mutecore.api.inventories;

public class InventoryOutputFluid extends InventoryFluid {
public InventoryOutputFluid(int maxPerSlot, int maxSlots) {
super(maxPerSlot, maxSlots);
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way that it done, input will either be overriden or override ItemOutput.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.gtnewhorizons.mutecore.api.inventories;

public class ItemInputInventory extends ItemInventory {
public ItemInputInventory(int maxPerSlot, int maxSlots) {
super(maxPerSlot, maxSlots);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.gtnewhorizons.mutecore.api.inventories;

import com.cleanroommc.modularui.utils.item.ItemStackLong;
import com.gtnewhorizons.mutecore.api.data.WorldStateValidator;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;

public class ItemInventory extends InventoryBase implements WorldStateValidator {

private ItemStackLong[] items;

private final String NBTTAG_KEY = "MuTEItemInventory";

public ItemInventory(int maxPerSlot, int maxSlots) {
super(maxPerSlot, maxSlots);
this.items = new ItemStackLong[maxSlots];
}

@Override
public void save(NBTTagCompound nbt) {
// no clue if this works, idea was to shove items under its
// own NBT compound tag for easier read when/if needed

// even less of a clue what to name these variables
NBTTagCompound inv = nbt.getCompoundTag(NBTTAG_KEY);
NBTTagList itemList = new NBTTagList();

for (ItemStackLong item : items) {
NBTTagCompound entry = new NBTTagCompound();
item.writeToNBT(entry);
itemList.appendTag(entry);
}

inv.setTag("Items", itemList);
inv.setString("UUID", this.getKey().toString());
}

@Override
public void load(NBTTagCompound nbt) {
// for (???) { items.add(ItemStackLong.loadFromNBT(???)); }
}

public ItemStackLong getItem(int index) {
return this.items[index];
}

public void setItem(int index, ItemStackLong item) {
this.items[index] = item;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.gtnewhorizons.mutecore.api.inventories;

public class ItemOutputInventory extends ItemInventory {
public ItemOutputInventory(int maxPerSlot, int maxSlots) {
super(maxPerSlot, maxSlots);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@
import javax.annotation.Nullable;

import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;

import com.gtnewhorizons.mutecore.MuTECore;
import com.gtnewhorizons.mutecore.api.data.FirstTickEvent;
import com.gtnewhorizons.mutecore.api.data.TickData;
import com.gtnewhorizons.mutecore.api.data.WorldStateValidator;
import com.gtnewhorizons.mutecore.api.gui.MuTEGUI;
import com.gtnewhorizons.mutecore.api.render.MuTERender;
import com.gtnewhorizons.mutecore.api.tile.MultiTileEntity;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dev.dominion.ecs.api.Entity;

public class MultiTileContainer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@

import org.jetbrains.annotations.ApiStatus.Internal;

import com.cleanroommc.modularui.utils.item.ItemStackLong;
import com.google.common.primitives.Ints;
import com.gtnewhorizons.mutecore.MuTECore;
import com.gtnewhorizons.mutecore.api.block.MultiTileEntityBlock;
import com.gtnewhorizons.mutecore.api.render.MuTERender;
import com.gtnewhorizons.mutecore.api.tile.MultiTileEntity;

import com.cleanroommc.modularui.utils.item.ItemStackLong;
import com.google.common.primitives.Ints;

import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.gtnewhorizons.mutecore.api.render;

import com.gtnewhorizons.mutecore.api.registry.TextureRegistry;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;

import com.gtnewhorizons.mutecore.api.registry.TextureRegistry;

public class MuTEIcon implements IIcon {

private String iconPath;
private IIcon icon;


public MuTEIcon(String modid, String path) {
this(new ResourceLocation(modid, path).toString());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.gtnewhorizons.mutecore.api.render;

import dev.dominion.ecs.api.Entity;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.IBlockAccess;

import dev.dominion.ecs.api.Entity;

public interface MuTERender {

void render(Entity entity, RenderBlocks render, int x, int y, int z, IBlockAccess world);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

import org.jetbrains.annotations.ApiStatus.Internal;

import com.cleanroommc.modularui.api.IGuiHolder;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.value.sync.GuiSyncManager;
import com.gtnewhorizons.mutecore.MuTECore;
import com.gtnewhorizons.mutecore.MuTENetwork;
import com.gtnewhorizons.mutecore.MuTENetwork.MuTEPacket;
Expand All @@ -17,9 +20,6 @@
import com.gtnewhorizons.mutecore.api.registry.MultiTileContainer;
import com.gtnewhorizons.mutecore.api.registry.MultiTileContainer.Id;
import com.gtnewhorizons.mutecore.api.registry.MultiTileEntityRegistry;
import com.cleanroommc.modularui.api.IGuiHolder;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.value.sync.GuiSyncManager;

import dev.dominion.ecs.api.Entity;
import dev.dominion.ecs.engine.IntEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;

import com.gtnewhorizons.mutecore.api.block.MultiTileEntityBlock;
import com.gtnewhorizons.mutecore.api.registry.MultiTileContainer;
import com.gtnewhorizons.mutecore.api.registry.MultiTileEntityRegistry;
import com.gtnewhorizons.mutecore.api.registry.MultiTileContainer.Id;
import com.gtnewhorizons.mutecore.api.registry.MultiTileEntityRegistry;
import com.gtnewhorizons.mutecore.api.tile.MultiTileEntity;

import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
Expand Down Expand Up @@ -42,7 +40,10 @@ public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b

Entity entity = mute.getEntity();
MultiTileEntityRegistry reg = mublock.getRegistry();
reg.getRender(entity.get(Id.class).getId()).render(entity, renderer, x, y, z, world);
reg.getRender(
entity.get(Id.class)
.getId())
.render(entity, renderer, x, y, z, world);

return true;
}
Expand Down
Loading