Worked on the Alchemy Table - final push for -35

This commit is contained in:
WayofTime 2016-05-02 08:27:38 -04:00
parent bc7760b11b
commit 7116e3775e
9 changed files with 268 additions and 43 deletions

View file

@ -7,6 +7,8 @@ Version 2.0.0-35
- Changed it so that the Mending enchantment consumes the EXP before the Tome of Peritia does - Changed it so that the Mending enchantment consumes the EXP before the Tome of Peritia does
- Added fall distance mitigation to the jump upgrade - Added fall distance mitigation to the jump upgrade
- Fixed Lava Crystals... again. - Fixed Lava Crystals... again.
- Worked on the Alchemy Table
- Added the Elytra upgrade - craft the tome in an anvil by using a book and a full Elytra.
------------------------------------------------------ ------------------------------------------------------
Version 2.0.0-34 Version 2.0.0-34

View file

@ -128,6 +128,7 @@ public class Constants
public static final int SOUL_FORGE_GUI = 1; public static final int SOUL_FORGE_GUI = 1;
public static final int ROUTING_NODE_GUI = 2; public static final int ROUTING_NODE_GUI = 2;
public static final int MASTER_ROUTING_NODE_GUI = 3; public static final int MASTER_ROUTING_NODE_GUI = 3;
public static final int ALCHEMY_TABLE_GUI = 4;
} }
public static class Compat public static class Compat

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.block; package WayofTime.bloodmagic.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
@ -7,10 +8,13 @@ import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -112,43 +116,54 @@ public class BlockAlchemyTable extends BlockContainer
return new TileAlchemyTable(); return new TileAlchemyTable();
} }
// @Override @Override
// public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
// { {
// TileDemonCrucible crucible = (TileDemonCrucible) world.getTileEntity(pos); BlockPos position = pos;
// TileEntity tile = world.getTileEntity(pos);
// if (crucible == null || player.isSneaking()) if (tile instanceof TileAlchemyTable)
// return false; {
// if (((TileAlchemyTable) tile).isSlave())
// if (heldItem != null) {
// { position = ((TileAlchemyTable) tile).getConnectedPos();
// if (!(heldItem.getItem() instanceof IDiscreteDemonWill) && !(heldItem.getItem() instanceof IDemonWillGem)) tile = world.getTileEntity(position);
// { if (!(tile instanceof TileAlchemyTable))
// return false; {
// } return false;
// } }
// }
// Utils.insertItemToTile(crucible, player); }
//
// world.notifyBlockUpdate(pos, state, state, 3); player.openGui(BloodMagic.instance, Constants.Gui.ALCHEMY_TABLE_GUI, world, position.getX(), position.getY(), position.getZ());
// return true;
// } return true;
}
@Override @Override
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) public void breakBlock(World world, BlockPos pos, IBlockState blockState)
{ {
TileAlchemyTable tile = (TileAlchemyTable) world.getTileEntity(blockPos); TileAlchemyTable tile = (TileAlchemyTable) world.getTileEntity(pos);
if (tile != null) if (tile != null && !tile.isSlave())
{
tile.dropItems(); tile.dropItems();
}
super.breakBlock(world, blockPos, blockState); super.breakBlock(world, pos, blockState);
}
@Override
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock)
{
TileAlchemyTable tile = (TileAlchemyTable) world.getTileEntity(pos);
if (tile != null)
{
BlockPos connectedPos = tile.getConnectedPos();
TileEntity connectedTile = world.getTileEntity(connectedPos);
if (!(connectedTile instanceof TileAlchemyTable && ((TileAlchemyTable) connectedTile).getConnectedPos().equals(pos)))
{
this.breakBlock(world, pos, state);
world.setBlockToAir(pos);
}
}
} }
//
// @Override
// public List<Pair<Integer, String>> getVariants()
// {
// List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
// ret.add(new ImmutablePair<Integer, String>(0, "normal"));
// return ret;
// }
} }

View file

