diff options
| author | Benjamin Culkin <scorpress@gmail.com> | 2024-08-24 08:16:37 -0400 |
|---|---|---|
| committer | Benjamin Culkin <scorpress@gmail.com> | 2024-08-24 08:16:37 -0400 |
| commit | 70c1354a4a96698758a88c032866288f79de6f5a (patch) | |
| tree | eca51294e84b90a4cb3230bc2c7900469e784184 /src/main/java/jp/plusplus/fbs/container | |
Diffstat (limited to 'src/main/java/jp/plusplus/fbs/container')
75 files changed, 3326 insertions, 0 deletions
diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerAlchemyCauldron.class b/src/main/java/jp/plusplus/fbs/container/ContainerAlchemyCauldron.class Binary files differnew file mode 100644 index 0000000..5ff1439 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerAlchemyCauldron.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerAlchemyCauldron.java b/src/main/java/jp/plusplus/fbs/container/ContainerAlchemyCauldron.java new file mode 100644 index 0000000..af7e083 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerAlchemyCauldron.java @@ -0,0 +1,68 @@ +package jp.plusplus.fbs.container;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import jp.plusplus.fbs.container.slot.SlotTakeOnlyWithMagicEXP;
+import jp.plusplus.fbs.tileentity.TileEntityAlchemyCauldron;
+import jp.plusplus.fbs.tileentity.TileEntityExtractingFurnace;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidStack;
+
+/**
+ * Createdby pluslus_Fon 2015/06/08.
+ */
+public class ContainerAlchemyCauldron extends Container {
+ public TileEntityAlchemyCauldron entity;
+ public EntityPlayer player;
+
+ public ContainerAlchemyCauldron(EntityPlayer player, TileEntityAlchemyCauldron tileEntity) {
+ this.entity = tileEntity;
+ this.player=player;
+
+ //inventory's inventory
+ this.addSlotToContainer(new Slot(this.entity, 0, 26, 19));
+ this.addSlotToContainer(new SlotTakeOnlyWithMagicEXP(player, this.entity, 1, 134, 39, 1));
+ this.addSlotToContainer(new Slot(this.entity, 2, 8, 19));
+
+ //player inventory
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 9; j++) {
+ this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 119 + i * 18));
+ }
+ }
+
+ //player slots
+ for (int i = 0; i < 9; i++) {
+ this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 177));
+ }
+ }
+
+ @Override
+ public void addCraftingToCrafters(ICrafting par1ICrafting) {
+ super.addCraftingToCrafters(par1ICrafting);
+ }
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityPlayer) {
+ return entity.isUseableByPlayer(entityPlayer);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void updateProgressBar(int par1, int par2) {}
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
+ ItemStack itemStack = null;
+ Slot slot = (Slot) this.inventorySlots.get(par2);
+ return itemStack;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerBasket.class b/src/main/java/jp/plusplus/fbs/container/ContainerBasket.class Binary files differnew file mode 100644 index 0000000..741d884 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerBasket.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerBasket.java b/src/main/java/jp/plusplus/fbs/container/ContainerBasket.java new file mode 100644 index 0000000..86b38f1 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerBasket.java @@ -0,0 +1,93 @@ +package jp.plusplus.fbs.container;
+
+import jp.plusplus.fbs.container.inventory.InventoryBasket;
+import jp.plusplus.fbs.container.slot.SlotInventory;
+import jp.plusplus.fbs.container.slot.SlotShowOnly;
+import jp.plusplus.fbs.item.ItemCore;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Created by plusplus_F on 2015/11/11.
+ */
+public class ContainerBasket extends Container {
+ private InventoryBasket inventory;
+
+ public ContainerBasket(InventoryPlayer inventoryPlayer) {
+ inventory = new InventoryBasket(inventoryPlayer);
+ inventory.openInventory();
+
+ for (int i = 0; i < inventory.getSizeInventory(); i++) {
+ this.addSlotToContainer(new SlotInventory(inventory, i, 8 + (i % 9) * 18, 18 + (i / 9) * 18, 3));
+ }
+
+ //player inventory
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 9; j++) {
+ ItemStack item = inventoryPlayer.getStackInSlot(j + i * 9 + 9);
+ if (item != null && item.getItem() == ItemCore.basket) {
+ this.addSlotToContainer(new SlotShowOnly(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 140 + i * 18));
+ } else {
+ this.addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 140 + i * 18));
+ }
+ }
+ }
+
+ //player slots
+ for (int i = 0; i < 9; i++) {
+ ItemStack item = inventoryPlayer.getStackInSlot(i);
+ if (item != null && item.getItem() == ItemCore.basket) {
+ this.addSlotToContainer(new SlotShowOnly(inventoryPlayer, i, 8 + i * 18, 198));
+ } else {
+ this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 198));
+ }
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer p_75145_1_) {
+ return true;
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) {
+ ItemStack itemstack = null;
+ Slot slot = (Slot) this.inventorySlots.get(p_82846_2_);
+
+ if (slot != null && slot.getHasStack()) {
+ ItemStack itemstack1 = slot.getStack();
+ itemstack = itemstack1.copy();
+
+ if(slot.getStack()==null || slot.getStack().getItem() == ItemCore.basket){
+ return null;
+ }
+ else if (p_82846_2_ < this.inventory.getSizeInventory()) {
+ if (!this.mergeItemStack(itemstack1, this.inventory.getSizeInventory(), this.inventorySlots.size(), true)) {
+ return null;
+ }
+ }
+ else if(!inventory.isItemValidForSlot(p_82846_2_, itemstack)){
+ return null;
+ }
+ else if (!this.mergeItemStack(itemstack1, 0, this.inventory.getSizeInventory(), false)) {
+ return null;
+ }
+ if (itemstack1.stackSize == 0) {
+ slot.putStack((ItemStack) null);
+ } else {
+ slot.onSlotChanged();
+ }
+ }
+
+ return itemstack;
+ }
+
+ @Override
+ public void onContainerClosed(EntityPlayer p_75134_1_) {
+ super.onContainerClosed(p_75134_1_);
+ this.inventory.closeInventory();
+ }
+}
\ No newline at end of file diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerBonfire.class b/src/main/java/jp/plusplus/fbs/container/ContainerBonfire.class Binary files differnew file mode 100644 index 0000000..3c78925 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerBonfire.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerBonfire.java b/src/main/java/jp/plusplus/fbs/container/ContainerBonfire.java new file mode 100644 index 0000000..076187a --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerBonfire.java @@ -0,0 +1,56 @@ +package jp.plusplus.fbs.container;
+
+import jp.plusplus.fbs.container.inventory.InventoryBonfire;
+import jp.plusplus.fbs.container.slot.SlotBonfire;
+import jp.plusplus.fbs.container.slot.SlotInventory;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Created by plusplus_F on 2015/10/19.
+ */
+public class ContainerBonfire extends Container {
+ public InventoryBonfire inventory;
+
+ public ContainerBonfire(int x, int y, int z, EntityPlayer player){
+ inventory=new InventoryBonfire(x,y,z,player);
+ inventory.openInventory();
+
+ addSlotToContainer(new SlotBonfire(inventory, 0, 80, 21, 0));
+ for(int i=0;i<3;i++){
+ addSlotToContainer(new SlotBonfire(inventory, i+1, 62+18*i, 43, 1));
+ }
+
+ //player's inv
+ for (int j = 0; j < 3; ++j) {
+ for (int k = 0; k < 9; ++k) {
+ this.addSlotToContainer(new SlotInventory(player.inventory, k + j * 9 + 9, 8 + k * 18, 84 + j * 18, 2));
+ }
+ }
+
+ for (int j = 0; j < 9; ++j) {
+ this.addSlotToContainer(new SlotInventory(player.inventory, j, 8 + j * 18, 142, 2));
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer p_75145_1_) {
+ return inventory.isUseableByPlayer(p_75145_1_);
+ }
+
+ @Override
+ public void onContainerClosed(EntityPlayer p_75134_1_) {
+ super.onContainerClosed(p_75134_1_);
+ this.inventory.closeInventory();
+ }
+
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) {
+ ItemStack itemstack = null;
+ return itemstack;
+ }
+
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerContract.class b/src/main/java/jp/plusplus/fbs/container/ContainerContract.class Binary files differnew file mode 100644 index 0000000..a8f98cc --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerContract.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerContract.java b/src/main/java/jp/plusplus/fbs/container/ContainerContract.java new file mode 100644 index 0000000..56a431b --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerContract.java @@ -0,0 +1,91 @@ +package jp.plusplus.fbs.container;
+
+import jp.plusplus.fbs.AchievementRegistry;
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.container.inventory.InventoryContract;
+import jp.plusplus.fbs.container.slot.SlotBonfire;
+import jp.plusplus.fbs.container.slot.SlotContract;
+import jp.plusplus.fbs.container.slot.SlotInventory;
+import jp.plusplus.fbs.container.slot.SlotTakeOnly;
+import jp.plusplus.fbs.item.ItemBookSorcery;
+import jp.plusplus.fbs.item.ItemStoneSpirit;
+import jp.plusplus.fbs.spirit.SpiritManager;
+import jp.plusplus.fbs.spirit.SpiritStatus;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Created by plusplus_F on 2015/11/14.
+ */
+public class ContainerContract extends Container {
+ public EntityPlayer player;
+ public InventoryContract inventory;
+
+ public ContainerContract(EntityPlayer player){
+ inventory=new InventoryContract(player);
+ inventory.openInventory();
+
+ for(int i=0;i<2;i++){
+ addSlotToContainer(new SlotContract(inventory, i, 26+18*i, 46, i));
+ }
+ addSlotToContainer(new SlotContract(inventory, 2, 98, 23, 2));
+ addSlotToContainer(new SlotTakeOnly(inventory, 3, 133, 40));
+
+ //player's inv
+ for (int j = 0; j < 3; ++j) {
+ for (int k = 0; k < 9; ++k) {
+ this.addSlotToContainer(new SlotInventory(player.inventory, k + j * 9 + 9, 8 + k * 18, 84 + j * 18, 2));
+ }
+ }
+
+ for (int j = 0; j < 9; ++j) {
+ this.addSlotToContainer(new SlotInventory(player.inventory, j, 8 + j * 18, 142, 2));
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer p_75145_1_) {
+ return true;
+ }
+
+ @Override
+ public void onContainerClosed(EntityPlayer p_75134_1_) {
+ super.onContainerClosed(p_75134_1_);
+ this.inventory.closeInventory();
+ }
+
+ public boolean canContract(){
+ if(inventory.itemStacks[0]==null || !SpiritManager.isTool(inventory.itemStacks[0].getItem())) return false;
+ if(inventory.itemStacks[1]==null || !(inventory.itemStacks[1].getItem() instanceof ItemStoneSpirit)) return false;
+ if(inventory.itemStacks[2]==null) return false;
+ Registry.BookData bd=Registry.GetBookDataFromItemStack(inventory.itemStacks[2]);
+ return bd!=null && bd.title.equals("fbs.contract") && ItemBookSorcery.getMagicMaxUse(inventory.itemStacks[2])>0 && inventory.itemStacks[3]==null;
+ }
+
+ public String contract(String name, EntityPlayer player){
+ if(!canContract()) return null;
+ SpiritManager.ToolEntry te=SpiritManager.getTool(inventory.itemStacks[0].getItem());
+ if(te!=null){
+ boolean m=((ItemStoneSpirit)inventory.itemStacks[1].getItem()).getSex();
+ inventory.setInventorySlotContents(3, te.getSpiritToolStack(m, SpiritManager.getRandomCharacter(m), name, player, inventory.itemStacks[0]));
+ inventory.setInventorySlotContents(0, null);
+ inventory.setInventorySlotContents(1, null);
+ ItemBookSorcery.reduceMagicMaxUse(inventory.itemStacks[2]);
+
+ if(!player.worldObj.isRemote) player.triggerAchievement(AchievementRegistry.contract);
+
+ SpiritStatus status=SpiritStatus.readFromNBT(inventory.itemStacks[3].getTagCompound());
+ SpiritManager.talk(player, status.getCharacter(), "first", inventory.itemStacks[3]);
+ return status.getCharacter();
+ }
+ return null;
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
+ ItemStack itemStack = null;
+ return itemStack;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerDummy.class b/src/main/java/jp/plusplus/fbs/container/ContainerDummy.class Binary files differnew file mode 100644 index 0000000..cdc7ba3 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerDummy.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerDummy.java b/src/main/java/jp/plusplus/fbs/container/ContainerDummy.java new file mode 100644 index 0000000..ed92fc7 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerDummy.java @@ -0,0 +1,14 @@ +package jp.plusplus.fbs.container;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+
+/**
+ * Createdby pluslus_Fon 2015/06/14.
+ */
+public class ContainerDummy extends Container {
+ @Override
+ public boolean canInteractWith(EntityPlayer entityPlayer) {
+ return false;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerExtractingFurnace.class b/src/main/java/jp/plusplus/fbs/container/ContainerExtractingFurnace.class Binary files differnew file mode 100644 index 0000000..24ede45 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerExtractingFurnace.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerExtractingFurnace.java b/src/main/java/jp/plusplus/fbs/container/ContainerExtractingFurnace.java new file mode 100644 index 0000000..a5c5e90 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerExtractingFurnace.java @@ -0,0 +1,148 @@ +package jp.plusplus.fbs.container;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import jp.plusplus.fbs.block.BlockCore;
+import jp.plusplus.fbs.container.slot.SlotTakeOnly;
+import jp.plusplus.fbs.tileentity.TileEntityExtractingFurnace;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidStack;
+
+/**
+ * Createdby pluslus_Fon 2015/06/08.
+ */
+public class ContainerExtractingFurnace extends Container {
+ public int lastProgress;
+ public int lastAmount;
+
+ private TileEntityExtractingFurnace entity;
+
+ public ContainerExtractingFurnace(EntityPlayer player, TileEntityExtractingFurnace tileEntity) {
+ this.entity = tileEntity;
+
+ //inventory's inventory
+ this.addSlotToContainer(new Slot(this.entity, 0, 134, 17));
+ this.addSlotToContainer(new SlotTakeOnly(this.entity, 1, 134, 53));
+ this.addSlotToContainer(new Slot(this.entity, 2, 44, 35));
+
+ //player inventory
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 9; j++) {
+ this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
+ }
+ }
+
+ //player slots
+ for (int i = 0; i < 9; i++) {
+ this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
+ }
+ }
+
+ @Override
+ public void addCraftingToCrafters(ICrafting par1ICrafting) {
+ super.addCraftingToCrafters(par1ICrafting);
+ par1ICrafting.sendProgressBarUpdate(this, 0, entity.tank.getFluidAmount());
+ par1ICrafting.sendProgressBarUpdate(this, 1, entity.progress);
+ }
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ for (int i = 0; i < this.crafters.size(); i++) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if (lastAmount != entity.tank.getFluidAmount()) {
+ icrafting.sendProgressBarUpdate(this, 0, entity.tank.getFluidAmount());
+ }
+ if (lastProgress != entity.progress) {
+ icrafting.sendProgressBarUpdate(this, 1, entity.progress);
+ }
+ }
+ lastAmount=entity.tank.getFluidAmount();
+ lastProgress = entity.progress;
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityPlayer) {
+ return entity.isUseableByPlayer(entityPlayer);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void updateProgressBar(int par1, int par2) {
+ if(par1==0) {
+ for (int i = 0; i < this.crafters.size(); i++) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if (lastAmount != entity.tank.getFluidAmount()) {
+ icrafting.sendProgressBarUpdate(this, 0, entity.tank.getFluidAmount());
+ }
+ }
+ if(par2>0){
+ if(entity.tank.getFluid()==null) entity.tank.setFluid(new FluidStack(BlockCore.mana, par2));
+ else entity.tank.setAmount(par2);
+ }
+ else{
+ entity.tank.setFluid(null);
+ }
+ }
+ else{
+ for (int i = 0; i < this.crafters.size(); i++) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if (lastProgress != entity.progress) {
+ icrafting.sendProgressBarUpdate(this, 1, entity.progress);
+ }
+ }
+ entity.progress=(short)par2;
+ }
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
+ ItemStack itemStack = null;
+ Slot slot = (Slot) this.inventorySlots.get(par2);
+
+ if (slot != null && slot.getHasStack()) {
+ ItemStack stack = slot.getStack();
+ itemStack = stack.copy();
+
+ if (par2 >=0 && par2<=2) {
+ if (!this.mergeItemStack(stack, 3, 39, true)) {
+ return null;
+ }
+ slot.onSlotChange(stack, itemStack);
+ } else {
+ if (entity.isItemValidForSlot(0, stack)) {
+ if (!this.mergeItemStack(stack, 0, 1, false)) {
+ return null;
+ }
+ }
+ else if (entity.isItemValidForSlot(2, stack)) {
+ if (!this.mergeItemStack(stack, 2, 3, false)) {
+ return null;
+ }
+ } else if (par2 >= 3 && par2 < 30) {
+ if (!this.mergeItemStack(stack, 30, 39, false)) {
+ return null;
+ }
+ } else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(stack, 3, 30, false)) {
+ return null;
+ }
+ }
+
+ if (stack.stackSize == 0) {
+ slot.putStack((ItemStack) null);
+ } else {
+ slot.onSlotChanged();
+ }
+
+ if (stack.stackSize == itemStack.stackSize) {
+ return null;
+ }
+ slot.onPickupFromSlot(par1EntityPlayer, stack);
+ }
+
+ return itemStack;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerFBSWorkbench.class b/src/main/java/jp/plusplus/fbs/container/ContainerFBSWorkbench.class Binary files differnew file mode 100644 index 0000000..c9dbb32 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerFBSWorkbench.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerFBSWorkbench.java b/src/main/java/jp/plusplus/fbs/container/ContainerFBSWorkbench.java new file mode 100644 index 0000000..8a8e335 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerFBSWorkbench.java @@ -0,0 +1,136 @@ +package jp.plusplus.fbs.container;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import jp.plusplus.fbs.block.BlockCore;
+import jp.plusplus.fbs.container.slot.SlotCrafting;
+import jp.plusplus.fbs.container.slot.SlotTakeOnly;
+import jp.plusplus.fbs.tileentity.TileEntityFBSWorkbench;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidStack;
+
+/**
+ * Createdby pluslus_Fon 2015/06/14.
+ */
+public class ContainerFBSWorkbench extends Container {
+ protected TileEntityFBSWorkbench entity;
+ public int lastAmount;
+
+ public ContainerFBSWorkbench(EntityPlayer player, TileEntityFBSWorkbench tileEntity) {
+ this.entity = tileEntity;
+
+ //inventory's inventory
+ for(int i=0;i<9;i++) {
+ this.addSlotToContainer(new Slot(this.entity, i, 30 + (i % 3) * 18, 17 + (i / 3) * 18));
+ }
+ this.addSlotToContainer(new SlotCrafting(player, this.entity, 9, 124, 35));
+
+ this.addSlotToContainer(new Slot(this.entity, 10, 66, 71));
+ this.addSlotToContainer(new SlotTakeOnly(this.entity, 11, 30, 71));
+
+ //player inventory
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 9; j++) {
+ this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 103 + i * 18));
+ }
+ }
+
+ //player slots
+ for (int i = 0; i < 9; i++) {
+ this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 161));
+ }
+ }
+
+ @Override
+ public void addCraftingToCrafters(ICrafting par1ICrafting) {
+ super.addCraftingToCrafters(par1ICrafting);
+ par1ICrafting.sendProgressBarUpdate(this, 0, entity.tank.getFluidAmount());
+ }
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ for (int i = 0; i < this.crafters.size(); i++) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if (lastAmount != entity.tank.getFluidAmount()) {
+ icrafting.sendProgressBarUpdate(this, 0, entity.tank.getFluidAmount());
+ }
+ }
+ lastAmount = entity.tank.getFluidAmount();
+ }
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void updateProgressBar(int par1, int par2) {
+ if (par1 == 0) {
+ for (int i = 0; i < this.crafters.size(); i++) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if (lastAmount != entity.tank.getFluidAmount()) {
+ icrafting.sendProgressBarUpdate(this, 0, entity.tank.getFluidAmount());
+ }
+ }
+ if (par2 > 0) {
+ if (entity.tank.getFluid() == null) entity.tank.setFluid(new FluidStack(BlockCore.mana, par2));
+ else entity.tank.setAmount(par2);
+ } else {
+ entity.tank.setFluid(null);
+ }
+ }
+ }
+
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityPlayer) {
+ return entity.isUseableByPlayer(entityPlayer);
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
+ ItemStack itemStack = null;
+ Slot slot = (Slot) this.inventorySlots.get(par2);
+
+ if (slot != null && slot.getHasStack()) {
+ ItemStack stack = slot.getStack();
+ itemStack = stack.copy();
+
+ if (par2 >= 0 && par2 <= 11) {
+ if(par2==9){
+ if(entity.product!=null){
+ entity.tank.drain(entity.product.mana*stack.stackSize, true);
+ }
+ }
+ if (!this.mergeItemStack(stack, 12, 48, true)) {
+ return null;
+ }
+ slot.onSlotChange(stack, itemStack);
+ } else {
+ if (entity.isItemValidForSlot(10, stack)) {
+ if (!this.mergeItemStack(stack, 10, 11, false)) {
+ return null;
+ }
+ } else if (par2 >= 12 && par2 < 39) {
+ if (!this.mergeItemStack(stack, 39, 48, false)) {
+ return null;
+ }
+ } else if (par2 >= 39 && par2 < 48 && !this.mergeItemStack(stack, 12, 39, false)) {
+ return null;
+ }
+ }
+
+ if (stack.stackSize == 0) {
+ slot.putStack((ItemStack) null);
+ } else {
+ slot.onSlotChanged();
+ }
+
+ if (stack.stackSize == itemStack.stackSize) {
+ return null;
+ }
+ slot.onPickupFromSlot(par1EntityPlayer, stack);
+ }
+
+ return itemStack;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerFillingTable.class b/src/main/java/jp/plusplus/fbs/container/ContainerFillingTable.class Binary files differnew file mode 100644 index 0000000..57995f3 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerFillingTable.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerFillingTable.java b/src/main/java/jp/plusplus/fbs/container/ContainerFillingTable.java new file mode 100644 index 0000000..dfabcfd --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerFillingTable.java @@ -0,0 +1,146 @@ +package jp.plusplus.fbs.container;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import jp.plusplus.fbs.block.BlockCore;
+import jp.plusplus.fbs.container.slot.SlotTakeOnly;
+import jp.plusplus.fbs.tileentity.TileEntityFillingTable;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidStack;
+
+/**
+ * Createdby pluslus_Fon 2015/06/14.
+ */
+public class ContainerFillingTable extends Container {
+ public int lastProgress;
+ public int lastAmount;
+
+ private TileEntityFillingTable entity;
+
+ public ContainerFillingTable(EntityPlayer player, TileEntityFillingTable tileEntity) {
+ this.entity = tileEntity;
+
+ //inventory's inventory
+ this.addSlotToContainer(new Slot(this.entity, 0, 116, 35));
+ this.addSlotToContainer(new Slot(this.entity, 1, 44, 17));
+ this.addSlotToContainer(new SlotTakeOnly(this.entity, 2, 44, 53));
+
+ //player inventory
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 9; j++) {
+ this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
+ }
+ }
+
+ //player slots
+ for (int i = 0; i < 9; i++) {
+ this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
+ }
+ }
+
+ @Override
+ public void addCraftingToCrafters(ICrafting par1ICrafting) {
+ super.addCraftingToCrafters(par1ICrafting);
+ par1ICrafting.sendProgressBarUpdate(this, 0, entity.tank.getFluidAmount());
+ par1ICrafting.sendProgressBarUpdate(this, 1, entity.progress);
+ }
+
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ for (int i = 0; i < this.crafters.size(); i++) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if (lastAmount != entity.tank.getFluidAmount()) {
+ icrafting.sendProgressBarUpdate(this, 0, entity.tank.getFluidAmount());
+ }
+ if (lastProgress != entity.progress) {
+ icrafting.sendProgressBarUpdate(this, 1, entity.progress);
+ }
+ }
+ lastAmount = entity.tank.getFluidAmount();
+ lastProgress = entity.progress;
+ }
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void updateProgressBar(int par1, int par2) {
+ if (par1 == 0) {
+ for (int i = 0; i < this.crafters.size(); i++) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if (lastAmount != entity.tank.getFluidAmount()) {
+ icrafting.sendProgressBarUpdate(this, 0, entity.tank.getFluidAmount());
+ }
+ }
+ if (par2 > 0) {
+ if (entity.tank.getFluid() == null) entity.tank.setFluid(new FluidStack(BlockCore.mana, par2));
+ else entity.tank.setAmount(par2);
+ } else {
+ entity.tank.setFluid(null);
+ }
+ } else {
+ for (int i = 0; i < this.crafters.size(); i++) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if (lastProgress != entity.progress) {
+ icrafting.sendProgressBarUpdate(this, 1, entity.progress);
+ }
+ }
+ entity.progress = (short) par2;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityPlayer) {
+ return entity.isUseableByPlayer(entityPlayer);
+ }
+
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
+ ItemStack itemStack = null;
+ Slot slot = (Slot) this.inventorySlots.get(par2);
+
+ if (slot != null && slot.getHasStack()) {
+ ItemStack stack = slot.getStack();
+ itemStack = stack.copy();
+
+ if (par2 >= 0 && par2 <= 2) {
+ if (!this.mergeItemStack(stack, 3, 39, true)) {
+ return null;
+ }
+ slot.onSlotChange(stack, itemStack);
+ } else {
+ if (entity.isItemValidForSlot(0, stack)) {
+ if (!this.mergeItemStack(stack, 0, 1, false)) {
+ return null;
+ }
+ } else if (entity.isItemValidForSlot(1, stack)) {
+ if (!this.mergeItemStack(stack, 1, 2, false)) {
+ return null;
+ }
+ } else if (par2 >= 3 && par2 < 30) {
+ if (!this.mergeItemStack(stack, 30, 39, false)) {
+ return null;
+ }
+ } else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(stack, 3, 30, false)) {
+ return null;
+ }
+ }
+
+ if (stack.stackSize == 0) {
+ slot.putStack((ItemStack) null);
+ } else {
+ slot.onSlotChanged();
+ }
+
+ if (stack.stackSize == itemStack.stackSize) {
+ return null;
+ }
+ slot.onPickupFromSlot(par1EntityPlayer, stack);
+ }
+
+ return itemStack;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerKiln.class b/src/main/java/jp/plusplus/fbs/container/ContainerKiln.class Binary files differnew file mode 100644 index 0000000..04311f7 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerKiln.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerKiln.java b/src/main/java/jp/plusplus/fbs/container/ContainerKiln.java new file mode 100644 index 0000000..9ce9698 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerKiln.java @@ -0,0 +1,114 @@ +package jp.plusplus.fbs.container;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import jp.plusplus.fbs.container.slot.SlotTakeOnly;
+import jp.plusplus.fbs.pottery.TileEntityKiln;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Created by plusplus_F on 2015/08/27.
+ */
+public class ContainerKiln extends Container {
+ public int lastFurnaceBurn;
+ public int lastItemBurn;
+ public int[] lastProgress=new int[9];
+ public TileEntityKiln entity;
+
+
+ public ContainerKiln(EntityPlayer player, TileEntityKiln tileEntity) {
+ this.entity = tileEntity;
+
+ //inventory's inventory
+ for(int i=0;i<9;i++) addSlotToContainer(new Slot(entity, i, 8+i*18, 58));
+ this.addSlotToContainer(new Slot(this.entity, 9, 80, 93));
+ for(int i=0;i<9;i++) addSlotToContainer(new SlotTakeOnly(entity, 10+i, 8+i*18, 23, 1));
+
+ //player inventory
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 9; j++) {
+ this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 115 + i * 18));
+ }
+ }
+
+ //player slots
+ for (int i = 0; i < 9; i++) {
+ this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 173));
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityPlayer) {
+ return entity.isUseableByPlayer(entityPlayer);
+ }
+
+ @Override
+ public void addCraftingToCrafters(ICrafting par1ICrafting) {
+ super.addCraftingToCrafters(par1ICrafting);
+ par1ICrafting.sendProgressBarUpdate(this, 0, entity.furnaceBurnTime);
+ par1ICrafting.sendProgressBarUpdate(this, 1, entity.currentItemBurnTime);
+ for(int i=0;i<9;i++) par1ICrafting.sendProgressBarUpdate(this, 2+i, entity.progress[i]);
+ }
+
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ for (int i = 0; i < this.crafters.size(); i++) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if(lastFurnaceBurn!=entity.furnaceBurnTime) icrafting.sendProgressBarUpdate(this, 0, entity.furnaceBurnTime);
+ if(lastItemBurn!=entity.currentItemBurnTime) icrafting.sendProgressBarUpdate(this, 1, entity.currentItemBurnTime);
+ for(int k=0;k<9;k++){
+ if (lastProgress[k] != entity.progress[k]) icrafting.sendProgressBarUpdate(this, 2+k, entity.progress[k]);
+ }
+ }
+ lastFurnaceBurn=entity.furnaceBurnTime;
+ lastItemBurn=entity.currentItemBurnTime;
+ for(int k=0;k<9;k++) lastProgress[k] = entity.progress[k];
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void updateProgressBar(int par1, int par2) {
+ if (par1 == 0) {
+ for (int i = 0; i < this.crafters.size(); i++) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if (lastFurnaceBurn != entity.furnaceBurnTime) {
+ icrafting.sendProgressBarUpdate(this, 0, entity.furnaceBurnTime);
+ }
+ }
+ entity.furnaceBurnTime=par2;
+ }
+ else if(par1==1){
+ for (int i = 0; i < this.crafters.size(); i++) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if (lastItemBurn != entity.currentItemBurnTime) {
+ icrafting.sendProgressBarUpdate(this, 0, entity.currentItemBurnTime);
+ }
+ }
+ entity.currentItemBurnTime=par2;
+ }
+ else {
+ int k = par1 - 2;
+ if (k < 0 || k >= 9) return;
+
+ for (int i = 0; i < this.crafters.size(); i++) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if (lastProgress != entity.progress) {
+ icrafting.sendProgressBarUpdate(this, 1, entity.progress[k]);
+ }
+ }
+ entity.progress[k] = (short) par2;
+ }
+ }
+
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
+ ItemStack itemStack = null;
+ return itemStack;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerMagic.class b/src/main/java/jp/plusplus/fbs/container/ContainerMagic.class Binary files differnew file mode 100644 index 0000000..8e0c99f --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerMagic.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerMagic.java b/src/main/java/jp/plusplus/fbs/container/ContainerMagic.java new file mode 100644 index 0000000..73f81be --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerMagic.java @@ -0,0 +1,101 @@ +package jp.plusplus.fbs.container;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import jp.plusplus.fbs.block.BlockCore;
+import jp.plusplus.fbs.container.slot.SlotInventory;
+import jp.plusplus.fbs.container.inventory.InventoryMagic;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidStack;
+
+/**
+ * Created by pluslus_F on 2015/06/18.
+ */
+public class ContainerMagic extends Container {
+ public InventoryMagic inventory;
+ private int lastProgress;
+
+ public ContainerMagic(InventoryPlayer invP, InventoryMagic invM){
+ inventory=invM;
+ invM.openInventory();
+
+ //player's inv
+ for (int j = 0; j < 3; ++j) {
+ for (int k = 0; k < 9; ++k) {
+ this.addSlotToContainer(new SlotInventory(invP, k + j * 9 + 9, 8 + k * 18, 84 + j * 18, 2));
+ }
+ }
+
+ for (int j = 0; j < 9; ++j) {
+ this.addSlotToContainer(new SlotInventory(invP, j, 8 + j * 18, 142, 2));
+ }
+
+ invM.addSlotToContainer(this);
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer p_75145_1_) {
+ return true;
+ }
+
+ @Override
+ public void onContainerClosed(EntityPlayer p_75134_1_) {
+ super.onContainerClosed(p_75134_1_);
+ this.inventory.closeInventory();
+ }
+
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) {
+ ItemStack itemstack = null;
+ return itemstack;
+ }
+
+
+ public Slot addSlotToContainer(Slot p_75146_1_){
+ return super.addSlotToContainer(p_75146_1_);
+ }
+
+
+ @Override
+ public void addCraftingToCrafters(ICrafting par1ICrafting) {
+ super.addCraftingToCrafters(par1ICrafting);
+ if(inventory.magicCore!=null){
+ par1ICrafting.sendProgressBarUpdate(this, 0, inventory.magicCore.progress);
+ }
+
+ }
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ if(inventory.magicCore==null) return;
+
+ for (int i = 0; i < this.crafters.size(); i++) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if (lastProgress != inventory.magicCore.progress) {
+ icrafting.sendProgressBarUpdate(this, 0, inventory.magicCore.progress);
+ }
+ }
+ lastProgress = inventory.magicCore.progress;
+ }
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void updateProgressBar(int par1, int par2) {
+ if(par1==0) {
+ for (int i = 0; i < this.crafters.size(); i++) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if (inventory.magicCore!=null && lastProgress != inventory.magicCore.progress) {
+ icrafting.sendProgressBarUpdate(this, 0, inventory.magicCore.progress);
+ }
+ }
+ if(inventory.magicCore!=null){
+ inventory.magicCore.progress=par2;
+ }
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerPottersWheel.class b/src/main/java/jp/plusplus/fbs/container/ContainerPottersWheel.class Binary files differnew file mode 100644 index 0000000..b4e535c --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerPottersWheel.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerPottersWheel.java b/src/main/java/jp/plusplus/fbs/container/ContainerPottersWheel.java new file mode 100644 index 0000000..3aea02e --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerPottersWheel.java @@ -0,0 +1,85 @@ +package jp.plusplus.fbs.container;
+
+import jp.plusplus.fbs.container.slot.SlotCraftingPottery;
+import jp.plusplus.fbs.pottery.TileEntityPottersWheel;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Created by pluslus_F on 2015/08/29.
+ */
+public class ContainerPottersWheel extends Container {
+ protected TileEntityPottersWheel entity;
+
+ public ContainerPottersWheel(EntityPlayer player, TileEntityPottersWheel tileEntity) {
+ this.entity = tileEntity;
+
+ //inventory's inventory
+ for(int i=0;i<25;i++) {
+ this.addSlotToContainer(new Slot(this.entity, i, 8 + (i % 5) * 18, 17 + (i / 5) * 18));
+ }
+ this.addSlotToContainer(new SlotCraftingPottery(player, this.entity, 25, 140, 54));
+
+ //player inventory
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 9; j++) {
+ this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 120 + i * 18));
+ }
+ }
+
+ //player slots
+ for (int i = 0; i < 9; i++) {
+ this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 178));
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityPlayer) {
+ return entity.isUseableByPlayer(entityPlayer);
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) {
+ ItemStack itemStack = null;
+ Slot slot = (Slot) this.inventorySlots.get(par2);
+
+ if (slot != null && slot.getHasStack()) {
+ ItemStack stack = slot.getStack();
+ itemStack = stack.copy();
+
+ if(par2==25){
+ if(!this.mergeItemStack(stack, 26+24, 26+24+9, true)){
+ return null;
+ }
+ slot.onSlotChange(stack, itemStack);
+ }
+ else if(par2>=26){
+ if(par2<26+24){
+ if(!this.mergeItemStack(stack, 26+24, 26+24+9, false)){
+ return null;
+ }
+ }
+ else{
+ if(!this.mergeItemStack(stack, 26, 26+24, false)){
+ return null;
+ }
+ }
+ }
+
+ if (stack.stackSize == 0) {
+ slot.putStack((ItemStack) null);
+ } else {
+ slot.onSlotChanged();
+ }
+
+ if (stack.stackSize == itemStack.stackSize) {
+ return null;
+ }
+ slot.onPickupFromSlot(par1EntityPlayer, stack);
+ }
+
+ return itemStack;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerShopAuthor.class b/src/main/java/jp/plusplus/fbs/container/ContainerShopAuthor.class Binary files differnew file mode 100644 index 0000000..8194621 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerShopAuthor.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerShopAuthor.java b/src/main/java/jp/plusplus/fbs/container/ContainerShopAuthor.java new file mode 100644 index 0000000..b34c78a --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerShopAuthor.java @@ -0,0 +1,32 @@ +package jp.plusplus.fbs.container;
+
+import jp.plusplus.fbs.entity.EntityMagicAuthor;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ContainerMerchant;
+import net.minecraft.world.World;
+import shift.mceconomy2.api.shop.IShop;
+import shift.mceconomy2.gui.ContainerShop;
+
+/**
+ * Created by plusplus_F on 2016/02/24.
+ */
+public class ContainerShopAuthor extends ContainerShop {
+ protected EntityMagicAuthor author;
+
+ public ContainerShopAuthor(EntityPlayer entityPlayer, IShop par2IProductList, World par3World, EntityMagicAuthor author) {
+ super(entityPlayer, par2IProductList, par3World);
+ this.author=author;
+ }
+
+ @Override
+ public void onContainerClosed(EntityPlayer player){
+ if(author!=null){
+ author.setCustomer(null);
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer entityplayer) {
+ return author==null || author.getCustomer() == entityplayer;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerStaff.class b/src/main/java/jp/plusplus/fbs/container/ContainerStaff.class Binary files differnew file mode 100644 index 0000000..6c379fc --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerStaff.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerStaff.java b/src/main/java/jp/plusplus/fbs/container/ContainerStaff.java new file mode 100644 index 0000000..0fdba49 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerStaff.java @@ -0,0 +1,59 @@ +package jp.plusplus.fbs.container;
+
+import jp.plusplus.fbs.container.slot.SlotInventory;
+import jp.plusplus.fbs.container.inventory.InventoryStaff;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Createdby pluslus_Fon 2015/06/15.
+ */
+public class ContainerStaff extends Container {
+ public InventoryStaff inventory;
+
+ public ContainerStaff(InventoryPlayer invP) {
+ inventory = new InventoryStaff(invP);
+ inventory.openInventory();
+
+ //player's inv
+ for (int j = 0; j < 3; ++j) {
+ for (int k = 0; k < 9; ++k) {
+ this.addSlotToContainer(new SlotInventory(invP, k + j * 9 + 9, 8 + k * 18, 84 + j * 18, 2));
+ }
+ }
+
+ for (int j = 0; j < 9; ++j) {
+ this.addSlotToContainer(new SlotInventory(invP, j, 8 + j * 18, 142, 2));
+ }
+
+ //staff
+ if(inventory.bookNum==1) addSlotToContainer(new SlotInventory(inventory, 0, 80, 25, 0));
+ if(inventory.bookNum==2){
+ addSlotToContainer(new SlotInventory(inventory, 0, 67, 25, 0));
+ addSlotToContainer(new SlotInventory(inventory, 1, 93, 25, 0));
+ }
+ for (int i = 0; i < inventory.gemNum; i++)
+ addSlotToContainer(new SlotInventory(inventory, inventory.bookNum + i, 44 + i * 18, 53, 1));
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer p_75145_1_) {
+ return true;
+ }
+
+ @Override
+ public void onContainerClosed(EntityPlayer p_75134_1_) {
+ super.onContainerClosed(p_75134_1_);
+ inventory.closeInventory();
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) {
+ ItemStack itemstack = null;
+ Slot slot = (Slot) this.inventorySlots.get(p_82846_2_);
+ return itemstack;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerTFKEnchantment.class b/src/main/java/jp/plusplus/fbs/container/ContainerTFKEnchantment.class Binary files differnew file mode 100644 index 0000000..f7c8f44 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerTFKEnchantment.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerTFKEnchantment.java b/src/main/java/jp/plusplus/fbs/container/ContainerTFKEnchantment.java new file mode 100644 index 0000000..b8f6785 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerTFKEnchantment.java @@ -0,0 +1,148 @@ +package jp.plusplus.fbs.container;
+
+import jp.plusplus.fbs.AchievementRegistry;
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.api.FBSEntityPropertiesAPI;
+import jp.plusplus.fbs.container.inventory.InventoryEnchantment;
+import jp.plusplus.fbs.container.slot.SlotInventory;
+import jp.plusplus.fbs.container.slot.SlotTakeOnly;
+import jp.plusplus.fbs.exprop.FBSEntityProperties;
+import jp.plusplus.fbs.item.ItemEnchantScroll;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.MathHelper;
+
+import java.util.Map;
+import java.util.Random;
+
+/**
+ * Created by plusplus_F on 2015/10/21.
+ */
+public class ContainerTFKEnchantment extends Container {
+ public boolean enchanted;
+ public InventoryEnchantment inventory;
+ public EntityPlayer player;
+
+ public ContainerTFKEnchantment(EntityPlayer player){
+ this.player=player;
+ inventory=new InventoryEnchantment(player);
+
+ addSlotToContainer(new Slot(inventory, 0, 44, 31));
+ addSlotToContainer(new Slot(inventory, 1, 62, 31));
+ addSlotToContainer(new SlotTakeOnly(inventory, 2, 120, 31));
+
+ //player's inv
+ for (int j = 0; j < 3; ++j) {
+ for (int k = 0; k < 9; ++k) {
+ this.addSlotToContainer(new SlotInventory(player.inventory, k + j * 9 + 9, 8 + k * 18, 84 + j * 18, 2));
+ }
+ }
+ for (int j = 0; j < 9; ++j) {
+ this.addSlotToContainer(new SlotInventory(player.inventory, j, 8 + j * 18, 142, 2));
+ }
+ }
+
+ public double getEnchantExp(int enchLv){
+ return 100 * enchLv;
+ }
+ public float getEnchantProbability(){
+ ItemStack es=inventory.getStackInSlot(1);
+ if(es==null) return 0;
+ Map ench=EnchantmentHelper.getEnchantments(es);
+ Map.Entry e=(Map.Entry)ench.entrySet().iterator().next();
+ return getEnchantProbability((Integer)e.getValue());
+ }
+ public float getEnchantProbability(int enchLv){
+ float p=0.5f;
+ p-=0.1f*(enchLv-1);
+ p+=0.01f*FBSEntityPropertiesAPI.GetMagicLevel(player);
+ return p;
+ }
+ public boolean canEnchant(){
+ ItemStack itemStack=inventory.getStackInSlot(0);
+ if(itemStack==null || !itemStack.getItem().isItemTool(itemStack)){
+ return false;
+ }
+
+ ItemStack es=inventory.getStackInSlot(1);
+ if(es==null || !(es.getItem() instanceof ItemEnchantScroll) || !es.isItemEnchanted()){
+ return false;
+ }
+
+ return true;
+ }
+ public void tryEnchant(){
+ if(!canEnchant()) return;
+
+ Random rand=new Random();
+ ItemStack itemStack=inventory.getStackInSlot(0);
+ ItemStack es=inventory.getStackInSlot(1);
+
+ Map ench=EnchantmentHelper.getEnchantments(es);
+ Map.Entry e=(Map.Entry)ench.entrySet().iterator().next();
+ int eLv=(Integer)e.getValue();
+
+ if(rand.nextFloat()<getEnchantProbability(eLv)){
+ //成功
+ player.triggerAchievement(AchievementRegistry.enchant);
+
+ //経験値
+ FBSEntityPropertiesAPI.AddExp(player, getEnchantExp(eLv), true);
+
+ //エンチャント重複判定,重複している場合は新しいもので上書きする
+ Map itemEnchantmentList=EnchantmentHelper.getEnchantments(itemStack);
+ if(itemEnchantmentList.containsKey(e.getKey())) {
+ //重複してる場合は削除
+ itemEnchantmentList.remove(e.getKey());
+ }
+
+ //エンチャント付与
+ itemEnchantmentList.put(e.getKey(), e.getValue());
+ EnchantmentHelper.setEnchantments(itemEnchantmentList, itemStack);
+
+ //スロット操作
+ inventory.setInventorySlotContents(0, null);
+ inventory.setInventorySlotContents(1, null);
+ inventory.setInventorySlotContents(2, itemStack);
+ }
+ else{
+ //失敗e
+
+ //経験値
+ FBSEntityPropertiesAPI.AddExp(player, 0.2*getEnchantExp(eLv), true);
+
+ //アイテムの耐久減らす
+ float d=(0.1f+(0.1f+0.1f*(eLv-1))*rand.nextFloat())*itemStack.getMaxDamage();
+ itemStack.setItemDamage(itemStack.getItemDamage() + MathHelper.floor_float(d));
+ inventory.setInventorySlotContents(0, null);
+ if(itemStack.getItemDamage()<itemStack.getMaxDamage()) inventory.setInventorySlotContents(2, itemStack);
+
+ //ESの耐久減らす
+ int mLv=FBSEntityPropertiesAPI.GetMagicLevel(player);
+ float dMin=0.1f+0.4f*(1.0f-(float)mLv/FBSEntityProperties.MAGIC_LEVEL_MAX);
+ d=dMin*es.getMaxDamage();
+ es.setItemDamage(es.getItemDamage()+ MathHelper.floor_float(d));
+ if(es.getItemDamage()>=es.getMaxDamage()) inventory.setInventorySlotContents(1, null);
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer p_75145_1_) {
+ return true;
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) {
+ ItemStack itemstack = null;
+ return itemstack;
+ }
+ @Override
+ public void onContainerClosed(EntityPlayer p_75134_1_) {
+ super.onContainerClosed(p_75134_1_);
+ this.inventory.closeInventory();
+ }
+
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerWarp.class b/src/main/java/jp/plusplus/fbs/container/ContainerWarp.class Binary files differnew file mode 100644 index 0000000..6855e6b --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerWarp.class diff --git a/src/main/java/jp/plusplus/fbs/container/ContainerWarp.java b/src/main/java/jp/plusplus/fbs/container/ContainerWarp.java new file mode 100644 index 0000000..a379af4 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/ContainerWarp.java @@ -0,0 +1,37 @@ +package jp.plusplus.fbs.container;
+
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.item.ItemBookNoDecoded;
+import jp.plusplus.fbs.item.ItemBookSorcery;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Created by plusplus_F on 2015/10/22.
+ */
+public class ContainerWarp extends Container {
+ public EntityPlayer player;
+ public boolean close;
+
+ public ContainerWarp(EntityPlayer ep){
+ player=ep;
+ close=false;
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer p_75145_1_) {
+ if(close) return false;
+
+ ItemStack item=p_75145_1_.getCurrentEquippedItem();
+ if(item==null) return false;
+ if(!(item.getItem() instanceof ItemBookSorcery)) return false;
+
+ Registry.BookData bd=Registry.GetBookDataFromItemStack(item);
+ if(bd==null) return false;
+
+ if(!bd.title.equals("fbs.warp")) return false;
+
+ return ItemBookSorcery.getMagicMaxUse(item)>0;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBasket.class b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBasket.class Binary files differnew file mode 100644 index 0000000..bae5992 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBasket.class diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBasket.java b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBasket.java new file mode 100644 index 0000000..9db5485 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBasket.java @@ -0,0 +1,162 @@ +package jp.plusplus.fbs.container.inventory;
+
+import jp.plusplus.fbs.alchemy.AlchemyRegistry;
+import jp.plusplus.fbs.alchemy.IAlchemyMaterial;
+import jp.plusplus.fbs.alchemy.IAlchemyProduct;
+import jp.plusplus.fbs.item.ItemCharm;
+import jp.plusplus.fbs.item.ItemCore;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.util.StatCollector;
+
+/**
+ * Created by plusplus_F on 2015/11/11.
+ */
+public class InventoryBasket implements IInventory {
+ private InventoryPlayer inventoryPlayer;
+ private ItemStack currentItem;
+ private ItemStack[] items;
+ private int currentIndex;
+
+ public InventoryBasket(InventoryPlayer inventory) {
+ inventoryPlayer = inventory;
+ currentItem = inventoryPlayer.getCurrentItem();
+ currentIndex=inventory.currentItem;
+ items = new ItemStack[54];
+ }
+ public InventoryBasket(InventoryPlayer inventory, int index) {
+ inventoryPlayer = inventory;
+ this.currentItem = inventory.getStackInSlot(index);
+ currentIndex=index;
+ items = new ItemStack[54];
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return items.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int slot) {
+ return items[slot];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int i, int size) {
+ if (this.items[i] != null) {
+ ItemStack itemstack;
+
+ if (this.items[i].stackSize <= size) {
+ itemstack = this.items[i];
+ this.items[i] = null;
+ this.markDirty();
+ return itemstack;
+ } else {
+ itemstack = this.items[i].splitStack(size);
+
+ if (this.items[i].stackSize == 0) {
+ this.items[i] = null;
+ }
+
+ this.markDirty();
+ return itemstack;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int i) {
+ if (this.items[i] != null) {
+ ItemStack itemstack = this.items[i];
+ this.items[i] = null;
+ return itemstack;
+ }
+ return null;
+ }
+
+ @Override
+ public void setInventorySlotContents(int i, ItemStack item) {
+ this.items[i] = item;
+
+ if (item != null && item.stackSize > this.getInventoryStackLimit()) {
+ item.stackSize = this.getInventoryStackLimit();
+ }
+
+ this.markDirty();
+ }
+
+ @Override
+ public String getInventoryName() {
+ return StatCollector.translateToLocal(ItemCore.basket.getUnlocalizedName() + ".name");
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+
+ @Override
+ public void markDirty() {
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
+ return true;
+ }
+
+ @Override
+ public void openInventory() {
+ if (!currentItem.hasTagCompound()) {
+ currentItem.setTagCompound(new NBTTagCompound());
+ currentItem.getTagCompound().setTag("Items", new NBTTagList());
+ }
+ else if(!currentItem.getTagCompound().hasKey("Items")){
+ currentItem.getTagCompound().setTag("Items", new NBTTagList());
+ }
+
+ NBTTagList tags = (NBTTagList) currentItem.getTagCompound().getTag("Items");
+ for (int i = 0; i < tags.tagCount(); i++) {
+ NBTTagCompound tagCompound = tags.getCompoundTagAt(i);
+ int slot = tagCompound.getByte("Slot");
+ if (slot >= 0 && slot < items.length) {
+ items[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
+ }
+ }
+ }
+
+ @Override
+ public void closeInventory() {
+ NBTTagList tagList = new NBTTagList();
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] != null) {
+ NBTTagCompound compound = new NBTTagCompound();
+ compound.setByte("Slot", (byte) i);
+ items[i].writeToNBT(compound);
+ tagList.appendTag(compound);
+ }
+ }
+ ItemStack result = new ItemStack(currentItem.getItem(), 1, currentItem.getItemDamage());
+ result.setTagCompound(new NBTTagCompound());;
+ result.getTagCompound().setTag("Items", tagList);
+ result.getTagCompound().setInteger("Color", currentItem.getTagCompound().getInteger("Color"));
+
+ inventoryPlayer.mainInventory[currentIndex] = result;
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack item) {
+ Item it=item.getItem();
+ return it instanceof IAlchemyMaterial || it instanceof IAlchemyProduct || AlchemyRegistry.isBasketItem(item);
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBonfire$EnchantmentPair.class b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBonfire$EnchantmentPair.class Binary files differnew file mode 100644 index 0000000..9443dba --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBonfire$EnchantmentPair.class diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBonfire.class b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBonfire.class Binary files differnew file mode 100644 index 0000000..a51ef15 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBonfire.class diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBonfire.java b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBonfire.java new file mode 100644 index 0000000..692dcaf --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryBonfire.java @@ -0,0 +1,288 @@ +package jp.plusplus.fbs.container.inventory;
+
+import jp.plusplus.fbs.AchievementRegistry;
+import jp.plusplus.fbs.alchemy.AlchemyRegistry;
+import jp.plusplus.fbs.alchemy.IAlchemyMaterial;
+import jp.plusplus.fbs.api.FBSEntityPropertiesAPI;
+import jp.plusplus.fbs.block.BlockCore;
+import jp.plusplus.fbs.exprop.FBSEntityProperties;
+import jp.plusplus.fbs.exprop.SanityManager;
+import jp.plusplus.fbs.item.ItemCore;
+import net.minecraft.enchantment.Enchantment;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.item.EntityXPOrb;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Items;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.SlotFurnace;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntityFurnace;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.StatCollector;
+import shift.mceconomy2.MCEconomy2;
+import shift.mceconomy2.api.MCEconomyAPI;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Random;
+
+/**
+ * Created by plusplus_F on 2015/10/19.
+ */
+public class InventoryBonfire implements IInventory {
+ public ItemStack[] itemStacks=new ItemStack[4];
+ public Random rand=new Random();
+ public EntityPlayer player;
+
+ private int x,y,z;
+
+ public InventoryBonfire(int x, int y, int z, EntityPlayer player){
+ this.x=x;
+ this.y=y;
+ this.z=z;
+ this.player=player;
+ }
+
+ public float getExtractProb(EnchantmentPair ench, int mLv){
+ float p=0.5f;
+ p-=0.15f*(ench.lv-1);
+ p+=0.025f*mLv;
+ return p;
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return itemStacks.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int p_70301_1_) {
+ return itemStacks[p_70301_1_];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) {
+ if (this.itemStacks[p_70298_1_] != null) {
+ ItemStack itemstack;
+
+ if (this.itemStacks[p_70298_1_].stackSize <= p_70298_2_) {
+ itemstack = this.itemStacks[p_70298_1_];
+ this.itemStacks[p_70298_1_] = null;
+ this.markDirty();
+ return itemstack;
+ } else {
+ itemstack = this.itemStacks[p_70298_1_].splitStack(p_70298_2_);
+
+ if (this.itemStacks[p_70298_1_].stackSize == 0) {
+ this.itemStacks[p_70298_1_] = null;
+ }
+
+ this.markDirty();
+ return itemstack;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int p_70304_1_) {
+ if (this.itemStacks[p_70304_1_] != null) {
+ ItemStack itemstack = this.itemStacks[p_70304_1_];
+ this.itemStacks[p_70304_1_] = null;
+ return itemstack;
+ }
+ return null;
+ }
+
+ @Override
+ public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
+ this.itemStacks[p_70299_1_] = p_70299_2_;
+ if (p_70299_2_ != null && p_70299_2_.stackSize > this.getInventoryStackLimit()) {
+ p_70299_2_.stackSize = this.getInventoryStackLimit();
+ }
+ this.markDirty();
+ }
+
+ @Override
+ public String getInventoryName() {
+ return BlockCore.bonfire.getLocalizedName();
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+
+ @Override
+ public void markDirty() {
+ //焼却スロットにアイテムがある場合
+ if(itemStacks[0]!=null){
+ if(!player.worldObj.isRemote) {
+ //--------------------------------焼却経験値の生成------------------------------------------
+ float rate;
+ int size = itemStacks[0].stackSize;
+ int tmp;
+
+ //レートの決定
+ float value;
+ if(itemStacks[0].isItemStackDamageable()){
+ ItemStack is=itemStacks[0].copy();
+ is.setItemDamage(0);
+ value=MCEconomyAPI.getPurchase(is)*(1.f-(float)itemStacks[0].getItemDamage()/(float)itemStacks[0].getMaxDamage());
+ }
+ else{
+ value=MCEconomyAPI.getPurchase(itemStacks[0]);
+ }
+ rate=0.001f*value;
+ if(rate<0.02f) rate=0.02f;
+ if(rate>1.f) rate=1.f;
+
+ //経験値の決定
+ if(rate<1.f){
+ tmp = MathHelper.floor_float(size * rate);
+ if (tmp < MathHelper.ceiling_float_int(size * rate) && (float) Math.random() < size * rate - (float) tmp) {
+ tmp++;
+ }
+ size = tmp;
+ }
+
+ while (size > 0) {
+ tmp = EntityXPOrb.getXPSplit(size);
+ size -= tmp;
+ player.worldObj.spawnEntityInWorld(new EntityXPOrb(player.worldObj, player.posX, player.posY + 0.5D, player.posZ + 0.5D, tmp));
+ }
+
+ //焼却アイテムがエンチャントされてあり、かつハーブスロットにハーブが存在する場合
+ //--------------------------------ESの生成------------------------------------------
+ if (itemStacks[0].isItemEnchanted() || itemStacks[0].getItem()==Items.enchanted_book) {
+ int herb = 0;
+ for (int i = 1; i < 4; i++) {
+ if (itemStacks[i] == null) continue;
+ if (!(itemStacks[i].getItem() instanceof IAlchemyMaterial)) continue;
+
+ if (AlchemyRegistry.IsMatching("herb", itemStacks[i])) {
+ herb++;
+ }
+ }
+
+ if (herb > 0) {
+ //エンチャントの抽出
+ ArrayList<EnchantmentPair> list = new ArrayList<EnchantmentPair>();
+ Map enchantments = EnchantmentHelper.getEnchantments(itemStacks[0]);
+ for (Object obj : enchantments.entrySet()) {
+ Map.Entry e = (Map.Entry) obj;
+ list.add(new EnchantmentPair((Integer) e.getKey(), (Integer) e.getValue()));
+ }
+
+ int mLv=FBSEntityPropertiesAPI.GetMagicLevel(player);
+
+ //ハーブの数だけ繰り返す
+ for (; herb > 0 && !list.isEmpty(); herb--) {
+ int index = rand.nextInt(list.size());
+ EnchantmentPair ep = list.get(index);
+ if (!player.capabilities.isCreativeMode && rand.nextFloat() >= getExtractProb(ep, mLv)){
+ String str=String.format(StatCollector.translateToLocal("info.fbs.enchant.extFailure"), Enchantment.enchantmentsList[ep.id].getTranslatedName(ep.lv));
+ player.addChatComponentMessage(new ChatComponentText(str));
+ continue; //確率で失敗
+ }
+
+ //経験値
+ double exp=100 * ep.lv;
+ FBSEntityPropertiesAPI.AddExp(player, exp, true);
+
+ String str=String.format(StatCollector.translateToLocal("info.fbs.enchant.extSuccess"), Enchantment.enchantmentsList[ep.id].getTranslatedName(ep.lv));
+ str=str+String.format("(EXP+%.2f)", exp);
+ player.addChatComponentMessage(new ChatComponentText(str));
+
+ //ESの生成
+ ItemStack es = new ItemStack(ItemCore.enchantScroll);
+ LinkedHashMap ench = new LinkedHashMap();
+ ench.put(ep.id, ep.lv);
+ EnchantmentHelper.setEnchantments(ench, es);
+
+ player.entityDropItem(es, 0);
+ list.remove(index);
+
+ player.triggerAchievement(AchievementRegistry.extract);
+ }
+ }
+ }
+ }
+
+ for(int i=0;i<itemStacks.length;i++){
+ itemStacks[i]=null;
+ }
+ }
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
+ return p_70300_1_.worldObj.getBlockMetadata(x,y,z)>0;
+ }
+
+ @Override
+ public void openInventory() {
+
+ }
+
+ @Override
+ public void closeInventory() {
+ if(player.worldObj.isRemote) return;
+
+ for(int i=0;i<itemStacks.length;i++){
+ ItemStack itemstack = this.getStackInSlot(i);
+
+ if (itemstack != null){
+ float f = this.rand.nextFloat() * 0.8F + 0.1F;
+ float f1 = this.rand.nextFloat() * 0.8F + 0.1F;
+ float f2 = this.rand.nextFloat() * 0.8F + 0.1F;
+
+ while (itemstack.stackSize > 0){
+ int k1 = this.rand.nextInt(21) + 10;
+
+ if (k1 > itemstack.stackSize){
+ k1 = itemstack.stackSize;
+ }
+
+ itemstack.stackSize -= k1;
+ double x=player.posX+f;
+ double y=player.posY+f1+player.getEyeHeight();
+ double z=player.posZ+f2;
+ EntityItem entityitem = new EntityItem(player.worldObj, x, y, z, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
+
+ if (itemstack.hasTagCompound()){
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
+ }
+
+ float f3 = 0.05F;
+ entityitem.motionX = (double)((float)this.rand.nextGaussian() * f3);
+ entityitem.motionY = (double)((float)this.rand.nextGaussian() * f3 + 0.2F);
+ entityitem.motionZ = (double)((float)this.rand.nextGaussian() * f3);
+ player.worldObj.spawnEntityInWorld(entityitem);
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
+ return true;
+ }
+
+ public static class EnchantmentPair{
+ int id, lv;
+ public EnchantmentPair(int id, int lv){
+ this.id=id;
+ this.lv=lv;
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryContract.class b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryContract.class Binary files differnew file mode 100644 index 0000000..32eb9da --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryContract.class diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryContract.java b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryContract.java new file mode 100644 index 0000000..000df7f --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryContract.java @@ -0,0 +1,150 @@ +package jp.plusplus.fbs.container.inventory;
+
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.StatCollector;
+
+import java.util.Random;
+
+/**
+ * Created by plusplus_F on 2015/11/04.
+ */
+public class InventoryContract implements IInventory {
+ public EntityPlayer player;
+ public ItemStack[] itemStacks=new ItemStack[4];
+ protected Random rand=new Random();
+
+ public InventoryContract(EntityPlayer player){
+ this.player=player;
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return itemStacks.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int p_70301_1_) {
+ return itemStacks[p_70301_1_];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) {
+ if (this.itemStacks[p_70298_1_] != null) {
+ ItemStack itemstack;
+
+ if (this.itemStacks[p_70298_1_].stackSize <= p_70298_2_) {
+ itemstack = this.itemStacks[p_70298_1_];
+ this.itemStacks[p_70298_1_] = null;
+ this.markDirty();
+ return itemstack;
+ } else {
+ itemstack = this.itemStacks[p_70298_1_].splitStack(p_70298_2_);
+
+ if (this.itemStacks[p_70298_1_].stackSize == 0) {
+ this.itemStacks[p_70298_1_] = null;
+ }
+
+ this.markDirty();
+ return itemstack;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int p_70304_1_) {
+ if (this.itemStacks[p_70304_1_] != null) {
+ ItemStack itemstack = this.itemStacks[p_70304_1_];
+ this.itemStacks[p_70304_1_] = null;
+ return itemstack;
+ }
+ return null;
+ }
+
+ @Override
+ public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
+ this.itemStacks[p_70299_1_] = p_70299_2_;
+ if (p_70299_2_ != null && p_70299_2_.stackSize > this.getInventoryStackLimit()) {
+ p_70299_2_.stackSize = this.getInventoryStackLimit();
+ }
+ this.markDirty();
+ }
+
+ @Override
+ public String getInventoryName() {
+ return StatCollector.translateToLocal("book.fbs.contract.title");
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+
+ @Override
+ public void markDirty() {
+
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
+ return true;
+ }
+
+ @Override
+ public void openInventory() {
+
+ }
+
+ @Override
+ public void closeInventory() {
+ if(player.worldObj.isRemote) return;
+
+ for(int i=0;i<itemStacks.length;i++){
+ ItemStack itemstack = this.getStackInSlot(i);
+
+ if (itemstack != null){
+ float f = this.rand.nextFloat() * 0.8F + 0.1F;
+ float f1 = this.rand.nextFloat() * 0.8F + 0.1F;
+ float f2 = this.rand.nextFloat() * 0.8F + 0.1F;
+
+ while (itemstack.stackSize > 0){
+ int k1 = this.rand.nextInt(21) + 10;
+
+ if (k1 > itemstack.stackSize){
+ k1 = itemstack.stackSize;
+ }
+
+ itemstack.stackSize -= k1;
+ double x=player.posX+f;
+ double y=player.posY+f1+player.getEyeHeight();
+ double z=player.posZ+f2;
+ EntityItem entityitem = new EntityItem(player.worldObj, x, y, z, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
+
+ if (itemstack.hasTagCompound()){
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
+ }
+
+ float f3 = 0.05F;
+ entityitem.motionX = (double)((float)this.rand.nextGaussian() * f3);
+ entityitem.motionY = (double)((float)this.rand.nextGaussian() * f3 + 0.2F);
+ entityitem.motionZ = (double)((float)this.rand.nextGaussian() * f3);
+ player.worldObj.spawnEntityInWorld(entityitem);
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
+ return true;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryEnchantment.class b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryEnchantment.class Binary files differnew file mode 100644 index 0000000..8f4bd1a --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryEnchantment.class diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryEnchantment.java b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryEnchantment.java new file mode 100644 index 0000000..a66e844 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryEnchantment.java @@ -0,0 +1,158 @@ +package jp.plusplus.fbs.container.inventory;
+
+import jp.plusplus.fbs.block.BlockCore;
+import jp.plusplus.fbs.item.ItemCore;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.item.EntityXPOrb;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.StatCollector;
+import shift.mceconomy2.api.MCEconomyAPI;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Random;
+
+/**
+ * Created by plusplus_F on 2015/10/21.
+ */
+public class InventoryEnchantment implements IInventory {
+ public EntityPlayer player;
+ public ItemStack[] itemStacks=new ItemStack[3];
+ protected Random rand=new Random();
+
+ public InventoryEnchantment(EntityPlayer ep){
+ player=ep;
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return itemStacks.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int p_70301_1_) {
+ return itemStacks[p_70301_1_];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) {
+ if (this.itemStacks[p_70298_1_] != null) {
+ ItemStack itemstack;
+
+ if (this.itemStacks[p_70298_1_].stackSize <= p_70298_2_) {
+ itemstack = this.itemStacks[p_70298_1_];
+ this.itemStacks[p_70298_1_] = null;
+ this.markDirty();
+ return itemstack;
+ } else {
+ itemstack = this.itemStacks[p_70298_1_].splitStack(p_70298_2_);
+
+ if (this.itemStacks[p_70298_1_].stackSize == 0) {
+ this.itemStacks[p_70298_1_] = null;
+ }
+
+ this.markDirty();
+ return itemstack;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int p_70304_1_) {
+ if (this.itemStacks[p_70304_1_] != null) {
+ ItemStack itemstack = this.itemStacks[p_70304_1_];
+ this.itemStacks[p_70304_1_] = null;
+ return itemstack;
+ }
+ return null;
+ }
+
+ @Override
+ public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
+ this.itemStacks[p_70299_1_] = p_70299_2_;
+ if (p_70299_2_ != null && p_70299_2_.stackSize > this.getInventoryStackLimit()) {
+ p_70299_2_.stackSize = this.getInventoryStackLimit();
+ }
+ this.markDirty();
+ }
+
+ @Override
+ public String getInventoryName() {
+ return StatCollector.translateToLocal(ItemCore.enchantScroll.getUnlocalizedName()+".name");
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+
+ @Override
+ public void markDirty() {
+
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
+ return true;
+ }
+
+ @Override
+ public void openInventory() {
+
+ }
+
+ @Override
+ public void closeInventory() {
+ if(player.worldObj.isRemote) return;
+
+ for(int i=0;i<itemStacks.length;i++){
+ ItemStack itemstack = this.getStackInSlot(i);
+
+ if (itemstack != null){
+ float f = this.rand.nextFloat() * 0.8F + 0.1F;
+ float f1 = this.rand.nextFloat() * 0.8F + 0.1F;
+ float f2 = this.rand.nextFloat() * 0.8F + 0.1F;
+
+ while (itemstack.stackSize > 0){
+ int k1 = this.rand.nextInt(21) + 10;
+
+ if (k1 > itemstack.stackSize){
+ k1 = itemstack.stackSize;
+ }
+
+ itemstack.stackSize -= k1;
+ double x=player.posX+f;
+ double y=player.posY+f1+player.getEyeHeight();
+ double z=player.posZ+f2;
+ EntityItem entityitem = new EntityItem(player.worldObj, x, y, z, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
+
+ if (itemstack.hasTagCompound()){
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
+ }
+
+ float f3 = 0.05F;
+ entityitem.motionX = (double)((float)this.rand.nextGaussian() * f3);
+ entityitem.motionY = (double)((float)this.rand.nextGaussian() * f3 + 0.2F);
+ entityitem.motionZ = (double)((float)this.rand.nextGaussian() * f3);
+ player.worldObj.spawnEntityInWorld(entityitem);
+ }
+ }
+ }
+ }
+
+ public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
+ return true;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagic.class b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagic.class Binary files differnew file mode 100644 index 0000000..caca4b1 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagic.class diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagic.java b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagic.java new file mode 100644 index 0000000..7cdb62a --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagic.java @@ -0,0 +1,179 @@ +package jp.plusplus.fbs.container.inventory;
+
+import cpw.mods.fml.common.FMLLog;
+import jp.plusplus.fbs.container.ContainerMagic;
+import jp.plusplus.fbs.tileentity.TileEntityMagicCore;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.item.EntityXPOrb;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.inventory.SlotFurnace;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.ResourceLocation;
+
+import java.util.Random;
+
+/**
+ * Created by pluslus_F on 2015/06/18.
+ */
+public abstract class InventoryMagic implements IInventory {
+ public ItemStack[] itemStacks;
+ public TileEntityMagicCore magicCore;
+ public Random rand=new Random();
+ public EntityPlayer player;
+
+ public InventoryMagic(int size, TileEntityMagicCore te, EntityPlayer player){
+ itemStacks=new ItemStack[size];
+ magicCore=te;
+ this.player=player;
+ }
+
+ public abstract void work();
+ public abstract void onInventoryChanged(int index);
+ public abstract void addSlotToContainer(ContainerMagic cm);
+
+ public int getProgressScaled(int sc){
+ if(magicCore==null) return 0;
+ if(magicCore.progressMax==0) return 0;
+ return sc*magicCore.progress/magicCore.progressMax;
+ }
+
+ public abstract ResourceLocation getResource();
+ public int getProgressX(){ return 68;}
+ public int getProgressY(){ return 36;}
+
+ @Override
+ public int getSizeInventory() {
+ return itemStacks.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int p_70301_1_) {
+ return itemStacks[p_70301_1_];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) {
+ if (this.itemStacks[p_70298_1_] != null) {
+ ItemStack itemstack;
+
+ if (this.itemStacks[p_70298_1_].stackSize <= p_70298_2_) {
+ itemstack = this.itemStacks[p_70298_1_];
+ this.itemStacks[p_70298_1_] = null;
+ this.markDirty();
+ return itemstack;
+ } else {
+ itemstack = this.itemStacks[p_70298_1_].splitStack(p_70298_2_);
+
+ if (this.itemStacks[p_70298_1_].stackSize == 0) {
+ this.itemStacks[p_70298_1_] = null;
+ }
+
+ this.markDirty();
+ return itemstack;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int p_70304_1_) {
+ if (this.itemStacks[p_70304_1_] != null) {
+ ItemStack itemstack = this.itemStacks[p_70304_1_];
+ this.itemStacks[p_70304_1_] = null;
+ return itemstack;
+ }
+ return null;
+ }
+
+ @Override
+ public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
+ this.itemStacks[p_70299_1_] = p_70299_2_;
+ if (p_70299_2_ != null && p_70299_2_.stackSize > this.getInventoryStackLimit()) {
+ p_70299_2_.stackSize = this.getInventoryStackLimit();
+ }
+ this.markDirty();
+ }
+
+ @Override
+ public abstract String getInventoryName();
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 64;
+ }
+
+ @Override
+ public void markDirty() {
+
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
+ return true;
+ }
+
+ @Override
+ public void openInventory() {
+ if(magicCore!=null){
+ magicCore.setInventory(this);
+ //FMLLog.info("registered inventory");
+ }
+ }
+
+ @Override
+ public void closeInventory() {
+ if(magicCore!=null){
+ magicCore.removeInventory();
+ }
+
+ if(player.worldObj.isRemote) return;
+
+ for(int i=0;i<itemStacks.length;i++){
+ ItemStack itemstack = this.getStackInSlot(i);
+
+ if (itemstack != null){
+ float f = this.rand.nextFloat() * 0.8F + 0.1F;
+ float f1 = this.rand.nextFloat() * 0.8F + 0.1F;
+ float f2 = this.rand.nextFloat() * 0.8F + 0.1F;
+
+ while (itemstack.stackSize > 0){
+ int k1 = this.rand.nextInt(21) + 10;
+
+ if (k1 > itemstack.stackSize){
+ k1 = itemstack.stackSize;
+ }
+
+ itemstack.stackSize -= k1;
+ double x=player.posX+f;
+ double y=player.posY+f1+player.getEyeHeight();
+ double z=player.posZ+f2;
+ EntityItem entityitem = new EntityItem(player.worldObj, x, y, z, new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
+
+ if (itemstack.hasTagCompound()){
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
+ }
+
+ float f3 = 0.05F;
+ entityitem.motionX = (double)((float)this.rand.nextGaussian() * f3);
+ entityitem.motionY = (double)((float)this.rand.nextGaussian() * f3 + 0.2F);
+ entityitem.motionZ = (double)((float)this.rand.nextGaussian() * f3);
+ player.worldObj.spawnEntityInWorld(entityitem);
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
+ return true;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagicCopy.class b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagicCopy.class Binary files differnew file mode 100644 index 0000000..0c75b21 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagicCopy.class diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagicCopy.java b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagicCopy.java new file mode 100644 index 0000000..482ffc6 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagicCopy.java @@ -0,0 +1,108 @@ +package jp.plusplus.fbs.container.inventory;
+
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.container.ContainerMagic;
+import jp.plusplus.fbs.container.slot.SlotMagic;
+import jp.plusplus.fbs.container.slot.SlotMagicCopy;
+import jp.plusplus.fbs.container.slot.SlotMagicTakeOnly;
+import jp.plusplus.fbs.exprop.SanityManager;
+import jp.plusplus.fbs.item.ItemBookSorcery;
+import jp.plusplus.fbs.api.MagicBase;
+import jp.plusplus.fbs.tileentity.TileEntityMagicCore;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.ResourceLocation;
+
+/**
+ * Created by pluslus_F on 2015/06/18.
+ */
+public class InventoryMagicCopy extends InventoryMagic {
+ public static final ResourceLocation rl=new ResourceLocation(FBS.MODID, "textures/gui/magicCopy.png");
+
+ public InventoryMagicCopy(TileEntityMagicCore te, EntityPlayer player) {
+ super(4, te, player);
+ }
+
+ @Override
+ public void work() {
+ if(itemStacks[0]==null) return;
+
+ //コピー魔法が無かったら
+ MagicBase mb=Registry.GetMagic("fbs.copy").getMagic(this.player.worldObj, this.player, true);
+ if(mb==null) return;
+
+ boolean crm=player.capabilities.isCreativeMode;
+
+ if(crm || mb.checkSuccess()){
+ //クリエイティブか、魔法に成功すると
+ for(int i=1;i<3;i++){
+ if(itemStacks[i]==null){
+ itemStacks[i]=itemStacks[0].copy();
+ }
+ else if(itemStacks[i].isItemEqual(itemStacks[0])){
+ itemStacks[i].stackSize++;
+ }
+ }
+ }
+ else {
+ SanityManager.loseSanity(player, 2, 10, true);
+ if(itemStacks[1]==null) itemStacks[1]=itemStacks[0];
+ else if(itemStacks[1].isItemEqual(itemStacks[0])) itemStacks[1].stackSize++;
+ }
+
+ //魔導書の回数を減らす
+ if(itemStacks[3]!=null && !crm) ItemBookSorcery.reduceMagicMaxUse(itemStacks[3]);
+
+ itemStacks[0]=null;
+ onInventoryChanged(0);
+ }
+
+ @Override
+ public void onInventoryChanged(int index) {
+ //FMLLog.info("changed");
+
+ //増やしたいアイテムが無い場合、魔導書が無い場合進捗を無に帰す
+ if (itemStacks[0] == null || itemStacks[3] == null) {
+ magicCore.resetProgress();
+ //FMLLog.info("item null");
+ return;
+ }
+
+ //本がおかしくても進捗を無に帰す
+ Registry.BookData bd = Registry.GetBookDataFromItemStack(itemStacks[3]);
+ if (bd == null || !bd.title.equals("fbs.copy") || ItemBookSorcery.getMagicMaxUse(itemStacks[3]) <= 0) {
+ magicCore.resetProgress();
+ return;
+ }
+
+ //増やせそうにない場合も進捗を無に帰す
+ for (int i = 1; i < 3; i++) {
+ if (itemStacks[i] == null) continue;
+ if (!itemStacks[i].isItemEqual(itemStacks[0]) || itemStacks[i].stackSize + 1 > itemStacks[i].getMaxStackSize()) {
+ magicCore.resetProgress();
+ return;
+ }
+ }
+
+ //進捗の最大値を設定する
+ magicCore.setProgressMax(20 * 10);
+ }
+
+ @Override
+ public void addSlotToContainer(ContainerMagic cm) {
+ cm.addSlotToContainer(new SlotMagicCopy(this, 0, 44, 36));
+ cm.addSlotToContainer(new SlotMagicTakeOnly(this, 1, 103, 36));
+ cm.addSlotToContainer(new SlotMagicTakeOnly(this, 2, 129, 36));
+ cm.addSlotToContainer(new SlotMagic(this, 3, 72, 17));
+ }
+
+ @Override
+ public ResourceLocation getResource() {
+ return rl;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return Registry.GetLocalizedBookTitle("fbs.copy");
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagicTimeTrace.class b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagicTimeTrace.class Binary files differnew file mode 100644 index 0000000..3022a92 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagicTimeTrace.class diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagicTimeTrace.java b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagicTimeTrace.java new file mode 100644 index 0000000..352dcfb --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryMagicTimeTrace.java @@ -0,0 +1,135 @@ +package jp.plusplus.fbs.container.inventory;
+
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.api.MagicBase;
+import jp.plusplus.fbs.container.ContainerMagic;
+import jp.plusplus.fbs.container.slot.SlotMagic;
+import jp.plusplus.fbs.container.slot.SlotMagicCopy;
+import jp.plusplus.fbs.container.slot.SlotMagicTakeOnly;
+import jp.plusplus.fbs.container.slot.SlotMagicTimeTrace;
+import jp.plusplus.fbs.exprop.SanityManager;
+import jp.plusplus.fbs.item.ItemBookSorcery;
+import jp.plusplus.fbs.mod.ForIR3;
+import jp.plusplus.fbs.mod.ForSS2;
+import jp.plusplus.fbs.tileentity.TileEntityMagicCore;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+
+/**
+ * Created by plusplus_F on 2016/02/28.
+ */
+public class InventoryMagicTimeTrace extends InventoryMagic {
+ public static final ResourceLocation rl=new ResourceLocation(FBS.MODID, "textures/gui/magicProcessing.png");
+
+ public InventoryMagicTimeTrace(TileEntityMagicCore te, EntityPlayer player) {
+ super(4, te, player);
+ }
+
+ public float getRepairPercent(){
+ return 0.5f*rand.nextFloat();
+ }
+
+ @Override
+ public void work() {
+ if(itemStacks[0]==null) return;
+
+ //魔法が無かったら
+ MagicBase mb=Registry.GetMagic("fbs.timeTrace").getMagic(this.player.worldObj, this.player, true);
+ if(mb==null) return;
+
+ boolean crm=player.capabilities.isCreativeMode;
+ if(crm || mb.checkSuccess()){
+ //クリエイティブか、魔法に成功すると
+ SanityManager.loseSanity(player, 1, 10, true);
+
+ ItemStack itemStack=itemStacks[0].copy();
+ if(FBS.cooperatesIR3 && ForIR3.isCrystalUnit(itemStack)){
+ ForIR3.repairCrystalUnit(itemStack, getRepairPercent());
+ }
+ else if(FBS.cooperatesSS2 && ForSS2.canTimeTrace(itemStack)){
+ itemStack=ForSS2.getTimeTraced(itemStack);
+ }
+ else if(itemStack.getItem().isItemTool(itemStack)){
+ int d=itemStack.getItemDamage();
+ d=Math.max(0, d-(int)(itemStack.getMaxDamage()*getRepairPercent()));
+ itemStack.setItemDamage(d);
+ }
+
+ if(itemStacks[1]==null){
+ itemStacks[1]=itemStack;
+ }
+ else if(itemStacks[1].isItemEqual(itemStack) && itemStacks[1].stackSize+itemStack.stackSize<=itemStack.getMaxStackSize()){
+ itemStacks[1].stackSize+=itemStack.stackSize;
+ }
+ }
+ else {
+ SanityManager.loseSanity(player, 1, 10, true);
+ if(itemStacks[1]==null) itemStacks[1]=itemStacks[0];
+ else if(itemStacks[1].isItemEqual(itemStacks[0])) itemStacks[1].stackSize++;
+ }
+
+ //魔導書の回数を減らす
+ if(itemStacks[2]!=null && !crm) ItemBookSorcery.reduceMagicMaxUse(itemStacks[2]);
+
+ itemStacks[0]=null;
+ onInventoryChanged(0);
+ }
+
+ @Override
+ public void onInventoryChanged(int index) {
+ //増やしたいアイテムが無い場合、魔導書が無い場合進捗を無に帰す
+ if (itemStacks[0] == null || itemStacks[2] == null) {
+ magicCore.resetProgress();
+ //FMLLog.info("item null");
+ return;
+ }
+
+ //本がおかしくても進捗を無に帰す
+ Registry.BookData bd = Registry.GetBookDataFromItemStack(itemStacks[2]);
+ if (bd == null || !bd.title.equals("fbs.timeTrace") || ItemBookSorcery.getMagicMaxUse(itemStacks[2]) <= 0) {
+ magicCore.resetProgress();
+ return;
+ }
+
+ //処理できそうにない場合も進捗を無に帰す
+ ItemStack get=null;
+ ItemStack itemStack=itemStacks[0].copy();
+ if(FBS.cooperatesIR3 && ForIR3.isCrystalUnit(itemStack)){
+ get=itemStack;
+ }
+ else if(FBS.cooperatesSS2 && ForSS2.canTimeTrace(itemStack)){
+ get=ForSS2.getTimeTraced(itemStack);
+ }
+ else if(itemStack.getItem().isItemTool(itemStack)){
+ get=itemStack;
+ }
+
+ //変換できない・完成品スロットのアイテムが違う・完成品スロットのスタック数がmaxのとき、失敗
+ if(get==null || (itemStacks[1]!=null && (!itemStacks[1].isItemEqual(get) || itemStacks[1].stackSize+get.stackSize>itemStacks[1].getMaxStackSize()))){
+ magicCore.resetProgress();
+ return;
+ }
+
+ //進捗の最大値を設定する
+ magicCore.setProgressMax(20 * 3);
+ }
+
+ @Override
+ public void addSlotToContainer(ContainerMagic cm) {
+ cm.addSlotToContainer(new SlotMagicTimeTrace(this, 0, 44, 36));
+ cm.addSlotToContainer(new SlotMagicTakeOnly(this, 1, 103, 36));
+ cm.addSlotToContainer(new SlotMagic(this, 2, 72, 17));
+ }
+
+ @Override
+ public ResourceLocation getResource() {
+ return rl;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return Registry.GetLocalizedBookTitle("fbs.timeTrace");
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryStaff.class b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryStaff.class Binary files differnew file mode 100644 index 0000000..c20b0d3 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryStaff.class diff --git a/src/main/java/jp/plusplus/fbs/container/inventory/InventoryStaff.java b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryStaff.java new file mode 100644 index 0000000..35e6515 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/inventory/InventoryStaff.java @@ -0,0 +1,189 @@ +package jp.plusplus.fbs.container.inventory;
+
+import jp.plusplus.fbs.AchievementRegistry;
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.item.ItemCore;
+import jp.plusplus.fbs.item.ItemStaff;
+import jp.plusplus.fbs.api.IResonance;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.ChatComponentTranslation;
+
+/**
+ * Createdby pluslus_Fon 2015/06/15.
+ */
+public class InventoryStaff implements IInventory {
+ public ItemStack[] itemStacks;
+
+
+ protected InventoryPlayer inventoryPlayer;
+ protected ItemStack currentItem;
+ protected ItemStack[] items;
+ public int gemNum;
+ public int bookNum;
+
+ public InventoryStaff(InventoryPlayer inventory) {
+ inventoryPlayer = inventory;
+ currentItem = inventoryPlayer.getCurrentItem();
+
+ if (currentItem != null && currentItem.getItem() instanceof ItemStaff) {
+ gemNum = ((ItemStaff) currentItem.getItem()).gemNum;
+ }
+
+ //InventorySize
+ bookNum=((ItemStaff)currentItem.getItem()).bookNum;
+ items = new ItemStack[gemNum+bookNum];
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return items.length;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int slot) {
+ return items[slot];
+ }
+
+ @Override
+ public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) {
+ if (this.items[p_70298_1_] != null) {
+ ItemStack itemstack;
+
+ if (this.items[p_70298_1_].stackSize <= p_70298_2_) {
+ itemstack = this.items[p_70298_1_];
+ this.items[p_70298_1_] = null;
+ this.markDirty();
+ return itemstack;
+ } else {
+ itemstack = this.items[p_70298_1_].splitStack(p_70298_2_);
+
+ if (this.items[p_70298_1_].stackSize == 0) {
+ this.items[p_70298_1_] = null;
+ }
+
+ this.markDirty();
+ return itemstack;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int p_70304_1_) {
+ if (this.items[p_70304_1_] != null) {
+ ItemStack itemstack = this.items[p_70304_1_];
+ this.items[p_70304_1_] = null;
+ return itemstack;
+ }
+ return null;
+ }
+
+ @Override
+ public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) {
+ this.items[p_70299_1_] = p_70299_2_;
+ if (p_70299_2_ != null && p_70299_2_.stackSize > this.getInventoryStackLimit()) {
+ p_70299_2_.stackSize = this.getInventoryStackLimit();
+ }
+ this.markDirty();
+ }
+
+ @Override
+ public String getInventoryName() {
+ return currentItem.getDisplayName();
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 1;
+ }
+
+ @Override
+ public void markDirty() {
+ }
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
+ return true;
+ }
+
+ /*
+ Containerが開かれたタイミングでItemStackの持っているNBTからアイテムを読み込んでいる
+ */
+ @Override
+ public void openInventory() {
+ items=ItemStaff.loadInventory(currentItem);
+ }
+
+ /*
+ Containerを閉じるときに保存
+ */
+ @Override
+ public void closeInventory() {
+ ItemStack result = new ItemStack(currentItem.getItem(), 1, currentItem.getItemDamage());
+ ItemStaff.saveInventory(result, items);
+
+ //ItemStackをセットする。NBTは右クリック等のタイミングでしか保存されないため再セットで保存している。
+ inventoryPlayer.mainInventory[inventoryPlayer.currentItem] = result;
+
+ EntityPlayer p=inventoryPlayer.player;
+ if(!p.worldObj.isRemote) {
+ String n = result.getTagCompound().getString("MagicName");
+ if (n.equals("fbs.failure")){
+ p.addChatComponentMessage(new ChatComponentTranslation("info.fbs.magic.resona.failure"));
+ }
+ else if (Registry.IsResonance(n)){
+ p.addChatComponentMessage(new ChatComponentTranslation("info.fbs.magic.resona.success"));
+ p.triggerAchievement(AchievementRegistry.resonance);
+ }
+
+
+ if(bookNum>1) {
+ IResonance r=Registry.GetResonance(n);
+ if(r==null) return;
+
+ String[] books=new String[bookNum];
+ for(int i=0;i<bookNum;i++){
+ if(items[i]==null) continue;
+ books[i]=Registry.GetUnlocalizedBookTitleFromItemStack(items[i]);
+ }
+
+ String s = "";
+ int i = 0;
+ boolean find = false, find1=false;
+ for (; i < bookNum; i++) {
+ if (items[i] != null && items[i].getItem() == ItemCore.bookSorcery) {
+ s = ItemCore.bookNoDecoded.getLocalizedBookTitle(items[i]);
+ find = true;
+ break;
+ }
+ }
+ for (i++; i < bookNum; i++) {
+ if (items[i] != null && items[i].getItem() == ItemCore.bookSorcery) {
+ s += " + " + ItemCore.bookNoDecoded.getLocalizedBookTitle(items[i]);
+ find1 = true;
+ break;
+ }
+ }
+ if (find && find1) {
+ s += " -> " + r.getDisplayMagicName(books);
+ p.addChatComponentMessage(new ChatComponentText(s));
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int i, ItemStack item) {
+ if(item==null) return false;
+ return item.getItem()==ItemCore.bookSorcery;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotBonfire.class b/src/main/java/jp/plusplus/fbs/container/slot/SlotBonfire.class Binary files differnew file mode 100644 index 0000000..55fb95a --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotBonfire.class diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotBonfire.java b/src/main/java/jp/plusplus/fbs/container/slot/SlotBonfire.java new file mode 100644 index 0000000..876f09a --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotBonfire.java @@ -0,0 +1,46 @@ +package jp.plusplus.fbs.container.slot;
+
+import jp.plusplus.fbs.alchemy.AlchemyRegistry;
+import jp.plusplus.fbs.alchemy.IAlchemyMaterial;
+import net.minecraft.init.Items;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import shift.mceconomy2.api.MCEconomyAPI;
+
+/**
+ * Created by plusplus_F on 2015/10/31.
+ */
+public class SlotBonfire extends Slot{
+ protected int type;
+
+ public SlotBonfire(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int type) {
+ super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
+ this.type=type;
+ }
+
+ public boolean isItemValid(ItemStack itemStack) {
+ if(type==0){
+ //焼くもの
+ if(itemStack.isItemStackDamageable()){
+ ItemStack it = itemStack.copy();
+ it.setItemDamage(0);
+ return MCEconomyAPI.getPurchase(it) >= 0 || itemStack.isItemEnchanted();
+ }
+ else {
+ return MCEconomyAPI.getPurchase(itemStack)>=0 || itemStack.isItemEnchanted() || itemStack.getItem()== Items.enchanted_book;
+ }
+ }
+ if(type==1){
+ //ハーブ
+ Item item=itemStack.getItem();
+ if(!(item instanceof IAlchemyMaterial)) return false;
+ return AlchemyRegistry.IsMatching("herb", itemStack);
+ }
+
+ return true;
+ }
+
+
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotContract.class b/src/main/java/jp/plusplus/fbs/container/slot/SlotContract.class Binary files differnew file mode 100644 index 0000000..ee7d789 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotContract.class diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotContract.java b/src/main/java/jp/plusplus/fbs/container/slot/SlotContract.java new file mode 100644 index 0000000..673b886 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotContract.java @@ -0,0 +1,49 @@ +package jp.plusplus.fbs.container.slot;
+
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.alchemy.AlchemyRegistry;
+import jp.plusplus.fbs.alchemy.IAlchemyMaterial;
+import jp.plusplus.fbs.item.ItemBookSorcery;
+import jp.plusplus.fbs.item.ItemStoneSpirit;
+import jp.plusplus.fbs.spirit.SpiritManager;
+import net.minecraft.init.Items;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import shift.mceconomy2.api.MCEconomyAPI;
+
+/**
+ * Created by plusplus_F on 2015/11/04.
+ */
+public class SlotContract extends Slot{
+ protected int type;
+
+ public SlotContract(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int type) {
+ super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
+ this.type=type;
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack itemStack) {
+ if(type==0){
+ //武器
+ return SpiritManager.isTool(itemStack.getItem());
+ }
+ else if(type==1){
+ //精霊石
+ return itemStack.getItem() instanceof ItemStoneSpirit;
+ }
+ else if(type==2){
+ //書物
+ if(!(itemStack.getItem() instanceof ItemBookSorcery)) return false;
+ Registry.BookData bd=Registry.GetBookDataFromItemStack(itemStack);
+ if(bd==null) return false;
+ return bd.title.equals("fbs.contract");
+ }
+
+ return true;
+ }
+
+
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotCrafting.class b/src/main/java/jp/plusplus/fbs/container/slot/SlotCrafting.class Binary files differnew file mode 100644 index 0000000..8645c7a --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotCrafting.class diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotCrafting.java b/src/main/java/jp/plusplus/fbs/container/slot/SlotCrafting.java new file mode 100644 index 0000000..3e73133 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotCrafting.java @@ -0,0 +1,81 @@ +package jp.plusplus.fbs.container.slot;
+
+import cpw.mods.fml.common.FMLCommonHandler;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
+
+/**
+ * Createdby pluslus_Fon 2015/06/14.
+ */
+public class SlotCrafting extends Slot {
+ private EntityPlayer thePlayer;
+ private int amountCrafted;
+ private IInventory inventory;
+
+ public SlotCrafting(EntityPlayer player, IInventory p_i1823_3_, int p_i1823_4_, int p_i1823_5_, int p_i1823_6_) {
+ super(p_i1823_3_, p_i1823_4_, p_i1823_5_, p_i1823_6_);
+ this.thePlayer = player;
+ this.inventory=p_i1823_3_;
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack p_75214_1_)
+ {
+ return false;
+ }
+
+ @Override
+ public ItemStack decrStackSize(int p_75209_1_) {
+ if (this.getHasStack()) {
+ this.amountCrafted += Math.min(p_75209_1_, this.getStack().stackSize);
+ }
+ return super.decrStackSize(p_75209_1_);
+ }
+
+ @Override
+ protected void onCrafting(ItemStack p_75210_1_, int p_75210_2_) {
+ this.amountCrafted += p_75210_2_;
+ this.onCrafting(p_75210_1_);
+ }
+
+ @Override
+ protected void onCrafting(ItemStack p_75208_1_) {
+ p_75208_1_.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted);
+ this.amountCrafted = 0;
+ }
+
+ @Override
+ public void onPickupFromSlot(EntityPlayer p_82870_1_, ItemStack p_82870_2_) {
+ FMLCommonHandler.instance().firePlayerCraftingEvent(p_82870_1_, p_82870_2_, inventory);
+ this.onCrafting(p_82870_2_);
+
+ for (int i = 0; i < 9; ++i) {
+ ItemStack itemstack1 = inventory.getStackInSlot(i);
+
+ if (itemstack1 != null) {
+ inventory.decrStackSize(i, 1);
+
+ if (itemstack1.getItem().hasContainerItem(itemstack1)) {
+ ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1);
+
+ if (itemstack2 != null && itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage()) {
+ MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
+ continue;
+ }
+
+ if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)) {
+ if (inventory.getStackInSlot(i) == null) {
+ inventory.setInventorySlotContents(i, itemstack2);
+ } else {
+ this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false);
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotCraftingPottery.class b/src/main/java/jp/plusplus/fbs/container/slot/SlotCraftingPottery.class Binary files differnew file mode 100644 index 0000000..fe12dd8 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotCraftingPottery.class diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotCraftingPottery.java b/src/main/java/jp/plusplus/fbs/container/slot/SlotCraftingPottery.java new file mode 100644 index 0000000..2149c66 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotCraftingPottery.java @@ -0,0 +1,78 @@ +package jp.plusplus.fbs.container.slot;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
+
+/**
+ * Createdby pluslus_Fon 2015/08/29.
+ */
+public class SlotCraftingPottery extends Slot {
+ private EntityPlayer thePlayer;
+ private int amountCrafted;
+
+ public SlotCraftingPottery(EntityPlayer player, IInventory p_i1823_3_, int p_i1823_4_, int p_i1823_5_, int p_i1823_6_) {
+ super(p_i1823_3_, p_i1823_4_, p_i1823_5_, p_i1823_6_);
+ this.thePlayer = player;
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack p_75214_1_)
+ {
+ return false;
+ }
+
+ @Override
+ public ItemStack decrStackSize(int p_75209_1_) {
+ if (this.getHasStack()) {
+ this.amountCrafted += Math.min(p_75209_1_, this.getStack().stackSize);
+ }
+ return super.decrStackSize(p_75209_1_);
+ }
+
+ @Override
+ protected void onCrafting(ItemStack p_75210_1_, int p_75210_2_) {
+ this.amountCrafted += p_75210_2_;
+ this.onCrafting(p_75210_1_);
+ }
+
+ @Override
+ protected void onCrafting(ItemStack p_75208_1_) {
+ p_75208_1_.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted);
+ this.amountCrafted = 0;
+ }
+
+ @Override
+ public void onPickupFromSlot(EntityPlayer p_82870_1_, ItemStack p_82870_2_) {
+ //FMLCommonHandler.instance().firePlayerCraftingEvent(p_82870_1_, p_82870_2_, craftMatrix);
+ this.onCrafting(p_82870_2_);
+
+ for (int i = 0; i < 25; ++i) {
+ ItemStack itemstack1 = inventory.getStackInSlot(i);
+
+ if (itemstack1 != null) {
+ inventory.decrStackSize(i, 1);
+
+ if (itemstack1.getItem().hasContainerItem(itemstack1)) {
+ ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1);
+
+ if (itemstack2 != null && itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage()) {
+ MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2));
+ continue;
+ }
+
+ if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2)) {
+ if (inventory.getStackInSlot(i) == null) {
+ inventory.setInventorySlotContents(i, itemstack2);
+ } else {
+ this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false);
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotInventory.class b/src/main/java/jp/plusplus/fbs/container/slot/SlotInventory.class Binary files differnew file mode 100644 index 0000000..d489ee4 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotInventory.class diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotInventory.java b/src/main/java/jp/plusplus/fbs/container/slot/SlotInventory.java new file mode 100644 index 0000000..76a7c5a --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotInventory.java @@ -0,0 +1,49 @@ +package jp.plusplus.fbs.container.slot;
+
+import jp.plusplus.fbs.alchemy.AlchemyRegistry;
+import jp.plusplus.fbs.alchemy.IAlchemyMaterial;
+import jp.plusplus.fbs.alchemy.IAlchemyProduct;
+import jp.plusplus.fbs.item.ItemBookSorcery;
+import jp.plusplus.fbs.item.ItemCore;
+import jp.plusplus.fbs.item.ItemStaff;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.OreDictionary;
+
+import java.util.ArrayList;
+
+/**
+ * Createdby pluslus_Fon 2015/06/15.
+ */
+public class SlotInventory extends Slot {
+ private int type;//0 book, 1 charm,book, 2 inv, 3 alchemy
+ public SlotInventory(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int type) {
+ super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
+ this.type=type;
+ }
+
+
+ public boolean isItemValid(ItemStack p_75214_1_) {
+ if (type == 0) return p_75214_1_.getItem() == ItemCore.bookSorcery;
+ if (type == 1){
+ ArrayList<ItemStack> list=OreDictionary.getOres("fbs.charm");
+ for(ItemStack item : list){
+ if(OreDictionary.itemMatches(item, p_75214_1_, false)) return true;
+ }
+ return false;
+ }
+ if(type==3){
+ Item it=p_75214_1_.getItem();
+ return it instanceof IAlchemyMaterial || it instanceof IAlchemyProduct || AlchemyRegistry.isBasketItem(p_75214_1_);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean canTakeStack(EntityPlayer p_82869_1_) {
+ return !(getHasStack() && getStack().getItem() instanceof ItemStaff);
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotMagic.class b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagic.class Binary files differnew file mode 100644 index 0000000..28c1683 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagic.class diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotMagic.java b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagic.java new file mode 100644 index 0000000..b437a68 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagic.java @@ -0,0 +1,20 @@ +package jp.plusplus.fbs.container.slot;
+
+import jp.plusplus.fbs.container.inventory.InventoryMagic;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Created by pluslus_F on 2015/06/18.
+ */
+public class SlotMagic extends Slot {
+ public SlotMagic(InventoryMagic p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) {
+ super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
+ }
+
+ @Override
+ public void onSlotChanged(){
+ super.onSlotChanged();
+ ((InventoryMagic)inventory).onInventoryChanged(getSlotIndex());
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicCopy.class b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicCopy.class Binary files differnew file mode 100644 index 0000000..65d9a01 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicCopy.class diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicCopy.java b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicCopy.java new file mode 100644 index 0000000..f0ed794 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicCopy.java @@ -0,0 +1,25 @@ +package jp.plusplus.fbs.container.slot;
+
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.container.inventory.InventoryMagic;
+import jp.plusplus.fbs.mod.ForSS2;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Created by pluslus_F on 2015/06/18.
+ */
+public class SlotMagicCopy extends SlotMagic {
+ public SlotMagicCopy(InventoryMagic p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) {
+ super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack p_75214_1_) {
+ return p_75214_1_.getMaxStackSize()>1;
+ }
+ @Override
+ public int getSlotStackLimit()
+ {
+ return 1;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicTakeOnly.class b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicTakeOnly.class Binary files differnew file mode 100644 index 0000000..c855f2e --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicTakeOnly.class diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicTakeOnly.java b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicTakeOnly.java new file mode 100644 index 0000000..0316492 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicTakeOnly.java @@ -0,0 +1,20 @@ +package jp.plusplus.fbs.container.slot;
+
+import jp.plusplus.fbs.container.inventory.InventoryMagic;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Createdby pluslus_Fon 2015/06/18.
+ */
+public class SlotMagicTakeOnly extends SlotMagic{
+ public SlotMagicTakeOnly(InventoryMagic p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) {
+ super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack item){
+ return false;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicTimeTrace.class b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicTimeTrace.class Binary files differnew file mode 100644 index 0000000..94e315a --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicTimeTrace.class diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicTimeTrace.java b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicTimeTrace.java new file mode 100644 index 0000000..a5ef88b --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotMagicTimeTrace.java @@ -0,0 +1,28 @@ +package jp.plusplus.fbs.container.slot;
+
+import jp.plusplus.fbs.FBS;
+import jp.plusplus.fbs.container.inventory.InventoryMagic;
+import jp.plusplus.fbs.mod.ForSS2;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Created by pluslus_F on 2015/02/28.
+ */
+public class SlotMagicTimeTrace extends SlotMagic {
+ public SlotMagicTimeTrace(InventoryMagic p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) {
+ super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack p_75214_1_) {
+ if(FBS.cooperatesSS2 && ForSS2.canTimeTrace(p_75214_1_)){
+ return true;
+ }
+ return p_75214_1_.getItem().isItemTool(p_75214_1_);
+ }
+ @Override
+ public int getSlotStackLimit()
+ {
+ return 64;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotShowOnly.class b/src/main/java/jp/plusplus/fbs/container/slot/SlotShowOnly.class Binary files differnew file mode 100644 index 0000000..02ee690 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotShowOnly.class diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotShowOnly.java b/src/main/java/jp/plusplus/fbs/container/slot/SlotShowOnly.java new file mode 100644 index 0000000..14f6be3 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotShowOnly.java @@ -0,0 +1,25 @@ +package jp.plusplus.fbs.container.slot;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Created by plusplus_F on 2015/02/06.
+ */
+public class SlotShowOnly extends Slot {
+ public SlotShowOnly(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) {
+ super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack item){
+ return false;
+ }
+
+ @Override
+ public boolean canTakeStack(EntityPlayer p_82869_1_) {
+ return false;
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotTakeOnly.class b/src/main/java/jp/plusplus/fbs/container/slot/SlotTakeOnly.class Binary files differnew file mode 100644 index 0000000..81c8e61 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotTakeOnly.class diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotTakeOnly.java b/src/main/java/jp/plusplus/fbs/container/slot/SlotTakeOnly.java new file mode 100644 index 0000000..4476bb4 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotTakeOnly.java @@ -0,0 +1,53 @@ +package jp.plusplus.fbs.container.slot;
+
+import cpw.mods.fml.common.FMLCommonHandler;
+import jp.plusplus.fbs.AchievementRegistry;
+import jp.plusplus.fbs.api.IPottery;
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Createdby pluslus_Fon 2015/06/08.
+ */
+public class SlotTakeOnly extends Slot{
+ protected int achievement;
+
+ public SlotTakeOnly(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_) {
+ this(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_, 0);
+ }
+ public SlotTakeOnly(IInventory p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int achievement){
+ super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
+ this.achievement=achievement;
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack item){
+ return false;
+ }
+
+ @Override
+ public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
+ Item item=stack.getItem();
+ if(achievement==1){
+ if(item instanceof ItemBlock){
+ Block b=((ItemBlock) item).field_150939_a;
+ if(b instanceof IPottery){
+ player.triggerAchievement(AchievementRegistry.grade);
+ if(((IPottery) b).getGrade(stack.getTagCompound())== IPottery.PotteryGrade.SOULFUL){
+ player.triggerAchievement(AchievementRegistry.soulful);
+ }
+ }
+ }
+ }
+ else if(achievement==2){
+ FMLCommonHandler.instance().firePlayerCraftingEvent(player, stack, null);
+ }
+
+ super.onPickupFromSlot(player, stack);
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotTakeOnlyWithMagicEXP.class b/src/main/java/jp/plusplus/fbs/container/slot/SlotTakeOnlyWithMagicEXP.class Binary files differnew file mode 100644 index 0000000..24aae06 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotTakeOnlyWithMagicEXP.class diff --git a/src/main/java/jp/plusplus/fbs/container/slot/SlotTakeOnlyWithMagicEXP.java b/src/main/java/jp/plusplus/fbs/container/slot/SlotTakeOnlyWithMagicEXP.java new file mode 100644 index 0000000..dd6f2a8 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/slot/SlotTakeOnlyWithMagicEXP.java @@ -0,0 +1,65 @@ +package jp.plusplus.fbs.container.slot;
+
+import cpw.mods.fml.common.FMLCommonHandler;
+import jp.plusplus.fbs.AchievementRegistry;
+import jp.plusplus.fbs.alchemy.AlchemyRegistry;
+import jp.plusplus.fbs.api.FBSEntityPropertiesAPI;
+import net.minecraft.entity.item.EntityXPOrb;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Items;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.inventory.SlotFurnace;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.crafting.FurnaceRecipes;
+import net.minecraft.stats.AchievementList;
+import net.minecraft.util.MathHelper;
+
+/**
+ * Created by plusplus_F on 2015/10/31.
+ */
+public class SlotTakeOnlyWithMagicEXP extends Slot {
+ protected EntityPlayer thePlayer;
+ protected int achievement;
+
+ public SlotTakeOnlyWithMagicEXP(EntityPlayer p_i1813_1_, IInventory p_i1813_2_, int p_i1813_3_, int p_i1813_4_, int p_i1813_5_) {
+ this(p_i1813_1_, p_i1813_2_, p_i1813_3_, p_i1813_4_, p_i1813_5_, 0);
+ }
+ public SlotTakeOnlyWithMagicEXP(EntityPlayer p_i1813_1_, IInventory p_i1813_2_, int p_i1813_3_, int p_i1813_4_, int p_i1813_5_, int achievement) {
+ super(p_i1813_2_, p_i1813_3_, p_i1813_4_, p_i1813_5_);
+ this.thePlayer = p_i1813_1_;
+ this.achievement=achievement;
+ }
+
+ public boolean isItemValid(ItemStack p_75214_1_) {
+ return false;
+ }
+
+ public ItemStack decrStackSize(int p_75209_1_) {
+ return super.decrStackSize(p_75209_1_);
+ }
+
+ public void onPickupFromSlot(EntityPlayer p_82870_1_, ItemStack p_82870_2_) {
+ this.onCrafting(p_82870_2_);
+ if(achievement==1){
+ p_82870_1_.triggerAchievement(AchievementRegistry.alchemy);
+ }
+ super.onPickupFromSlot(p_82870_1_, p_82870_2_);
+ }
+
+ protected void onCrafting(ItemStack p_75210_1_, int p_75210_2_) {
+ this.onCrafting(p_75210_1_);
+ }
+
+ protected void onCrafting(ItemStack p_75208_1_) {
+ p_75208_1_.onCrafting(this.thePlayer.worldObj, this.thePlayer, 1);
+
+ if (!this.thePlayer.worldObj.isRemote) {
+ double baseEXP = AlchemyRegistry.GetProductExp(p_75208_1_);
+
+ if(baseEXP>0){
+ FBSEntityPropertiesAPI.AddExp(thePlayer, baseEXP, true);
+ }
+ }
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/spirit/ContainerSpiritLearn.class b/src/main/java/jp/plusplus/fbs/container/spirit/ContainerSpiritLearn.class Binary files differnew file mode 100644 index 0000000..aa90a90 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/spirit/ContainerSpiritLearn.class diff --git a/src/main/java/jp/plusplus/fbs/container/spirit/ContainerSpiritLearn.java b/src/main/java/jp/plusplus/fbs/container/spirit/ContainerSpiritLearn.java new file mode 100644 index 0000000..79a0747 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/spirit/ContainerSpiritLearn.java @@ -0,0 +1,50 @@ +package jp.plusplus.fbs.container.spirit;
+
+import jp.plusplus.fbs.container.slot.SlotShowOnly;
+import jp.plusplus.fbs.spirit.ISpiritTool;
+import jp.plusplus.fbs.spirit.SkillManager;
+import jp.plusplus.fbs.spirit.SpiritManager;
+import jp.plusplus.fbs.spirit.SpiritStatus;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Created by plusplus_F on 2015/11/29.
+ */
+public class ContainerSpiritLearn extends Container {
+ public EntityPlayer player;
+ public ItemStack spiritTool;
+ public SpiritStatus status;
+
+ public ContainerSpiritLearn(EntityPlayer player){
+ this.player=player;
+ spiritTool= SpiritManager.findSpiritTool(player);
+ status=SpiritStatus.readFromNBT(spiritTool.getTagCompound());
+
+ for (int j = 0; j < 9; ++j) {
+ ItemStack is=player.inventory.getStackInSlot(j);
+ if(is!=null && is.getItem() instanceof ISpiritTool) this.addSlotToContainer(new SlotShowOnly(player.inventory, j, 8 + j * 18, 142));
+ else this.addSlotToContainer(new Slot(player.inventory, j, 8 + j * 18, 142));
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer p_75145_1_) {
+ return true;
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) {
+ ItemStack itemstack = null;
+ return itemstack;
+ }
+
+ public void learn(String skill){
+ int now=status.getSkillLevel(skill);
+ status.reduceSkillPoint();
+ status.setSkill(skill, now+1);
+ SpiritManager.updateNBT(spiritTool, status);
+ }
+}
diff --git a/src/main/java/jp/plusplus/fbs/container/spirit/ContainerSpiritMain.class b/src/main/java/jp/plusplus/fbs/container/spirit/ContainerSpiritMain.class Binary files differnew file mode 100644 index 0000000..3044b68 --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/spirit/ContainerSpiritMain.class diff --git a/src/main/java/jp/plusplus/fbs/container/spirit/ContainerSpiritMain.java b/src/main/java/jp/plusplus/fbs/container/spirit/ContainerSpiritMain.java new file mode 100644 index 0000000..e84327f --- /dev/null +++ b/src/main/java/jp/plusplus/fbs/container/spirit/ContainerSpiritMain.java @@ -0,0 +1,40 @@ +package jp.plusplus.fbs.container.spirit;
+
+import jp.plusplus.fbs.container.slot.SlotInventory;
+import jp.plusplus.fbs.container.slot.SlotShowOnly;
+import jp.plusplus.fbs.spirit.ISpiritTool;
+import jp.plusplus.fbs.spirit.SpiritManager;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Created by plusplus_F on 2015/11/15.
+ */
+public class ContainerSpiritMain extends Container{
+ public EntityPlayer player;
+ public int type;
+
+ public ContainerSpiritMain(EntityPlayer player, int type){
+ this.player=player;
+ this.type=type;
+
+ for (int j = 0; j < 9; ++j) {
+ ItemStack is=player.inventory.getStackInSlot(j);
+ if(is!=null && is.getItem() instanceof ISpiritTool) this.addSlotToContainer(new SlotShowOnly(player.inventory, j, 8 + j * 18, 142));
+ else this.addSlotToContainer(new Slot(player.inventory, j, 8 + j * 18, 142));
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer p_75145_1_) {
+ return true;
+ }
+
+ @Override
+ public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) {
+ ItemStack itemstack = null;
+ return itemstack;
+ }
+}
|
