This commit is contained in:
oitsjustjose 2015-12-09 10:42:21 -06:00
commit 08f79f8f51
24 changed files with 372 additions and 18 deletions

View file

@ -0,0 +1,103 @@
package com.oitsjustjose.criss_cross.container;
import com.oitsjustjose.criss_cross.lib.LibItems;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerPouch extends Container
{
private EntityPlayer player = null;
private int currentFilter = -1;
private ItemStack itemStack;
public ContainerPouch(EntityPlayer player, int invId)
{
this.player = player;
this.currentFilter = invId;
int i = 36;
for (int j = 0; j < 6; j++)
{
for (int k = 0; k < 9; k++)
{
addSlotToContainer(new PouchSlot(player.inventory, k + j * 9, 8 + k * 18, 18 + j * 18, this.currentFilter));
}
}
for (int j = 0; j < 3; j++)
{
for (int k = 0; k < 9; k++)
{
addSlotToContainer(new Slot(player.inventory, k + j * 9 + 9, 8 + k * 18, 104 + j * 18 + i));
}
}
for (int j = 0; j < 9; j++)
{
if (j == this.currentFilter)
{
addSlotToContainer(new PouchLockedSlot(player.inventory, j, 8 + j * 18, 162 + i));
}
else
{
addSlotToContainer(new Slot(player.inventory, j, 8 + j * 18, 162 + i));
}
}
}
protected void retrySlotClick(int par1, int par2, boolean par3, EntityPlayer par4EntityPlayer)
{
}
public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer)
{
if ((par3 == 2) && (par2 == this.currentFilter))
{
return null;
}
ItemStack filter = this.player.inventory.getStackInSlot(this.currentFilter);
if ((filter == null) || (filter.getItem() != LibItems.pouch))
{
return null;
}
return super.slotClick(par1, par2, par3, par4EntityPlayer);
}
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
{
ItemStack itemstack = null;
Slot slot = (Slot) this.inventorySlots.get(par2);
if ((slot != null) && (slot.getHasStack()))
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (par2 < 54)
{
if (!mergeItemStack(itemstack1, 54, this.inventorySlots.size(), true))
{
return null;
}
}
else if (!mergeItemStack(itemstack1, 0, 54, false))
{
return null;
}
if (itemstack1.stackSize == 0)
{
slot.putStack(null);
return null;
}
slot.onSlotChanged();
}
return itemstack;
}
public boolean canInteractWith(EntityPlayer entityplayer)
{
ItemStack filter = this.player.inventory.getStackInSlot(this.currentFilter);
return (filter != null) && (filter.getItem() == LibItems.pouch);
}
}

View file

@ -0,0 +1,24 @@
package com.oitsjustjose.criss_cross.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class PouchLockedSlot extends Slot
{
public PouchLockedSlot(IInventory par1iInventory, int par2, int par3, int par4)
{
super(par1iInventory, par2, par3, par4);
}
public boolean isItemValid(ItemStack par1ItemStack)
{
return false;
}
public boolean canTakeStack(EntityPlayer par1EntityPlayer)
{
return false;
}
}

View file

