Worked on Soul Forge GUI and container. GUI texture is VERY WIP and the slot locations as well as the progress par will change. Don't work on it >:3

This commit is contained in:
WayofTime 2016-01-07 18:05:23 -05:00
parent 8b024e1703
commit fec2236114
8 changed files with 232 additions and 6 deletions
src/main
java/WayofTime/bloodmagic
resources/assets/bloodmagic/textures/gui

View file

@ -92,6 +92,7 @@ public class Constants
public static final class Gui
{
public static final int TELEPOSER_GUI = 0;
public static final int SOUL_FORGE_GUI = 1;
}
public static class Compat

View file

@ -1,11 +1,20 @@
package WayofTime.bloodmagic.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.tile.TileSoulForge;
import WayofTime.bloodmagic.tile.TileTeleposer;
public class BlockSoulForge extends Block
public class BlockSoulForge extends BlockContainer
{
public BlockSoulForge()
{
@ -15,7 +24,7 @@ public class BlockSoulForge extends Block
setHardness(2.0F);
setResistance(5.0F);
setStepSound(soundTypeMetal);
setHarvestLevel("pickaxe", 2);
setHarvestLevel("pickaxe", 1);
setCreativeTab(BloodMagic.tabBloodMagic);
}
@ -42,4 +51,32 @@ public class BlockSoulForge extends Block
{
return 3;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (world.getTileEntity(pos) instanceof TileSoulForge)
{
player.openGui(BloodMagic.instance, Constants.Gui.SOUL_FORGE_GUI, world, pos.getX(), pos.getY(), pos.getZ());
}
return true;
}
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
if (worldIn.getTileEntity(pos) != null && worldIn.getTileEntity(pos) instanceof TileTeleposer)
{
InventoryHelper.dropInventoryItems(worldIn, pos, (TileTeleposer) worldIn.getTileEntity(pos));
}
super.breakBlock(worldIn, pos, state);
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta)
{
return new TileSoulForge();
}
}

View file

@ -1,13 +1,15 @@
package WayofTime.bloodmagic.client.gui;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.tile.TileTeleposer;
import WayofTime.bloodmagic.tile.container.ContainerTeleposer;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.tile.TileSoulForge;
import WayofTime.bloodmagic.tile.TileTeleposer;
import WayofTime.bloodmagic.tile.container.ContainerSoulForge;
import WayofTime.bloodmagic.tile.container.ContainerTeleposer;
public class GuiHandler implements IGuiHandler
{
@ -20,6 +22,8 @@ public class GuiHandler implements IGuiHandler
{
case Constants.Gui.TELEPOSER_GUI:
return new ContainerTeleposer(player.inventory, (TileTeleposer) world.getTileEntity(pos));
case Constants.Gui.SOUL_FORGE_GUI:
return new ContainerSoulForge(player.inventory, (TileSoulForge) world.getTileEntity(pos));
}
return null;
@ -36,6 +40,8 @@ public class GuiHandler implements IGuiHandler
{
case Constants.Gui.TELEPOSER_GUI:
return new GuiTeleposer(player.inventory, (TileTeleposer) world.getTileEntity(pos));
case Constants.Gui.SOUL_FORGE_GUI:
return new GuiSoulForge(player.inventory, (TileSoulForge) world.getTileEntity(pos));
}
}

View file

@ -0,0 +1,51 @@
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.minecraft.util.StatCollector;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.tile.container.ContainerSoulForge;
import WayofTime.bloodmagic.util.helper.TextHelper;
@SideOnly(Side.CLIENT)
public class GuiSoulForge extends GuiContainer
{
public GuiSoulForge(InventoryPlayer playerInventory, IInventory tileTeleposer)
{
super(new ContainerSoulForge(playerInventory, tileTeleposer));
this.xSize = 176;
this.ySize = 157;
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
this.fontRendererObj.drawString(TextHelper.localize("tile.BloodMagic.soulForge.name"), 64, 23, 4210752);
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, 47, 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/soulForge.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(36);
this.drawTexturedModalRect(i + 79, j + 32, 176, 0, l, 18);
}
public int getCookProgressScaled(int scale)
{
double progress = 1;
return (int) (progress * scale);
}
}

View file

@ -65,6 +65,7 @@ public class ModBlocks
GameRegistry.registerTileEntity(TileSpectralBlock.class, Constants.Mod.MODID + ":" + TileSpectralBlock.class.getSimpleName());
GameRegistry.registerTileEntity(TilePhantomBlock.class, Constants.Mod.MODID + ":" + TilePhantomBlock.class.getSimpleName());
GameRegistry.registerTileEntity(TileTeleposer.class, Constants.Mod.MODID + ":" + TileTeleposer.class.getSimpleName());
GameRegistry.registerTileEntity(TileSoulForge.class, Constants.Mod.MODID + ":" + TileSoulForge.class.getSimpleName());
}
public static void initRenders()

View file

@ -0,0 +1,30 @@
package WayofTime.bloodmagic.tile;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ITickable;
public class TileSoulForge extends TileInventory implements ITickable
{
public TileSoulForge()
{
super(6, "soulForge");
}
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
}
@Override
public void writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
}
@Override
public void update()
{
}
}

View file

@ -0,0 +1,100 @@
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.soul.ISoul;
import WayofTime.bloodmagic.api.soul.ISoulGem;
import WayofTime.bloodmagic.item.ItemTelepositionFocus;
public class ContainerSoulForge extends Container
{
private final IInventory tileForge;
public ContainerSoulForge(InventoryPlayer inventoryPlayer, IInventory tileForge)
{
this.tileForge = tileForge;
this.addSlotToContainer(new SlotSoul(tileForge, 0, 152, 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, 75 + i * 18));
}
}
for (int i = 0; i < 9; i++)
{
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 133));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot)
{
ItemStack stack = null;
Slot slotObject = inventorySlots.get(slot);
int slots = inventorySlots.size();
if (slotObject != null && slotObject.getHasStack())
{
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
if (stack.getItem() instanceof ItemTelepositionFocus)
{
if (slot <= slots)
{
if (!this.mergeItemStack(stackInSlot, 0, slots, false))
{
return null;
}
} else if (!this.mergeItemStack(stackInSlot, slots, 36 + slots, false))
{
return null;
}
}
if (stackInSlot.stackSize == 0)
{
slotObject.putStack(null);
} else
{
slotObject.onSlotChanged();
}
if (stackInSlot.stackSize == stack.stackSize)
{
return null;
}
slotObject.onPickupFromSlot(player, stackInSlot);
}
return stack;
}
@Override
public boolean canInteractWith(EntityPlayer playerIn)
{
return this.tileForge.isUseableByPlayer(playerIn);
}
private class SlotSoul extends Slot
{
public SlotSoul(IInventory inventory, int slotIndex, int x, int y)
{
super(inventory, slotIndex, x, y);
}
@Override
public boolean isItemValid(ItemStack itemStack)
{
return itemStack.getItem() instanceof ISoulGem || itemStack.getItem() instanceof ISoul;
}
}
}

Binary file not shown.

After

(image error) Size: 1.7 KiB