mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 07:13:28 +01:00
Fireplace and Crucible fully working
This commit is contained in:
parent
74831f14a4
commit
79b2abefca
30 changed files with 645 additions and 150 deletions
|
@ -1,35 +1,30 @@
|
|||
package ellpeck.gemification;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.*;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import ellpeck.gemification.blocks.InitBlocks;
|
||||
import ellpeck.gemification.container.GuiHandler;
|
||||
import ellpeck.gemification.crafting.CrucibleCraftingManager;
|
||||
import ellpeck.gemification.gen.OreGen;
|
||||
import ellpeck.gemification.inventory.GuiHandler;
|
||||
import ellpeck.gemification.items.InitItems;
|
||||
import ellpeck.gemification.proxy.IProxy;
|
||||
import ellpeck.gemification.tile.TileEntityCrucible;
|
||||
import ellpeck.gemification.tile.TileEntityBase;
|
||||
import ellpeck.gemification.util.Util;
|
||||
|
||||
@Mod(modid = Gemification.MOD_ID, name = Gemification.NAME, version = Gemification.VERSION)
|
||||
public class Gemification {
|
||||
@Mod(modid = Util.MOD_ID, name = Util.NAME, version = Util.VERSION)
|
||||
public class Gemification{
|
||||
|
||||
@Instance(Gemification.MOD_ID)
|
||||
@Instance(Util.MOD_ID)
|
||||
public static Gemification instance;
|
||||
|
||||
@SidedProxy(clientSide = "ellpeck.gemification.proxy.ClientProxy", serverSide = "ellpeck.gemification.proxy.ServerProxy")
|
||||
public static IProxy proxy;
|
||||
|
||||
public static final String MOD_ID = "gemification";
|
||||
public static final String NAME = "Gemification";
|
||||
public static final String VERSION = "1.7.10-1.0.1";
|
||||
|
||||
public static final int guiCrucible = 0;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler()
|
||||
public void preInit(FMLPreInitializationEvent event){
|
||||
|
@ -43,9 +38,9 @@ public class Gemification {
|
|||
public void init(FMLInitializationEvent event){
|
||||
CrucibleCraftingManager.instance.initRecipes();
|
||||
proxy.init();
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
||||
GameRegistry.registerWorldGenerator(new OreGen(), 0);
|
||||
GameRegistry.registerTileEntity(TileEntityCrucible.class, Gemification.MOD_ID + "tileEntityCrucible");
|
||||
GuiHandler.init();
|
||||
OreGen.init();
|
||||
TileEntityBase.init();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package ellpeck.gemification.blocks;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import ellpeck.gemification.CreativeTab;
|
||||
import ellpeck.gemification.Gemification;
|
||||
import ellpeck.gemification.Util;
|
||||
import ellpeck.gemification.creative.CreativeTab;
|
||||
import ellpeck.gemification.inventory.GuiHandler;
|
||||
import ellpeck.gemification.tile.TileEntityCrucible;
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -12,7 +13,6 @@ import net.minecraft.client.renderer.texture.IIconRegister;
|
|||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -35,12 +35,7 @@ public class BlockCrucible extends BlockContainer{
|
|||
@SuppressWarnings("static-access")
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){
|
||||
if (!world.isRemote){
|
||||
TileEntityCrucible tileCrucible = (TileEntityCrucible)world.getTileEntity(x, y, z);
|
||||
if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.water_bucket && tileCrucible.currentFluid == Util.fluidNone){
|
||||
tileCrucible.currentFluid = Util.fluidWater;
|
||||
if(!player.capabilities.isCreativeMode) player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.bucket));
|
||||
}
|
||||
else player.openGui(Gemification.instance, Gemification.guiCrucible, world, x, y, z);
|
||||
player.openGui(Gemification.instance, GuiHandler.guiCrucible, world, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
package ellpeck.gemification.blocks;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.gemification.Gemification;
|
||||
import ellpeck.gemification.creative.CreativeTab;
|
||||
import ellpeck.gemification.inventory.GuiHandler;
|
||||
import ellpeck.gemification.tile.TileEntityCrucibleFire;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockCrucibleFire extends BlockContainer{
|
||||
|
||||
protected BlockCrucibleFire(){
|
||||
super(Material.rock);
|
||||
this.setBlockName("blockCrucibleFire");
|
||||
this.setCreativeTab(CreativeTab.instance);
|
||||
this.setTickRandomly(true);
|
||||
}
|
||||
|
||||
public TileEntity createNewTileEntity(World world, int i){
|
||||
return new TileEntityCrucibleFire();
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){
|
||||
if (!world.isRemote){
|
||||
player.openGui(Gemification.instance, GuiHandler.guiCrucibleFire, world, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getRenderType(){
|
||||
return RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean renderAsNormalBlock(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public void registerBlockIcons(IIconRegister iconReg){
|
||||
this.blockIcon = Blocks.hopper.getIcon(0, 0);
|
||||
}
|
||||
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int meta){
|
||||
this.dropInventory(world, x, y, z);
|
||||
super.breakBlock(world, x, y, z, block, meta);
|
||||
}
|
||||
|
||||
public void dropInventory(World world, int x, int y, int z){
|
||||
TileEntityCrucibleFire tileEntity = (TileEntityCrucibleFire)world.getTileEntity(x, y, z);
|
||||
for (int i = 0; i < tileEntity.getSizeInventory(); i++){
|
||||
ItemStack itemStack = tileEntity.getStackInSlot(i);
|
||||
if (itemStack != null && itemStack.stackSize > 0){
|
||||
Random rand = new Random();
|
||||
float dX = rand.nextFloat() * 0.8F + 0.1F;
|
||||
float dY = rand.nextFloat() * 0.8F + 0.1F;
|
||||
float dZ = rand.nextFloat() * 0.8F + 0.1F;
|
||||
EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, itemStack.copy());
|
||||
if(itemStack.hasTagCompound()) entityItem.getEntityItem().setTagCompound((NBTTagCompound)itemStack.getTagCompound().copy());
|
||||
float factor = 0.05F;
|
||||
entityItem.motionX = rand.nextGaussian() * factor;
|
||||
entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
|
||||
entityItem.motionZ = rand.nextGaussian() * factor;
|
||||
world.spawnEntityInWorld(entityItem);
|
||||
itemStack.stackSize = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(World world, int x, int y, int z, Random rand){
|
||||
if(((TileEntityCrucibleFire)world.getTileEntity(x, y, z)).isBurning()){
|
||||
for(int i = 0; i < 8; i++){
|
||||
world.spawnParticle("flame", (double) x + rand.nextFloat() * 0.5F + 0.25F, (double) y + 0.55F, (double) z + rand.nextFloat() * 0.5F + 0.25F, 0.0D, 0.0D, 0.0D);
|
||||
world.spawnParticle("smoke", (double) x + rand.nextFloat() * 0.5F + 0.25F, (double) y + 0.55F, (double) z + rand.nextFloat() * 0.5F + 0.25F, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,14 +7,17 @@ public class InitBlocks{
|
|||
|
||||
public static Block oreGem;
|
||||
public static Block blockCrucible;
|
||||
public static Block blockCrucibleFire;
|
||||
|
||||
public static void init(){
|
||||
|
||||
oreGem = new OreGem();
|
||||
blockCrucible = new BlockCrucible();
|
||||
blockCrucibleFire = new BlockCrucibleFire();
|
||||
|
||||
GameRegistry.registerBlock(oreGem, ItemBlockOreGem.class, oreGem.getUnlocalizedName().substring(5));
|
||||
GameRegistry.registerBlock(blockCrucible, ItemBlockCrucible.class, blockCrucible.getUnlocalizedName().substring(5));
|
||||
GameRegistry.registerBlock(blockCrucibleFire, ItemBlockCrucibleFire.class, blockCrucibleFire.getUnlocalizedName().substring(5));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package ellpeck.gemification.blocks;
|
|||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.gemification.Util;
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package ellpeck.gemification.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBlockCrucibleFire extends ItemBlock {
|
||||
|
||||
public ItemBlockCrucibleFire(Block block){
|
||||
super(block);
|
||||
setHasSubtypes(false);
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return this.getUnlocalizedName();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
||||
if(Util.isShiftPressed()) list.add(StatCollector.translateToLocal("tooltip." + this.getUnlocalizedName().substring(5) + ".desc"));
|
||||
else list.add(Util.shiftForInfo());
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ package ellpeck.gemification.blocks;
|
|||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.gemification.Util;
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
|
|
@ -2,10 +2,9 @@ package ellpeck.gemification.blocks;
|
|||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.gemification.CreativeTab;
|
||||
import ellpeck.gemification.Gemification;
|
||||
import ellpeck.gemification.Util;
|
||||
import ellpeck.gemification.creative.CreativeTab;
|
||||
import ellpeck.gemification.items.InitItems;
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
@ -58,7 +57,7 @@ public class OreGem extends Block{
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconReg) {
|
||||
for (int i = 0; i < Util.gemList.size(); i++) {
|
||||
textures[i] = iconReg.registerIcon(Gemification.MOD_ID + ":" + this.getUnlocalizedName().substring(5) + Util.gemList.get(i).name.substring(5));
|
||||
textures[i] = iconReg.registerIcon(Util.MOD_ID + ":" + this.getUnlocalizedName().substring(5) + Util.gemList.get(i).name.substring(5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package ellpeck.gemification.blocks.models;
|
||||
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
public class ModelCrucibleFire extends ModelBaseG{
|
||||
public ModelRenderer floor, wallOne, wallTwo, wallThree, wallFour, supportOne, supportTwo, supportThree, supportFour, outsideSupOne, outsideSupTwo, outsideSupThree, outsideSupFour, topFloor, floorBlock;
|
||||
|
||||
public ModelCrucibleFire() {
|
||||
this.textureWidth = 64;
|
||||
this.textureHeight = 64;
|
||||
this.wallFour = new ModelRenderer(this, 0, 0);
|
||||
this.wallFour.setRotationPoint(-4.5F, 15.0F, 4.5F);
|
||||
this.wallFour.addBox(0.0F, 0.0F, 0.0F, 9, 3, 1);
|
||||
this.outsideSupFour = new ModelRenderer(this, 0, 30);
|
||||
this.outsideSupFour.setRotationPoint(-8.0F, 9.0F, 6.0F);
|
||||
this.outsideSupFour.addBox(0.0F, 0.0F, 0.0F, 2, 15, 2);
|
||||
this.supportFour = new ModelRenderer(this, 0, 0);
|
||||
this.supportFour.setRotationPoint(3.5F, 19.0F, -4.5F);
|
||||
this.supportFour.addBox(0.0F, 0.0F, 0.0F, 1, 2, 1);
|
||||
this.outsideSupThree = new ModelRenderer(this, 0, 30);
|
||||
this.outsideSupThree.setRotationPoint(-8.0F, 9.0F, -8.0F);
|
||||
this.outsideSupThree.addBox(0.0F, 0.0F, 0.0F, 2, 15, 2);
|
||||
this.outsideSupOne = new ModelRenderer(this, 0, 30);
|
||||
this.outsideSupOne.setRotationPoint(6.0F, 9.0F, 6.0F);
|
||||
this.outsideSupOne.addBox(0.0F, 0.0F, 0.0F, 2, 15, 2);
|
||||
this.floorBlock = new ModelRenderer(this, 0, 17);
|
||||
this.floorBlock.setRotationPoint(-5.0F, 21.0F, -5.0F);
|
||||
this.floorBlock.addBox(0.0F, 0.0F, 0.0F, 10, 3, 10);
|
||||
this.wallOne = new ModelRenderer(this, 0, 0);
|
||||
this.wallOne.setRotationPoint(4.5F, 15.0F, -5.5F);
|
||||
this.wallOne.addBox(0.0F, 0.0F, 0.0F, 1, 3, 11);
|
||||
this.wallTwo = new ModelRenderer(this, 0, 0);
|
||||
this.wallTwo.setRotationPoint(-5.5F, 15.0F, -5.5F);
|
||||
this.wallTwo.addBox(0.0F, 0.0F, 0.0F, 1, 3, 11);
|
||||
this.supportOne = new ModelRenderer(this, 0, 0);
|
||||
this.supportOne.setRotationPoint(3.5F, 19.0F, 3.5F);
|
||||
this.supportOne.addBox(0.0F, 0.0F, 0.0F, 1, 2, 1);
|
||||
this.wallThree = new ModelRenderer(this, 0, 0);
|
||||
this.wallThree.setRotationPoint(-4.5F, 15.0F, -5.5F);
|
||||
this.wallThree.addBox(0.0F, 0.0F, 0.0F, 9, 3, 1);
|
||||
this.outsideSupTwo = new ModelRenderer(this, 0, 30);
|
||||
this.outsideSupTwo.setRotationPoint(6.0F, 9.0F, -8.0F);
|
||||
this.outsideSupTwo.addBox(0.0F, 0.0F, 0.0F, 2, 15, 2);
|
||||
this.floor = new ModelRenderer(this, 0, 0);
|
||||
this.floor.mirror = true;
|
||||
this.floor.setRotationPoint(-4.5F, 18.0F, -4.5F);
|
||||
this.floor.addBox(0.0F, 0.0F, 0.0F, 9, 1, 9);
|
||||
this.supportThree = new ModelRenderer(this, 0, 0);
|
||||
this.supportThree.setRotationPoint(-4.5F, 19.0F, -4.5F);
|
||||
this.supportThree.addBox(0.0F, 0.0F, 0.0F, 1, 2, 1);
|
||||
this.topFloor = new ModelRenderer(this, 0, 30);
|
||||
this.topFloor.setRotationPoint(-8.0F, 8.0F, -8.0F);
|
||||
this.topFloor.addBox(0.0F, 0.0F, 0.0F, 16, 1, 16);
|
||||
this.supportTwo = new ModelRenderer(this, 0, 0);
|
||||
this.supportTwo.setRotationPoint(-4.5F, 19.0F, 3.5F);
|
||||
this.supportTwo.addBox(0.0F, 0.0F, 0.0F, 1, 2, 1);
|
||||
}
|
||||
|
||||
public void render(float f){
|
||||
this.wallFour.render(f);
|
||||
this.outsideSupFour.render(f);
|
||||
this.supportFour.render(f);
|
||||
this.outsideSupThree.render(f);
|
||||
this.outsideSupOne.render(f);
|
||||
this.floorBlock.render(f);
|
||||
this.wallOne.render(f);
|
||||
this.wallTwo.render(f);
|
||||
this.supportOne.render(f);
|
||||
this.wallThree.render(f);
|
||||
this.outsideSupTwo.render(f);
|
||||
this.floor.render(f);
|
||||
this.supportThree.render(f);
|
||||
this.topFloor.render(f);
|
||||
this.supportTwo.render(f);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package ellpeck.gemification.blocks.models;
|
||||
|
||||
import ellpeck.gemification.Gemification;
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -8,7 +8,7 @@ import org.lwjgl.opengl.GL11;
|
|||
|
||||
public class RendererCrucible extends TileEntitySpecialRenderer{
|
||||
|
||||
public static final ResourceLocation resLoc = new ResourceLocation(Gemification.MOD_ID, "textures/blocks/models/modelCrucible.png");
|
||||
public static final ResourceLocation resLoc = new ResourceLocation(Util.MOD_ID, "textures/blocks/models/modelCrucible.png");
|
||||
private ModelCrucible model;
|
||||
|
||||
public RendererCrucible(){
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package ellpeck.gemification.blocks.models;
|
||||
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RendererCrucibleFire extends TileEntitySpecialRenderer{
|
||||
|
||||
public static final ResourceLocation resLoc = new ResourceLocation(Util.MOD_ID, "textures/blocks/models/modelCrucibleFire.png");
|
||||
private ModelCrucibleFire model;
|
||||
|
||||
public RendererCrucibleFire(){
|
||||
this.model = new ModelCrucibleFire();
|
||||
}
|
||||
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par5) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
|
||||
GL11.glRotatef(180, 0F, 0F, 1F);
|
||||
this.bindTexture(resLoc);
|
||||
GL11.glPushMatrix();
|
||||
this.model.render(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package ellpeck.gemification.container;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import ellpeck.gemification.Gemification;
|
||||
import ellpeck.gemification.tile.TileEntityCrucible;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
|
||||
public Object getServerGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z) {
|
||||
switch (id) {
|
||||
case Gemification.guiCrucible:
|
||||
TileEntityCrucible tileCrucible = (TileEntityCrucible) world.getTileEntity(x, y, z);
|
||||
return new ContainerCrucible(entityPlayer.inventory, tileCrucible);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getClientGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z) {
|
||||
switch (id) {
|
||||
case Gemification.guiCrucible:
|
||||
TileEntityCrucible tileCrucible = (TileEntityCrucible) world.getTileEntity(x, y, z);
|
||||
return new GuiCrucible(entityPlayer.inventory, tileCrucible);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
package ellpeck.gemification.crafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import ellpeck.gemification.GemType;
|
||||
import ellpeck.gemification.Util;
|
||||
import ellpeck.gemification.util.GemType;
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class CrucibleCraftingManager{
|
||||
|
||||
public static final CrucibleCraftingManager instance = new CrucibleCraftingManager();
|
||||
|
@ -72,38 +72,45 @@ public class CrucibleCraftingManager{
|
|||
stack2[i1] = null;
|
||||
}
|
||||
}
|
||||
|
||||
this.recipes.add(new CrucibleRecipe(stack2, output, fluidNeeded, processTimeNeeded));
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public ItemStack getCraftingResult(ItemStack[] slots, int minSlot, int maxSlot, GemType currentFluid){
|
||||
for (CrucibleRecipe recipe : this.recipes) {
|
||||
ItemStack[] inputs = recipe.recipeItems;
|
||||
int k = 0;
|
||||
for (int j = 0; j < maxSlot - minSlot + 1; j++) {
|
||||
if (slots[minSlot + j] != null && inputs[j] != null && slots[minSlot + j].getItem() == inputs[j].getItem()){
|
||||
if(inputs[j].getItemDamage() == 32767 || inputs[j].getItemDamage() == slots[minSlot + j].getItemDamage()) {
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (k == maxSlot - minSlot + 1) {
|
||||
if(currentFluid == recipe.fluidNeeded) {
|
||||
return recipe.recipeOutput;
|
||||
}
|
||||
CrucibleRecipe matchingRecipe = this.matchingRecipe(slots, minSlot, maxSlot);
|
||||
if(matchingRecipe != null){
|
||||
if (currentFluid == matchingRecipe.fluidNeeded){
|
||||
return matchingRecipe.recipeOutput;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public int getProcessTimeNeeded(ItemStack stack){
|
||||
for(CrucibleRecipe recipe : this.recipes){
|
||||
if(recipe.recipeOutput == stack){
|
||||
return recipe.processTimeNeeded;
|
||||
}
|
||||
public int getProcessTimeNeeded(ItemStack[] slots, int minSlot, int maxSlot){
|
||||
CrucibleRecipe matchingRecipe = this.matchingRecipe(slots, minSlot, maxSlot);
|
||||
if(matchingRecipe != null){
|
||||
return matchingRecipe.processTimeNeeded;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public CrucibleRecipe matchingRecipe(ItemStack[] slots, int minSlot, int maxSlot){
|
||||
for (CrucibleRecipe recipe : this.recipes){
|
||||
ItemStack[] inputs = recipe.recipeItems;
|
||||
int k = 0;
|
||||
for (int j = 0; j < maxSlot - minSlot + 1; j++){
|
||||
if (slots[minSlot + j] != null && inputs[j] != null && slots[minSlot + j].getItem() == inputs[j].getItem()){
|
||||
if(inputs[j].getItemDamage() == 32767 || inputs[j].getItemDamage() == slots[minSlot + j].getItemDamage()) {
|
||||
k++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (k == maxSlot - minSlot + 1){
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package ellpeck.gemification.crafting;
|
||||
|
||||
import ellpeck.gemification.GemType;
|
||||
import ellpeck.gemification.util.GemType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class CrucibleRecipe{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ellpeck.gemification;
|
||||
package ellpeck.gemification.creative;
|
||||
|
||||
import ellpeck.gemification.blocks.InitBlocks;
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
|
@ -9,7 +10,7 @@ public class CreativeTab extends CreativeTabs{
|
|||
public static CreativeTab instance = new CreativeTab();
|
||||
|
||||
public CreativeTab(){
|
||||
super(Gemification.MOD_ID);
|
||||
super(Util.MOD_ID);
|
||||
}
|
||||
|
||||
public Item getTabIconItem() {
|
|
@ -1,7 +1,9 @@
|
|||
package ellpeck.gemification;
|
||||
package ellpeck.gemification.gen;
|
||||
|
||||
import cpw.mods.fml.common.IWorldGenerator;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import ellpeck.gemification.blocks.InitBlocks;
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -48,4 +50,8 @@ public class OreGen implements IWorldGenerator {
|
|||
(new WorldGenMinable(block, meta, maxVeinSize, blockIn)).generate(world, random, posX, posY, posZ);
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(){
|
||||
GameRegistry.registerWorldGenerator(new OreGen(), 0);
|
||||
}
|
||||
}
|
50
src/main/java/ellpeck/gemification/inventory/GuiHandler.java
Normal file
50
src/main/java/ellpeck/gemification/inventory/GuiHandler.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
package ellpeck.gemification.inventory;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import ellpeck.gemification.Gemification;
|
||||
import ellpeck.gemification.inventory.container.ContainerCrucible;
|
||||
import ellpeck.gemification.inventory.container.ContainerCrucibleFire;
|
||||
import ellpeck.gemification.inventory.gui.GuiCrucible;
|
||||
import ellpeck.gemification.inventory.gui.GuiCrucibleFire;
|
||||
import ellpeck.gemification.tile.TileEntityBase;
|
||||
import ellpeck.gemification.tile.TileEntityCrucible;
|
||||
import ellpeck.gemification.tile.TileEntityCrucibleFire;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
|
||||
public static final int guiCrucible = 0;
|
||||
public static final int guiCrucibleFire = 1;
|
||||
|
||||
public Object getServerGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z) {
|
||||
TileEntityBase tile = (TileEntityBase)world.getTileEntity(x, y, z);
|
||||
switch (id) {
|
||||
case guiCrucible:
|
||||
return new ContainerCrucible(entityPlayer.inventory, (TileEntityCrucible)tile);
|
||||
case guiCrucibleFire:
|
||||
return new ContainerCrucibleFire(entityPlayer.inventory, (TileEntityCrucibleFire)tile);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getClientGuiElement(int id, EntityPlayer entityPlayer, World world, int x, int y, int z) {
|
||||
TileEntityBase tile = (TileEntityBase)world.getTileEntity(x, y, z);
|
||||
switch (id) {
|
||||
case guiCrucible:
|
||||
return new GuiCrucible(entityPlayer.inventory, (TileEntityCrucible)tile);
|
||||
case guiCrucibleFire:
|
||||
return new GuiCrucibleFire(entityPlayer.inventory, (TileEntityCrucibleFire)tile);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(){
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(Gemification.instance, new GuiHandler());
|
||||
}
|
||||
}
|
|
@ -1,11 +1,14 @@
|
|||
package ellpeck.gemification.container;
|
||||
package ellpeck.gemification.inventory.container;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.gemification.tile.TileEntityCrucible;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotFurnace;
|
||||
|
||||
public class ContainerCrucible extends Container {
|
||||
|
||||
|
@ -14,6 +17,8 @@ public class ContainerCrucible extends Container {
|
|||
private int lastCurrentFluidID;
|
||||
private int lastProcessTime;
|
||||
private int lastProcessTimeNeeded;
|
||||
private int lastBurnTime;
|
||||
private int lastBurnTimeOfItem;
|
||||
|
||||
public ContainerCrucible(InventoryPlayer inventoryPlayer, TileEntityCrucible tileCrucible) {
|
||||
this.tileCrucible = tileCrucible;
|
||||
|
@ -54,6 +59,8 @@ public class ContainerCrucible extends Container {
|
|||
iCraft.sendProgressBarUpdate(this, 0, this.tileCrucible.currentFluidID);
|
||||
iCraft.sendProgressBarUpdate(this, 1, this.tileCrucible.currentProcessTime);
|
||||
iCraft.sendProgressBarUpdate(this, 2, this.tileCrucible.processTimeNeeded);
|
||||
iCraft.sendProgressBarUpdate(this, 3, this.tileCrucible.burnTime);
|
||||
iCraft.sendProgressBarUpdate(this, 4, this.tileCrucible.burnTimeOfItem);
|
||||
}
|
||||
|
||||
public void detectAndSendChanges(){
|
||||
|
@ -64,11 +71,15 @@ public class ContainerCrucible extends Container {
|
|||
if (this.lastCurrentFluidID != this.tileCrucible.currentFluidID) iCraft.sendProgressBarUpdate(this, 0, this.tileCrucible.currentFluidID);
|
||||
if (this.lastProcessTime != this.tileCrucible.currentProcessTime) iCraft.sendProgressBarUpdate(this, 1, this.tileCrucible.currentProcessTime);
|
||||
if (this.lastProcessTimeNeeded != this.tileCrucible.processTimeNeeded) iCraft.sendProgressBarUpdate(this, 2, this.tileCrucible.processTimeNeeded);
|
||||
if (this.lastBurnTime != this.tileCrucible.burnTime) iCraft.sendProgressBarUpdate(this, 3, this.tileCrucible.burnTime);
|
||||
if (this.lastBurnTimeOfItem != this.tileCrucible.burnTimeOfItem) iCraft.sendProgressBarUpdate(this, 4, this.tileCrucible.burnTimeOfItem);
|
||||
}
|
||||
|
||||
this.lastCurrentFluidID = this.tileCrucible.currentFluidID;
|
||||
this.lastProcessTime = this.tileCrucible.currentProcessTime;
|
||||
this.lastProcessTimeNeeded = this.tileCrucible.processTimeNeeded;
|
||||
this.lastBurnTime = this.tileCrucible.burnTime;
|
||||
this.lastBurnTimeOfItem = this.tileCrucible.burnTimeOfItem;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
@ -76,6 +87,7 @@ public class ContainerCrucible extends Container {
|
|||
if (par1 == 0) this.tileCrucible.currentFluidID = par2;
|
||||
if (par1 == 1) this.tileCrucible.currentProcessTime = par2;
|
||||
if (par1 == 2) this.tileCrucible.processTimeNeeded = par2;
|
||||
|
||||
if (par1 == 3) this.tileCrucible.burnTime = par2;
|
||||
if (par1 == 4) this.tileCrucible.burnTimeOfItem = par2;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package ellpeck.gemification.inventory.container;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.gemification.tile.TileEntityCrucibleFire;
|
||||
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;
|
||||
|
||||
public class ContainerCrucibleFire extends Container {
|
||||
|
||||
private TileEntityCrucibleFire tileCrucibleFire;
|
||||
|
||||
private int lastBurnTime;
|
||||
private int lastBurnTimeOfItem;
|
||||
|
||||
public ContainerCrucibleFire(InventoryPlayer inventoryPlayer, TileEntityCrucibleFire tileCrucibleFire) {
|
||||
this.tileCrucibleFire = tileCrucibleFire;
|
||||
|
||||
this.addSlotToContainer(new Slot(this.tileCrucibleFire, 0, 70, 9));
|
||||
|
||||
for (int i = 0; i < 3; ++i){
|
||||
for (int j = 0; j < 9; ++j){
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 34 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i){
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 92));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return tileCrucibleFire.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
public void addCraftingToCrafters(ICrafting iCraft){
|
||||
super.addCraftingToCrafters(iCraft);
|
||||
|
||||
iCraft.sendProgressBarUpdate(this, 0, this.tileCrucibleFire.burnTime);
|
||||
iCraft.sendProgressBarUpdate(this, 1, this.tileCrucibleFire.burnTimeOfItem);
|
||||
}
|
||||
|
||||
public void detectAndSendChanges(){
|
||||
super.detectAndSendChanges();
|
||||
for (Object crafter : this.crafters) {
|
||||
ICrafting iCraft = (ICrafting) crafter;
|
||||
|
||||
if (this.lastBurnTime != this.tileCrucibleFire.burnTime) iCraft.sendProgressBarUpdate(this, 0, this.tileCrucibleFire.burnTime);
|
||||
if (this.lastBurnTimeOfItem != this.tileCrucibleFire.burnTimeOfItem) iCraft.sendProgressBarUpdate(this, 1, this.tileCrucibleFire.burnTimeOfItem);
|
||||
}
|
||||
|
||||
this.lastBurnTime = tileCrucibleFire.burnTime;
|
||||
this.lastBurnTimeOfItem = tileCrucibleFire.burnTimeOfItem;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int par1, int par2){
|
||||
if (par1 == 0) this.tileCrucibleFire.burnTime = par2;
|
||||
if (par1 == 1) this.tileCrucibleFire.burnTimeOfItem = par2;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package ellpeck.gemification.container;
|
||||
package ellpeck.gemification.inventory.gui;
|
||||
|
||||
import ellpeck.gemification.Gemification;
|
||||
import ellpeck.gemification.Util;
|
||||
import ellpeck.gemification.inventory.container.ContainerCrucible;
|
||||
import ellpeck.gemification.tile.TileEntityCrucible;
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
@ -16,9 +16,9 @@ public class GuiCrucible extends GuiContainer{
|
|||
|
||||
private TileEntityCrucible tileCrucible;
|
||||
|
||||
public static final ResourceLocation resLoc = new ResourceLocation(Gemification.MOD_ID, "textures/gui/guiCrucible.png");
|
||||
public static final ResourceLocation resLoc = new ResourceLocation(Util.MOD_ID, "textures/gui/guiCrucible.png");
|
||||
|
||||
public GuiCrucible(InventoryPlayer inventoryPlayer, TileEntityCrucible tileCrucible) {
|
||||
public GuiCrucible(InventoryPlayer inventoryPlayer, TileEntityCrucible tileCrucible){
|
||||
super(new ContainerCrucible(inventoryPlayer, tileCrucible));
|
||||
this.tileCrucible = tileCrucible;
|
||||
|
||||
|
@ -36,6 +36,11 @@ public class GuiCrucible extends GuiContainer{
|
|||
this.drawTexturedModalRect(guiLeft + 107, guiTop + 55, 176, 0, i, 45);
|
||||
}
|
||||
|
||||
if(this.tileCrucible.burnTime > 0 && this.tileCrucible.burnTimeOfItem > 0) {
|
||||
int i = this.tileCrucible.getBurnTimeRemainingScaled(13);
|
||||
this.drawTexturedModalRect(guiLeft + 141, guiTop + 21 + 12 - i, 188, 45 + 12 - i, 14, i + 1);
|
||||
}
|
||||
|
||||
if(this.tileCrucible.currentFluidID == Util.fluidWater.ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 176, 47, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(0).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 176, 59, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(1).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 188, 59, 12, 12);
|
||||
|
@ -58,6 +63,7 @@ public class GuiCrucible extends GuiContainer{
|
|||
@SuppressWarnings("static-access")
|
||||
public void drawScreen(int par1, int par2, float par3){
|
||||
super.drawScreen(par1, par2, par3);
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), tileCrucible.output, guiLeft + 112, guiTop + 65);
|
|
@ -0,0 +1,40 @@
|
|||
package ellpeck.gemification.inventory.gui;
|
||||
|
||||
import ellpeck.gemification.inventory.container.ContainerCrucibleFire;
|
||||
import ellpeck.gemification.tile.TileEntityCrucibleFire;
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiCrucibleFire extends GuiContainer{
|
||||
|
||||
@SuppressWarnings("all")
|
||||
private TileEntityCrucibleFire tileCrucibleFire;
|
||||
|
||||
public static final ResourceLocation resLoc = new ResourceLocation(Util.MOD_ID, "textures/gui/guiCrucibleFire.png");
|
||||
|
||||
public GuiCrucibleFire(InventoryPlayer inventoryPlayer, TileEntityCrucibleFire tileCrucibleFire){
|
||||
super(new ContainerCrucibleFire(inventoryPlayer, tileCrucibleFire));
|
||||
this.tileCrucibleFire = tileCrucibleFire;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 116;
|
||||
}
|
||||
|
||||
public void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(resLoc);
|
||||
this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
if(this.tileCrucibleFire.burnTime > 0 && this.tileCrucibleFire.burnTimeOfItem > 0) {
|
||||
int i = this.tileCrucibleFire.getBurnTimeRemainingScaled(13);
|
||||
this.drawTexturedModalRect(guiLeft + 96, guiTop + 10 + 12 - i, 176, 12 - i, 14, i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawScreen(int par1, int par2, float par3){
|
||||
super.drawScreen(par1, par2, par3);
|
||||
}
|
||||
}
|
|
@ -2,9 +2,8 @@ package ellpeck.gemification.items;
|
|||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.gemification.CreativeTab;
|
||||
import ellpeck.gemification.Gemification;
|
||||
import ellpeck.gemification.Util;
|
||||
import ellpeck.gemification.creative.CreativeTab;
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -59,7 +58,7 @@ public class ItemGem extends Item {
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconReg){
|
||||
for (int i = 0; i < Util.gemList.size(); i++) {
|
||||
textures[i] = iconReg.registerIcon(Gemification.MOD_ID + ":" + this.getUnlocalizedName().substring(5) + Util.gemList.get(i).name.substring(5));
|
||||
textures[i] = iconReg.registerIcon(Util.MOD_ID + ":" + this.getUnlocalizedName().substring(5) + Util.gemList.get(i).name.substring(5));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,9 @@ package ellpeck.gemification.proxy;
|
|||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import ellpeck.gemification.blocks.InitBlocks;
|
||||
import ellpeck.gemification.blocks.models.ModelCrucible;
|
||||
import ellpeck.gemification.blocks.models.RendererCrucible;
|
||||
import ellpeck.gemification.blocks.models.RendererHoldingTileEntity;
|
||||
import ellpeck.gemification.blocks.models.*;
|
||||
import ellpeck.gemification.tile.TileEntityCrucible;
|
||||
import ellpeck.gemification.tile.TileEntityCrucibleFire;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
|
@ -19,8 +18,11 @@ public class ClientProxy implements IProxy{
|
|||
public void init() {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrucible.class, new RendererCrucible());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockCrucible), new RendererHoldingTileEntity(new ModelCrucible(), RendererCrucible.resLoc));
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrucibleFire.class, new RendererCrucibleFire());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockCrucibleFire), new RendererHoldingTileEntity(new ModelCrucibleFire(), RendererCrucibleFire.resLoc));
|
||||
}
|
||||
|
||||
public void postInit() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package ellpeck.gemification.tile;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
|
@ -19,4 +21,8 @@ public class TileEntityBase extends TileEntity{
|
|||
this.readFromNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
public static void init(){
|
||||
GameRegistry.registerTileEntity(TileEntityCrucible.class, Util.MOD_ID + "tileEntityCrucible");
|
||||
GameRegistry.registerTileEntity(TileEntityCrucibleFire.class, Util.MOD_ID + "tileEntityCrucibleFire");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,14 @@ package ellpeck.gemification.tile;
|
|||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.gemification.GemType;
|
||||
import ellpeck.gemification.Util;
|
||||
import ellpeck.gemification.blocks.InitBlocks;
|
||||
import ellpeck.gemification.crafting.CrucibleCraftingManager;
|
||||
import ellpeck.gemification.items.ItemGem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import ellpeck.gemification.util.GemType;
|
||||
import ellpeck.gemification.util.Util;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileEntityCrucible extends TileEntityInventoryBase{
|
||||
|
@ -32,8 +26,9 @@ public class TileEntityCrucible extends TileEntityInventoryBase{
|
|||
public int currentFluidID;
|
||||
public int currentProcessTime;
|
||||
public int processTimeNeeded;
|
||||
public int burnTime;
|
||||
public int burnTimeOfItem;
|
||||
|
||||
private boolean isCrafting = false;
|
||||
public static ItemStack output;
|
||||
|
||||
public TileEntityCrucible(){
|
||||
|
@ -48,43 +43,67 @@ public class TileEntityCrucible extends TileEntityInventoryBase{
|
|||
this.slots = new ItemStack[12];
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public void updateEntity(){
|
||||
boolean isCraftingFlag = this.isCrafting();
|
||||
if(!worldObj.isRemote){
|
||||
if(!this.isCrafting()) this.output = CrucibleCraftingManager.instance.getCraftingResult(slots, 0, 8, currentFluid);
|
||||
this.getBurnFromBelow();
|
||||
this.craft();
|
||||
this.addWaterByWaterSlot();
|
||||
this.colorGemWater();
|
||||
this.currentFluidID = this.currentFluid.ID;
|
||||
}
|
||||
if(isCraftingFlag != this.isCrafting()){
|
||||
this.markDirty();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCrafting(){
|
||||
return this.currentProcessTime > 0;
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public void craft(){
|
||||
if(!this.isCrafting){
|
||||
this.output = CrucibleCraftingManager.instance.getCraftingResult(slots, 0, 8, currentFluid);
|
||||
if (output != null) {
|
||||
this.processTimeNeeded = CrucibleCraftingManager.instance.getProcessTimeNeeded(output);
|
||||
for(int i = 0; i <= 8; i++){
|
||||
if(this.burnTime > 0){
|
||||
if (!this.isCrafting()){
|
||||
if (output != null && (this.slots[slotOutput] == null || this.slots[slotOutput].isItemEqual(output))) {
|
||||
this.processTimeNeeded = this.currentProcessTime = CrucibleCraftingManager.instance.getProcessTimeNeeded(slots, 0, 8);
|
||||
for (int i = 0; i <= 8; i++){
|
||||
this.slots[i].stackSize--;
|
||||
if (this.slots[i].stackSize == 0){
|
||||
if (this.slots[i].stackSize == 0) {
|
||||
this.slots[i] = slots[i].getItem().getContainerItem(slots[i]);
|
||||
}
|
||||
}
|
||||
this.currentFluid = Util.fluidNone;
|
||||
this.isCrafting = true;
|
||||
}
|
||||
}
|
||||
if(this.isCrafting){
|
||||
this.currentProcessTime++;
|
||||
if(this.currentProcessTime >= this.processTimeNeeded){
|
||||
if(this.slots[slotOutput] == null) this.slots[slotOutput] = output.copy();
|
||||
else if(this.slots[slotOutput].getItem() == output.getItem()) this.slots[slotOutput].stackSize += output.stackSize;
|
||||
if(this.isCrafting()){
|
||||
this.currentProcessTime--;
|
||||
if (this.currentProcessTime <= 0){
|
||||
if (this.slots[slotOutput] == null) this.slots[slotOutput] = output.copy();
|
||||
else if (this.slots[slotOutput].getItem() == output.getItem())
|
||||
this.slots[slotOutput].stackSize += output.stackSize;
|
||||
this.output = null;
|
||||
this.currentProcessTime = 0;
|
||||
this.processTimeNeeded = 0;
|
||||
this.isCrafting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getBurnFromBelow(){
|
||||
TileEntity tileDown = worldObj.getTileEntity(this.xCoord, this.yCoord - 1, this.zCoord);
|
||||
if(tileDown instanceof TileEntityCrucibleFire){
|
||||
this.burnTime = ((TileEntityCrucibleFire)tileDown).burnTime;
|
||||
this.burnTimeOfItem = ((TileEntityCrucibleFire)tileDown).burnTimeOfItem;
|
||||
}
|
||||
else{
|
||||
this.burnTime = 0;
|
||||
this.burnTimeOfItem = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void colorGemWater(){
|
||||
ItemStack stack = this.slots[slotSmeltGem];
|
||||
|
@ -110,12 +129,27 @@ public class TileEntityCrucible extends TileEntityInventoryBase{
|
|||
|
||||
public void writeToNBT(NBTTagCompound compound){
|
||||
super.writeToNBT(compound);
|
||||
|
||||
compound.setInteger("CurrentFluidID", this.currentFluidID);
|
||||
compound.setInteger("ProcessTime", this.currentProcessTime);
|
||||
compound.setInteger("ProcessTimeNeeded", this.processTimeNeeded);
|
||||
|
||||
if(output != null) {
|
||||
NBTTagCompound compoundOutput = new NBTTagCompound();
|
||||
compoundOutput = output.writeToNBT(compoundOutput);
|
||||
compound.setTag("Output", compoundOutput);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
super.readFromNBT(compound);
|
||||
|
||||
this.currentFluidID = compound.getInteger("CurrentFluidID");
|
||||
this.currentProcessTime = compound.getInteger("ProcessTime");
|
||||
this.processTimeNeeded = compound.getInteger("ProcessTimeNeeded");
|
||||
this.output = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("Output"));
|
||||
|
||||
if(this.currentFluidID == Util.fluidWater.ID) this.currentFluid = Util.fluidWater;
|
||||
else if(this.currentFluidID == Util.fluidNone.ID) this.currentFluid = Util.fluidNone;
|
||||
else this.currentFluid = Util.gemList.get(this.currentFluidID);
|
||||
|
@ -123,6 +157,11 @@ public class TileEntityCrucible extends TileEntityInventoryBase{
|
|||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getCraftProcessScaled(int par1){
|
||||
return this.currentProcessTime * par1 / this.processTimeNeeded;
|
||||
return (this.processTimeNeeded-this.currentProcessTime) * par1 / this.processTimeNeeded;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBurnTimeRemainingScaled(int i){
|
||||
return this.burnTime * i / this.burnTimeOfItem;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
package ellpeck.gemification.tile;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.gemification.blocks.InitBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
|
||||
public class TileEntityCrucibleFire extends TileEntityInventoryBase{
|
||||
|
||||
public int burnTime;
|
||||
public int burnTimeOfItem;
|
||||
|
||||
public TileEntityCrucibleFire(){
|
||||
this.slots = new ItemStack[1];
|
||||
}
|
||||
|
||||
public void updateEntity(){
|
||||
boolean isBurningFlag = this.isBurning();
|
||||
if(!worldObj.isRemote){
|
||||
this.burnFuel();
|
||||
}
|
||||
if(isBurningFlag != this.isBurning()){
|
||||
this.markDirty();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
public void burnFuel(){
|
||||
if(this.burnTime <= 0){
|
||||
if (this.slots[0] != null) {
|
||||
this.burnTimeOfItem = this.burnTime = TileEntityFurnace.getItemBurnTime(this.slots[0]);
|
||||
this.slots[0].stackSize--;
|
||||
if (this.slots[0].stackSize == 0){
|
||||
this.slots[0] = slots[0].getItem().getContainerItem(slots[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(this.burnTime > 0){
|
||||
this.burnTime--;
|
||||
if(this.burnTime <= 0){
|
||||
this.burnTimeOfItem = 0;
|
||||
this.burnTime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getInventoryName() {
|
||||
return InitBlocks.blockCrucibleFire.getUnlocalizedName().substring(5);
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound compound){
|
||||
super.writeToNBT(compound);
|
||||
compound.setInteger("BurnTime", this.burnTime);
|
||||
compound.setInteger("BurnTimeOfItem", this.burnTimeOfItem);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
super.readFromNBT(compound);
|
||||
this.burnTime = compound.getInteger("BurnTime");
|
||||
this.burnTimeOfItem = compound.getInteger("BurnTimeOfItem");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getBurnTimeRemainingScaled(int i){
|
||||
return this.burnTime * i / this.burnTimeOfItem;
|
||||
}
|
||||
|
||||
public boolean isBurning(){
|
||||
return this.burnTime > 0;
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class TileEntityInventoryBase extends TileEntityBase implements ISidedInventory{
|
||||
public abstract class TileEntityInventoryBase extends TileEntityBase implements ISidedInventory{
|
||||
|
||||
public ItemStack slots[];
|
||||
|
||||
|
@ -80,10 +80,6 @@ public class TileEntityInventoryBase extends TileEntityBase implements ISidedInv
|
|||
this.slots[i] = stack;
|
||||
}
|
||||
|
||||
public String getInventoryName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getSizeInventory() {
|
||||
return slots.length;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package ellpeck.gemification;
|
||||
package ellpeck.gemification.util;
|
||||
|
||||
public class GemType {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package ellpeck.gemification;
|
||||
package ellpeck.gemification.util;
|
||||
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
@ -8,6 +8,10 @@ import java.util.ArrayList;
|
|||
|
||||
public class Util {
|
||||
|
||||
public static final String MOD_ID = "gemification";
|
||||
public static final String NAME = "Gemification";
|
||||
public static final String VERSION = "1.7.10-1.0.1";
|
||||
|
||||
public static ArrayList<GemType> gemList = new ArrayList<GemType>();
|
||||
|
||||
public static final GemType fluidOnyx = new GemType(0, "Onyx", true);
|
||||
|
@ -33,8 +37,7 @@ public class Util {
|
|||
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
|
||||
}
|
||||
|
||||
public static String shiftForInfo(){
|
||||
return (EnumChatFormatting.ITALIC + StatCollector.translateToLocal("tooltip.shiftForInfo.desc"));
|
||||
public static String shiftForInfo() {
|
||||
return ((char)167+"2" + EnumChatFormatting.ITALIC + StatCollector.translateToLocal("tooltip.shiftForInfo.desc"));
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in a new issue