@ -0,0 +1,134 @@
package com.oitsjustjose.criss_cross.container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class PouchSlot extends Slot
{
static boolean checking = false;
static boolean iterating = false;
private static IInventory fakeInv = new InventoryBasic("fakeInventory", true, 54);
int filterIndex = -1;
ItemStack curStack = null;
private IInventory filterInv;
public PouchSlot(IInventory par1iInventory, int slot, int x, int y, int filterIndex)
{
super(fakeInv, slot, x, y);
this.filterInv = par1iInventory;
this.filterIndex = filterIndex;
}
public ItemStack getStack()
{
ItemStack filter = this.filterInv.getStackInSlot(this.filterIndex);
if ((filter != null) && (filter.getTagCompound() != null) && (filter.getTagCompound().hasKey("items_" + getSlotIndex())))
{
if (!checking)
{
this.curStack = ItemStack.loadItemStackFromNBT(filter.getTagCompound().getCompoundTag("items_" + getSlotIndex()));
return this.curStack;
}
return ItemStack.loadItemStackFromNBT(filter.getTagCompound().getCompoundTag("items_" + getSlotIndex()));
}
if (!checking)
{
this.curStack = null;
return null;
}
return null;
}
public ItemStack decrStackSize(int par1)
{
ItemStack curItem = getStack();
if (curItem != null)
{
if (curItem.stackSize <= par1)
{
ItemStack itemstack = curItem;
putStack(null);
return itemstack;
}
ItemStack itemstack = curItem.splitStack(par1);
if (curItem.stackSize == 0)
{
putStack(null);
}
return itemstack;
}
return null;
}
public boolean getHasStack()
{
return getStack() != null;
}
public void putStack(ItemStack par1ItemStack)
{
ItemStack filter = this.filterInv.getStackInSlot(this.filterIndex);
if (filter == null)
{
return;
}
NBTTagCompound tags = filter.getTagCompound();
if (par1ItemStack != null)
{
if (tags == null)
{
tags = new NBTTagCompound();
}
if (tags.hasKey("items_" + getSlotIndex()))
{
tags.removeTag("items_" + getSlotIndex());
}
NBTTagCompound itemTags = new NBTTagCompound();
par1ItemStack.writeToNBT(itemTags);
tags.setTag("items_" + getSlotIndex(), itemTags);
filter.setTagCompound(tags);
}
else if (tags != null)
{
tags.removeTag("items_" + getSlotIndex());
if (tags.hasNoTags())
{
filter.setTagCompound(null);
}
else
{
filter.setTagCompound(tags);
}
}
if (par1ItemStack != null)
{
this.curStack = par1ItemStack;
}
else
{
this.curStack = null;
}
if (!iterating)
{
onSlotChanged();
}
}
public void onSlotChanged()
{
checking = true;
ItemStack oldItem = getStack();
checking = false;
boolean flag = false;
if (!ItemStack.areItemStacksEqual(oldItem, this.curStack))
{
iterating = true;
putStack(this.curStack);
iterating = false;
}
this.filterInv.markDirty();
}
}

View file

@ -3,16 +3,18 @@ package com.oitsjustjose.criss_cross.gui;
import com.oitsjustjose.criss_cross.container.ContainerCobblegen;
import com.oitsjustjose.criss_cross.container.ContainerCropomator;
import com.oitsjustjose.criss_cross.container.ContainerElectroextractor;
import com.oitsjustjose.criss_cross.container.ContainerPouch;
import com.oitsjustjose.criss_cross.container.ContainerStonegen;
import com.oitsjustjose.criss_cross.container.ContainerWoodchipper;
import com.oitsjustjose.criss_cross.items.ItemPouch;
import com.oitsjustjose.criss_cross.tileentity.TileCobblegen;
import com.oitsjustjose.criss_cross.tileentity.TileCropomator;
import com.oitsjustjose.criss_cross.tileentity.TileElectroextractor;
import com.oitsjustjose.criss_cross.tileentity.TileStonegen;
import com.oitsjustjose.criss_cross.tileentity.TileWoodchipper;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
@ -25,12 +27,13 @@ public class GUIHandler implements IGuiHandler
public static final int Woodchipper = 3;
public static final int Cobblegen = 4;
public static final int Stonegen = 5;
public static final int Lamp = 6;
public static final int Pouch = 6;
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
Item item = player.getHeldItem().getItem();
if (tile instanceof TileCropomator)
{
@ -62,6 +65,10 @@ public class GUIHandler implements IGuiHandler
return new ContainerStonegen(player, TE);
}
if (item instanceof ItemPouch)
{
return new ContainerPouch(player, player.inventory.currentItem);
}
return null;
}
@ -70,6 +77,7 @@ public class GUIHandler implements IGuiHandler
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity tile = world.getTileEntity(new BlockPos(x, y, z));
Item item = player.getHeldItem().getItem();
if (tile instanceof TileCropomator)
{
@ -102,6 +110,10 @@ public class GUIHandler implements IGuiHandler
return new GUIStonegen(player, TE);
}
if (item instanceof ItemPouch)
{
return new GUIPouch(player, player.inventory.currentItem);
}
return null;
}