@ -0,0 +1,54 @@
package WayofTime.bloodmagic.client.gui;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.tile.container.ContainerAlchemyTable;
import WayofTime.bloodmagic.util.helper.TextHelper;
@SideOnly(Side.CLIENT)
public class GuiAlchemyTable extends GuiContainer
{
public IInventory tileTable;
public GuiAlchemyTable(InventoryPlayer playerInventory, IInventory tileTable)
{
super(new ContainerAlchemyTable(playerInventory, tileTable));
this.tileTable = tileTable;
this.xSize = 176;
this.ySize = 205;
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
this.fontRendererObj.drawString(TextHelper.localize("tile.BloodMagic.alchemyTable.name"), 8, 5, 4210752);
this.fontRendererObj.drawString(TextHelper.localize("container.inventory"), 8, 111, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
ResourceLocation soulForgeGuiTextures = new ResourceLocation(Constants.Mod.MODID + ":textures/gui/alchemyTable.png");
this.mc.getTextureManager().bindTexture(soulForgeGuiTextures);
int i = (this.width - this.xSize) / 2;
int j = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
int l = this.getCookProgressScaled(90);
this.drawTexturedModalRect(i + 115, j + 14 + 90 - l, 176, 90 - l, 18, l);
}
public int getCookProgressScaled(int scale)
{
// double progress = ((TileAlchemyTable) tileTable).getProgressForGui();
// return (int) (progress * scale);
return scale / 2;
}
}

View file

@ -1,19 +1,21 @@
package WayofTime.bloodmagic.client.gui; package WayofTime.bloodmagic.client.gui;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;
import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.tile.TileAlchemyTable;
import WayofTime.bloodmagic.tile.TileSoulForge; import WayofTime.bloodmagic.tile.TileSoulForge;
import WayofTime.bloodmagic.tile.TileTeleposer; import WayofTime.bloodmagic.tile.TileTeleposer;
import WayofTime.bloodmagic.tile.container.ContainerAlchemyTable;
import WayofTime.bloodmagic.tile.container.ContainerItemRoutingNode; import WayofTime.bloodmagic.tile.container.ContainerItemRoutingNode;
import WayofTime.bloodmagic.tile.container.ContainerMasterRoutingNode; import WayofTime.bloodmagic.tile.container.ContainerMasterRoutingNode;
import WayofTime.bloodmagic.tile.container.ContainerSoulForge; import WayofTime.bloodmagic.tile.container.ContainerSoulForge;
import WayofTime.bloodmagic.tile.container.ContainerTeleposer; import WayofTime.bloodmagic.tile.container.ContainerTeleposer;
import WayofTime.bloodmagic.tile.routing.TileFilteredRoutingNode; import WayofTime.bloodmagic.tile.routing.TileFilteredRoutingNode;
import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode; import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;
public class GuiHandler implements IGuiHandler public class GuiHandler implements IGuiHandler
{ {
@ -32,6 +34,8 @@ public class GuiHandler implements IGuiHandler
return new ContainerItemRoutingNode(player.inventory, (TileFilteredRoutingNode) world.getTileEntity(pos)); return new ContainerItemRoutingNode(player.inventory, (TileFilteredRoutingNode) world.getTileEntity(pos));
case Constants.Gui.MASTER_ROUTING_NODE_GUI: case Constants.Gui.MASTER_ROUTING_NODE_GUI:
return new ContainerMasterRoutingNode(player.inventory, (TileMasterRoutingNode) world.getTileEntity(pos)); return new ContainerMasterRoutingNode(player.inventory, (TileMasterRoutingNode) world.getTileEntity(pos));
case Constants.Gui.ALCHEMY_TABLE_GUI:
return new ContainerAlchemyTable(player.inventory, (TileAlchemyTable) world.getTileEntity(pos));
} }
return null; return null;
@ -54,6 +58,8 @@ public class GuiHandler implements IGuiHandler
return new GuiItemRoutingNode(player.inventory, (TileFilteredRoutingNode) world.getTileEntity(pos)); return new GuiItemRoutingNode(player.inventory, (TileFilteredRoutingNode) world.getTileEntity(pos));
case Constants.Gui.MASTER_ROUTING_NODE_GUI: case Constants.Gui.MASTER_ROUTING_NODE_GUI:
return new GuiMasterRoutingNode(player.inventory, (TileMasterRoutingNode) world.getTileEntity(pos)); return new GuiMasterRoutingNode(player.inventory, (TileMasterRoutingNode) world.getTileEntity(pos));
case Constants.Gui.ALCHEMY_TABLE_GUI:
return new GuiAlchemyTable(player.inventory, (TileAlchemyTable) world.getTileEntity(pos));
} }
} }

View file

@ -38,9 +38,14 @@ public class ItemBlockAlchemyTable extends ItemBlock
// newState = block.getDefaultState().withProperty(BlockAlchemyTable.DIRECTION, direction).withProperty(BlockAlchemyTable.INVISIBLE, true); // newState = block.getDefaultState().withProperty(BlockAlchemyTable.DIRECTION, direction).withProperty(BlockAlchemyTable.INVISIBLE, true);
if (!world.setBlockState(pos, newState, 3)) if (!world.setBlockState(pos, newState, 3))
{
return false; return false;
}
world.setBlockState(pos.offset(direction), Blocks.LAPIS_BLOCK.getDefaultState()); if (!world.setBlockState(pos.offset(direction), newState, 3))
{
return false;
}
IBlockState state = world.getBlockState(pos); IBlockState state = world.getBlockState(pos);
if (state.getBlock() == this.block) if (state.getBlock() == this.block)
@ -50,6 +55,13 @@ public class ItemBlockAlchemyTable extends ItemBlock
{ {
((TileAlchemyTable) tile).setInitialTableParameters(direction, false, pos.offset(direction)); ((TileAlchemyTable) tile).setInitialTableParameters(direction, false, pos.offset(direction));
} }
TileEntity slaveTile = world.getTileEntity(pos.offset(direction));
if (slaveTile instanceof TileAlchemyTable)
{
((TileAlchemyTable) slaveTile).setInitialTableParameters(direction, true, pos);
}
setTileEntityNBT(world, player, pos, stack); setTileEntityNBT(world, player, pos, stack);
this.block.onBlockPlacedBy(world, pos, state, player, stack); this.block.onBlockPlacedBy(world, pos, state, player, stack);
} }

