mirror of
https://github.com/GTNewHorizons/Gadomancy.git
synced 2026-11-20 03:59:56 +00:00
-Finished up block protector
-Added basic stuff for arcane packager
This commit is contained in:
1 parent
d4d8a360f8
commit
a31da1adef
9 files changed
+306
-9
No files matched your search
@@ -8,6 +8,7 @@ import cpw.mods.fml.common.FMLLog;
|
||||
import makeo.gadomancy.client.events.ClientTickHandler;
|
||||
import makeo.gadomancy.client.events.RenderEventHandler;
|
||||
import makeo.gadomancy.client.events.ResourceReloadListener;
|
||||
import makeo.gadomancy.client.gui.ArcanePackagerGui;
|
||||
import makeo.gadomancy.client.gui.InfusionClawGui;
|
||||
import makeo.gadomancy.client.renderers.block.BlockExtendedNodeJarRenderer;
|
||||
import makeo.gadomancy.client.renderers.block.RenderBlockStoneMachine;
|
||||
@@ -171,6 +172,8 @@ public class ClientProxy extends CommonProxy {
|
||||
//return new AdditionalGolemGui(player, (EntityGolemBase)world.getEntityByID(x));
|
||||
case 1:
|
||||
return new InfusionClawGui(player.inventory, (IInventory) world.getTileEntity(x, y, z));
|
||||
case 2:
|
||||
return new ArcanePackagerGui(player.inventory, (IInventory) world.getTileEntity(x, y, z));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package makeo.gadomancy.client.gui;
|
||||
|
||||
import makeo.gadomancy.common.containers.ContainerArcanePackager;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
/**
|
||||
* This class is part of the Gadomancy Mod
|
||||
* Gadomancy is Open Source and distributed under the
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* for more read the LICENSE file
|
||||
* <p/>
|
||||
* Created by makeo @ 14.11.2015 01:17
|
||||
*/
|
||||
public class ArcanePackagerGui extends GuiContainer {
|
||||
public ArcanePackagerGui(InventoryPlayer playerInv, IInventory inventory) {
|
||||
super(new ContainerArcanePackager(playerInv, inventory));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float mouseX, int mouseZ, int par3) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int button) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import makeo.gadomancy.client.ClientProxy;
|
||||
import makeo.gadomancy.common.containers.ContainerArcanePackager;
|
||||
import makeo.gadomancy.common.containers.ContainerInfusionClaw;
|
||||
import makeo.gadomancy.common.data.ModConfig;
|
||||
import makeo.gadomancy.common.events.EventHandlerEntity;
|
||||
@@ -114,6 +115,8 @@ public class CommonProxy implements IGuiHandler {
|
||||
return new ContainerGolem(player.inventory, ((EntityGolemBase)world.getEntityByID(x)).inventory);
|
||||
case 1:
|
||||
return new ContainerInfusionClaw(player.inventory, (IInventory) world.getTileEntity(x, y, z));
|
||||
case 2:
|
||||
return new ContainerArcanePackager(player.inventory, (IInventory) world.getTileEntity(x, y, z));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package makeo.gadomancy.common.blocks.tiles;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* This class is part of the Gadomancy Mod
|
||||
* Gadomancy is Open Source and distributed under the
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* for more read the LICENSE file
|
||||
* <p/>
|
||||
* Created by makeo @ 14.11.2015 12:22
|
||||
*/
|
||||
public class TileArcanePackager extends SynchronizedTileEntity implements IInventory {
|
||||
private ItemStack[] contents = new ItemStack[10];
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 12;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
return contents[slot];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slot, int amount) {
|
||||
if (this.contents[slot] != null) {
|
||||
ItemStack itemstack;
|
||||
|
||||
if (this.contents[slot].stackSize <= amount) {
|
||||
itemstack = this.contents[slot];
|
||||
this.contents[slot] = null;
|
||||
this.markDirty();
|
||||
return itemstack;
|
||||
} else {
|
||||
itemstack = this.contents[slot].splitStack(amount);
|
||||
if (this.contents[slot].stackSize == 0) {
|
||||
this.contents[slot] = null;
|
||||
}
|
||||
this.markDirty();
|
||||
return itemstack;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
this.contents[slot] = stack;
|
||||
if (stack != null && stack.stackSize > this.getInventoryStackLimit()) {
|
||||
stack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "blub";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slot, ItemStack stack) {
|
||||
if(slot == 0) {
|
||||
return stack.getItem() == Items.string;
|
||||
} else if(slot == 1) {
|
||||
return stack.getItem() == Items.leather;
|
||||
} else if(slot == 2) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class TileBlockProtector extends TileJarFillable {
|
||||
markDirty();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
|
||||
saturation = 15 - range;
|
||||
saturation = 16 - range;
|
||||
}
|
||||
executeDecrease = false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package makeo.gadomancy.common.containers;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
/**
|
||||
* This class is part of the Gadomancy Mod
|
||||
* Gadomancy is Open Source and distributed under the
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* for more read the LICENSE file
|
||||
* <p/>
|
||||
* Created by makeo @ 14.11.2015 18:08
|
||||
*/
|
||||
public class ContainerArcanePackager extends Container {
|
||||
public final InventoryPlayer playerInv;
|
||||
public final IInventory packagerInv;
|
||||
|
||||
public ContainerArcanePackager(InventoryPlayer playerInv, IInventory packagerInv) {
|
||||
this.playerInv = playerInv;
|
||||
this.packagerInv = packagerInv;
|
||||
|
||||
addSlotToContainer(new FilteredSlot(packagerInv, 0, 80, 32));
|
||||
bindPlayerInventory();
|
||||
}
|
||||
|
||||
protected void bindPlayerInventory() {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 9; j++) {
|
||||
addSlotToContainer(new Slot(this.playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 9; i++) {
|
||||
addSlotToContainer(new Slot(this.playerInv, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package makeo.gadomancy.common.items;
|
||||
|
||||
import makeo.gadomancy.common.Gadomancy;
|
||||
import makeo.gadomancy.common.utils.NBTHelper;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import thaumcraft.common.items.ItemLootBag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is part of the Gadomancy Mod
|
||||
* Gadomancy is Open Source and distributed under the
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* for more read the LICENSE file
|
||||
* <p/>
|
||||
* Created by makeo @ 14.11.2015 12:34
|
||||
*/
|
||||
public class ItemArcanePackage extends ItemLootBag {
|
||||
public ItemArcanePackage() {
|
||||
setCreativeTab(null);
|
||||
setUnlocalizedName("ItemLootBag");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item item, CreativeTabs tab, List list) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIconFromDamage(int damage) {
|
||||
return super.getIconFromDamage(damage >> 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
if ((stack.getItemDamage() & 1) == 1) {
|
||||
super.addInformation(stack, player, list, par4);
|
||||
} else {
|
||||
list.add(StatCollector.translateToLocal(Gadomancy.MODID + ".info.ArcanePackage"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumRarity getRarity(ItemStack stack) {
|
||||
switch (stack.getItemDamage() >> 1) {
|
||||
case 1:
|
||||
return EnumRarity.uncommon;
|
||||
case 2:
|
||||
return EnumRarity.rare;
|
||||
}
|
||||
return EnumRarity.common;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
if ((stack.getItemDamage() & 1) == 0) {
|
||||
return "item.ItemArcanePackage";
|
||||
}
|
||||
return super.getUnlocalizedName(stack);
|
||||
}
|
||||
|
||||
public void setContents(ItemStack stack, List<ItemStack> items) {
|
||||
NBTTagList stackList = new NBTTagList();
|
||||
|
||||
for (ItemStack item : items) {
|
||||
if (stack != null) {
|
||||
NBTTagCompound nbtStack = new NBTTagCompound();
|
||||
item.writeToNBT(nbtStack);
|
||||
stackList.appendTag(nbtStack);
|
||||
}
|
||||
}
|
||||
NBTHelper.getData(stack).setTag("items", stackList);
|
||||
}
|
||||
|
||||
public List<ItemStack> getContents(ItemStack stack) {
|
||||
List<ItemStack> contents = new ArrayList<ItemStack>();
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagList stackList = (NBTTagList) stack.getTagCompound().getTag("items");
|
||||
if (stackList != null) {
|
||||
for (int i = 0; i < stackList.tagCount(); ++i) {
|
||||
NBTTagCompound nbtStack = stackList.getCompoundTagAt(i);
|
||||
contents.add(ItemStack.loadItemStackFromNBT(nbtStack));
|
||||
}
|
||||
}
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (!world.isRemote) {
|
||||
List<ItemStack> contents = getContents(stack);
|
||||
for (ItemStack content : contents) {
|
||||
world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, content));
|
||||
}
|
||||
world.playSoundAtEntity(player, "thaumcraft:coins", 0.75F, 1.0F);
|
||||
}
|
||||
stack.stackSize -= 1;
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,7 @@ package makeo.gadomancy.common.registration;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import makeo.gadomancy.common.Gadomancy;
|
||||
import makeo.gadomancy.common.items.ItemCreativeNode;
|
||||
import makeo.gadomancy.common.items.ItemExtendedNodeJar;
|
||||
import makeo.gadomancy.common.items.ItemFakeGolemPlacer;
|
||||
import makeo.gadomancy.common.items.ItemFakeGolemShield;
|
||||
import makeo.gadomancy.common.items.ItemFakeModIcon;
|
||||
import makeo.gadomancy.common.items.ItemGolemCoreBreak;
|
||||
import makeo.gadomancy.common.items.ItemTransformationFocus;
|
||||
import makeo.gadomancy.common.items.*;
|
||||
import makeo.gadomancy.common.items.baubles.ItemFamiliar;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.EnumRarity;
|
||||
@@ -48,6 +42,7 @@ public class RegisteredItems {
|
||||
public static Item itemExtendedNodeJar;
|
||||
public static Item itemFamiliar;
|
||||
public static Item itemCreativeNode;
|
||||
public static Item itemPackage;
|
||||
|
||||
public static void preInit() {
|
||||
creativeTab = new CreativeTabs(Gadomancy.MODID) {
|
||||
@@ -78,6 +73,7 @@ public class RegisteredItems {
|
||||
itemExtendedNodeJar = registerItem(new ItemExtendedNodeJar());
|
||||
itemFamiliar = registerItem(new ItemFamiliar());
|
||||
itemCreativeNode = registerItem(new ItemCreativeNode());
|
||||
itemPackage = registerItem(new ItemArcanePackage());
|
||||
}
|
||||
|
||||
private static <T extends Item> T registerItem(T item, String name) {
|
||||
|
||||
Reference in new issue
Block a user