View file

@ -0,0 +1,46 @@
package com.oitsjustjose.criss_cross.gui;
import org.lwjgl.opengl.GL11;
import com.oitsjustjose.criss_cross.container.ContainerPouch;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GUIPouch extends GuiContainer
{
private static final ResourceLocation texture = new ResourceLocation("textures/gui/container/generic_54.png");
private EntityPlayer player;
private int currentFilter = -1;
private String name;
public GUIPouch(EntityPlayer player, int currentFilter)
{
super(new ContainerPouch(player, currentFilter));
this.name = player.getHeldItem().getDisplayName();
this.currentFilter = currentFilter;
this.player = player;
this.xSize = 176;
this.ySize = 222;
}
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
this.fontRendererObj.drawString(name, 7, 9, 4210752);
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 7, this.ySize - 92, 4210752);
}
protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
}
}

View file

@ -14,8 +14,8 @@ public class ItemInfiniApple extends Item
{
this.setMaxStackSize(1);
this.setCreativeTab(CrissCross.CCTab);
this.setUnlocalizedName(Lib.modid + ".infiniApple");
GameRegistry.registerItem(this, "infiniApple");
this.setUnlocalizedName(Lib.modid + ".infini_apple");
GameRegistry.registerItem(this, this.getUnlocalizedName());
MinecraftForge.EVENT_BUS.register(new InfiniAppleEvent());
Lib.add(this);
}

View file

@ -21,7 +21,7 @@ public class ItemMantleSmasher extends ItemPickaxe
public ItemMantleSmasher(ToolMaterial material)
{
super(material);
this.setUnlocalizedName(Lib.modid + ".mantleSmasher_" + material.name());
this.setUnlocalizedName(Lib.modid + ".mantle_smasher_" + material.name());
this.setCreativeTab(CrissCross.CCTab);
MinecraftForge.EVENT_BUS.register(new ToolEfficiencyEvent());
GameRegistry.registerItem(this, this.getUnlocalizedName());

View file

@ -23,7 +23,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class ItemModBuckets extends Item
{
String[] types = new String[] { "everfulBucket", "voidBucket" };
String[] types = new String[] { "everful_bucket", "void_bucket" };
public ItemModBuckets()
{
@ -31,7 +31,7 @@ public class ItemModBuckets extends Item
this.maxStackSize = 1;
this.setCreativeTab(CrissCross.CCTab);
this.setContainerItem(this);
GameRegistry.registerItem(this, "magicBucket");
GameRegistry.registerItem(this, "special_bucket");
Lib.add(this);
}

View file

@ -0,0 +1,31 @@
package com.oitsjustjose.criss_cross.items;
import com.oitsjustjose.criss_cross.CrissCross;
import com.oitsjustjose.criss_cross.gui.GUIHandler;
import com.oitsjustjose.criss_cross.lib.Lib;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class ItemPouch extends Item
{
public ItemPouch()
{
this.setUnlocalizedName(Lib.modid + ".pouch");
this.setCreativeTab(CrissCross.CCTab);
GameRegistry.registerItem(this, this.getUnlocalizedName());
Lib.add(this);
}
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)
{
if(!world.isRemote)
player.openGui(CrissCross.instance, GUIHandler.Pouch, world, player.inventory.currentItem, 0, 0);
return itemstack;
}
}

View file

@ -4,6 +4,7 @@ import com.oitsjustjose.criss_cross.items.ItemDust;
import com.oitsjustjose.criss_cross.items.ItemInfiniApple;
import com.oitsjustjose.criss_cross.items.ItemMantleSmasher;
import com.oitsjustjose.criss_cross.items.ItemModBuckets;
import com.oitsjustjose.criss_cross.items.ItemPouch;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
@ -16,6 +17,7 @@ public class LibItems
public static Item dusts;
public static Item buckets;
public static Item infiniApple;
public static Item pouch;
public static Item mantleSmasherMkI;
public static Item mantleSmasherMkII;
@ -31,6 +33,7 @@ public class LibItems
dusts = new ItemDust();
buckets = new ItemModBuckets();
infiniApple = new ItemInfiniApple();
pouch = new ItemPouch();
mantleSmasherMkI = new ItemMantleSmasher(mkI);
mantleSmasherMkII = new ItemMantleSmasher(mkII);
}

View file

@ -47,7 +47,7 @@ public class CCMachineRecipes
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.emerald_ore), new ItemStack(Items.emerald, electroQTY));
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.coal_ore), new ItemStack(Items.coal, electroQTY));
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.gravel), new ItemStack(Items.flint));
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.sand));
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.cobblestone, 16), new ItemStack(Blocks.sand, 16));
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.sandstone, 1, Short.MAX_VALUE), new ItemStack(Blocks.sand, 4));
ElectroextractorRecipes.getInstance().addRecipe(new ItemStack(Blocks.red_sandstone, 1, Short.MAX_VALUE), new ItemStack(Blocks.sand, 4, 1));

View file

@ -11,11 +11,12 @@ item.CrissCross.trash.name=This is a bad item, please trash it.
item.CrissCross.dustPrefix=Electrolytic
item.CrissCross.dustPostfix=Dust
#Buckets
item.CrissCross.everfulBucket.name=Everful Bucket
item.CrissCross.voidBucket.name=Insatiable Bucket
item.CrissCross.infiniApple.name=§cI§6n§ef§ai§2n§bi§3A§9p§1p§5l§de§r
item.CrissCross.mantleSmasher_mkI.name=Mantle Smasher
item.CrissCross.mantleSmasher_mkII.name=§cM§6a§en§at§2l§be§3 S§9m§1a§5s§dh§ce§6r§e M§ak§2. §bII§r
item.CrissCross.everful_bucket.name=Everful Bucket
item.CrissCross.void_bucket.name=Insatiable Bucket
item.CrissCross.infini_apple.name=§cI§6n§ef§ai§2n§bi§3A§9p§1p§5l§de§r
item.CrissCross.mantle_smasher_mkI.name=Mantle Smasher
item.CrissCross.mantle_smasher_mkII.name=§cM§6a§en§at§2l§be§3 S§9m§1a§5s§dh§ce§6r§e M§ak§2. §bII§r
item.CrissCross.pouch.name=Pouch
#Chat Color Codes for Rainbow Chat: C 6 E A 2 B 3 9 1 5 D

View file

@ -1,7 +1,7 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "crisscross:items/everfulBucket"
"layer0": "crisscross:items/everful_bucket"
},
"display": {
"thirdperson": {

View file

@ -1,7 +1,7 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "crisscross:items/infiniApple"
"layer0": "crisscross:items/infini_apple"
},
"display": {
"thirdperson": {

View file

@ -1,7 +1,7 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "crisscross:items/mantleSmasher_mkI"
"layer0": "crisscross:items/mantle_smasher_mkI"
},
"display": {
"thirdperson": {

View file

@ -1,7 +1,7 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "crisscross:items/mantleSmasher_mkII"
"layer0": "crisscross:items/mantle_smasher_mkII"
},
"display": {
"thirdperson": {

View file

@ -1,7 +1,7 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "crisscross:items/voidBucket"
"layer0": "crisscross:items/void_bucket"
},
"display": {
"thirdperson": {

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 387 B

After

Width:  |  Height:  |  Size: 387 B

Before After
Before After