View file

@ -12,6 +12,10 @@ import WayofTime.bloodmagic.api.Constants;
@Getter @Getter
public class TileAlchemyTable extends TileInventory implements ISidedInventory, ITickable public class TileAlchemyTable extends TileInventory implements ISidedInventory, ITickable
{ {
public static final int orbSlot = 6;
public static final int toolSlot = 7;
public static final int outputSlot = 8;
public EnumFacing direction = EnumFacing.NORTH; public EnumFacing direction = EnumFacing.NORTH;
public boolean isSlave = false; public boolean isSlave = false;
@ -19,7 +23,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
public TileAlchemyTable() public TileAlchemyTable()
{ {
super(1, "alchemyTable"); super(9, "alchemyTable");
} }
public void setInitialTableParameters(EnumFacing direction, boolean isSlave, BlockPos connectedPos) public void setInitialTableParameters(EnumFacing direction, boolean isSlave, BlockPos connectedPos)
@ -55,9 +59,9 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
tag.setBoolean("isSlave", isSlave); tag.setBoolean("isSlave", isSlave);
tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex()); tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex());
tag.setInteger(Constants.NBT.X_COORD, pos.getX()); tag.setInteger(Constants.NBT.X_COORD, connectedPos.getX());
tag.setInteger(Constants.NBT.Y_COORD, pos.getY()); tag.setInteger(Constants.NBT.Y_COORD, connectedPos.getY());
tag.setInteger(Constants.NBT.Z_COORD, pos.getZ()); tag.setInteger(Constants.NBT.Z_COORD, connectedPos.getZ());
} }
@Override @Override

View file

@ -0,0 +1,131 @@
package WayofTime.bloodmagic.tile.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import WayofTime.bloodmagic.api.orb.IBloodOrb;
import WayofTime.bloodmagic.tile.TileAlchemyTable;
public class ContainerAlchemyTable extends Container
{
private final IInventory tileTable;
public ContainerAlchemyTable(InventoryPlayer inventoryPlayer, IInventory tileTable)
{
this.tileTable = tileTable;
this.addSlotToContainer(new Slot(tileTable, 0, 62, 15));
this.addSlotToContainer(new Slot(tileTable, 1, 80, 51));
this.addSlotToContainer(new Slot(tileTable, 2, 62, 87));
this.addSlotToContainer(new Slot(tileTable, 3, 26, 87));
this.addSlotToContainer(new Slot(tileTable, 4, 8, 51));
this.addSlotToContainer(new Slot(tileTable, 5, 26, 15));
this.addSlotToContainer(new Slot(tileTable, TileAlchemyTable.toolSlot, 152, 33));
this.addSlotToContainer(new SlotOrb(tileTable, TileAlchemyTable.orbSlot, 152, 69));
this.addSlotToContainer(new SlotOutput(tileTable, TileAlchemyTable.outputSlot, 44, 51));
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 9; j++)
{
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 123 + i * 18));
}
}
for (int i = 0; i < 9; i++)
{
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 181));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index)
{
ItemStack itemstack = null;
Slot slot = this.inventorySlots.get(index);
if (slot != null && slot.getHasStack())
{
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (index == 8)
{
if (!this.mergeItemStack(itemstack1, 9, 9 + 36, true))
{
return null;
}
slot.onSlotChange(itemstack1, itemstack);
} else if (index > 8)
{
if (itemstack1.getItem() instanceof IBloodOrb)
{
if (!this.mergeItemStack(itemstack1, 7, 8, false)) //TODO: Add alchemy tools to list
{
return null;
}
} else if (!this.mergeItemStack(itemstack1, 0, 6, false))
{
return null;
}
} else if (!this.mergeItemStack(itemstack1, 9, 9 + 36, false))
{
return null;
}
if (itemstack1.stackSize == 0)
{
slot.putStack(null);
} else
{
slot.onSlotChanged();
}
if (itemstack1.stackSize == itemstack.stackSize)
{
return null;
}
slot.onPickupFromSlot(playerIn, itemstack1);
}
return itemstack;
}
@Override
public boolean canInteractWith(EntityPlayer playerIn)
{
return this.tileTable.isUseableByPlayer(playerIn);
}
private class SlotOrb extends Slot
{
public SlotOrb(IInventory inventory, int slotIndex, int x, int y)
{
super(inventory, slotIndex, x, y);
}
@Override
public boolean isItemValid(ItemStack itemStack)
{
return itemStack.getItem() instanceof IBloodOrb;
}
}
private class SlotOutput extends Slot
{
public SlotOutput(IInventory inventory, int slotIndex, int x, int y)
{
super(inventory, slotIndex, x, y);
}
@Override
public boolean isItemValid(ItemStack stack)
{
return false;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB