mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Made lots and lots of awesome Stuff. Mainly: Crucible!
This commit is contained in:
parent
60ed1cd062
commit
00800f6108
28 changed files with 964 additions and 25 deletions
|
@ -17,12 +17,12 @@ buildscript {
|
|||
|
||||
apply plugin: 'forge'
|
||||
|
||||
version = "1.7.10-1.0"
|
||||
version = "1.7.10-1.0.1"
|
||||
group = "ellpeck.thingycraft"
|
||||
archivesBaseName = "ThingyCraft"
|
||||
|
||||
minecraft {
|
||||
version = "1.7.10-10.13.2.1230"
|
||||
version = "1.7.10-10.13.2.1236"
|
||||
runDir = "idea"
|
||||
}
|
||||
|
||||
|
|
13
src/main/java/ellpeck/thingycraft/GemType.java
Normal file
13
src/main/java/ellpeck/thingycraft/GemType.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package ellpeck.thingycraft;
|
||||
|
||||
public class GemType {
|
||||
|
||||
public int ID;
|
||||
public String name;
|
||||
|
||||
public GemType(int ID, String name, boolean shouldAddToList){
|
||||
this.ID = ID;
|
||||
this.name = "fluid" + name;
|
||||
if(shouldAddToList) Util.gemList.add(ID, this);
|
||||
}
|
||||
}
|
|
@ -29,8 +29,8 @@ public class OreGen implements IWorldGenerator {
|
|||
}
|
||||
|
||||
private void generateSurface(World world, Random random, int x, int z){
|
||||
for(int i = 0; i < Util.gemTypes.length; i++) {
|
||||
this.addOreSpawn(InitBlocks.oreGem, i, Blocks.stone, world, random, x, z, 4 + random.nextInt(3), 8, 1, 70);
|
||||
for(int i = 0; i < Util.gemList.size(); i++) {
|
||||
this.addOreSpawn(InitBlocks.oreGem, i, Blocks.stone, world, random, x, z, 4 + random.nextInt(3), 6, 1, 70);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
package ellpeck.thingycraft;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.event.*;
|
||||
import cpw.mods.fml.common.Mod.*;
|
||||
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.thingycraft.blocks.InitBlocks;
|
||||
import ellpeck.thingycraft.container.GuiHandler;
|
||||
import ellpeck.thingycraft.crafting.CrucibleCraftingManager;
|
||||
import ellpeck.thingycraft.items.InitItems;
|
||||
import ellpeck.thingycraft.proxy.IProxy;
|
||||
import ellpeck.thingycraft.tile.TileEntityCrucible;
|
||||
|
||||
@Mod(modid = ThingyCraft.MOD_ID, name = ThingyCraft.NAME, version = ThingyCraft.VERSION)
|
||||
public class ThingyCraft {
|
||||
|
@ -13,26 +21,36 @@ public class ThingyCraft {
|
|||
@Instance(ThingyCraft.MOD_ID)
|
||||
public static ThingyCraft instance;
|
||||
|
||||
@SidedProxy(clientSide = "ellpeck.thingycraft.proxy.ClientProxy", serverSide = "ellpeck.thingycraft.proxy.ServerProxy")
|
||||
public static IProxy proxy;
|
||||
|
||||
public static final String MOD_ID = "thingycraft";
|
||||
public static final String NAME = "ThingyCraft";
|
||||
public static final String VERSION = "1.7.10-1.0";
|
||||
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){
|
||||
InitBlocks.init();
|
||||
InitItems.init();
|
||||
proxy.preInit();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler()
|
||||
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, ThingyCraft.MOD_ID + "tileEntityCrucible");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler()
|
||||
public void postInit(FMLPostInitializationEvent event){
|
||||
|
||||
proxy.postInit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,30 @@ import net.minecraft.util.EnumChatFormatting;
|
|||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Util {
|
||||
|
||||
public static final String[] gemTypes = {"Onyx", "AlmandineGarnet", "ChromeDiopside", "Jasper", "Sodalite", "Iolite", "Smithsonite", "Danburite", "Hematite", "Lepidolite", "Tourmaline", "Sphene", "ParaibaTourlamine", "Rhodochrosite", "Clinohumite", "Goshenite"};
|
||||
public static ArrayList<GemType> gemList = new ArrayList<GemType>();
|
||||
|
||||
public static final GemType fluidOnyx = new GemType(0, "Onyx", true);
|
||||
public static final GemType fluidAlmandineGarnet = new GemType(1, "AlmandineGarnet", true);
|
||||
public static final GemType fluidChromeDiopside = new GemType(2, "ChromeDiopside", true);
|
||||
public static final GemType fluidJasper = new GemType(3, "Jasper", true);
|
||||
public static final GemType fluidSodalite = new GemType(4, "Sodalite", true);
|
||||
public static final GemType fluidIolite = new GemType(5, "Iolite", true);
|
||||
public static final GemType fluidSmithsonite = new GemType(6, "Smithsonite", true);
|
||||
public static final GemType fluidDanburite = new GemType(7, "Danburite", true);
|
||||
public static final GemType fluidHematite = new GemType(8, "Hematite", true);
|
||||
public static final GemType fluidLepidolite = new GemType(9, "Lepidolite", true);
|
||||
public static final GemType fluidTourmaline = new GemType(10, "Tourmaline", true);
|
||||
public static final GemType fluidSphene = new GemType(11, "Sphene", true);
|
||||
public static final GemType fluidParaibaTourlamine = new GemType(12, "ParaibaTourlamine", true);
|
||||
public static final GemType fluidRhodochrosite = new GemType(13, "Rhodochrosite", true);
|
||||
public static final GemType fluidClinohumite = new GemType(14, "Clinohumite", true);
|
||||
public static final GemType fluidGoshenite = new GemType(15, "Goshenite", true);
|
||||
public static final GemType fluidWater = new GemType(16, "Water", false);
|
||||
public static final GemType fluidNone = new GemType(17, "None", false);
|
||||
|
||||
public static boolean isShiftPressed(){
|
||||
return Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
|
||||
|
|
91
src/main/java/ellpeck/thingycraft/blocks/BlockCrucible.java
Normal file
91
src/main/java/ellpeck/thingycraft/blocks/BlockCrucible.java
Normal file
|
@ -0,0 +1,91 @@
|
|||
package ellpeck.thingycraft.blocks;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import ellpeck.thingycraft.ThingyCraft;
|
||||
import ellpeck.thingycraft.Util;
|
||||
import ellpeck.thingycraft.tile.TileEntityCrucible;
|
||||
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.creativetab.CreativeTabs;
|
||||
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;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockCrucible extends BlockContainer{
|
||||
|
||||
protected BlockCrucible(){
|
||||
super(Material.rock);
|
||||
this.setBlockName("blockCrucible");
|
||||
this.setCreativeTab(CreativeTabs.tabBrewing);
|
||||
}
|
||||
|
||||
public TileEntity createNewTileEntity(World world, int i){
|
||||
return new TileEntityCrucible();
|
||||
}
|
||||
|
||||
@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(ThingyCraft.instance, ThingyCraft.guiCrucible, 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){
|
||||
TileEntityCrucible tileEntity = (TileEntityCrucible)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;
|
||||
}
|
||||
}
|
||||
if(tileEntity.currentFluid != Util.fluidNone) world.setBlock(x, y, z, Blocks.flowing_water);
|
||||
}
|
||||
|
||||
}
|
|
@ -6,12 +6,15 @@ import net.minecraft.block.Block;
|
|||
public class InitBlocks{
|
||||
|
||||
public static Block oreGem;
|
||||
public static Block blockCrucible;
|
||||
|
||||
public static void init(){
|
||||
|
||||
oreGem = new OreGem();
|
||||
blockCrucible = new BlockCrucible();
|
||||
|
||||
GameRegistry.registerBlock(oreGem, ItemBlockOreGem.class, oreGem.getUnlocalizedName().substring(5));
|
||||
GameRegistry.registerBlock(blockCrucible, blockCrucible.getUnlocalizedName().substring(5));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ public class ItemBlockOreGem extends ItemBlock {
|
|||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return this.getUnlocalizedName() + Util.gemTypes[stack.getItemDamage()];
|
||||
return this.getUnlocalizedName() + Util.gemList.get(stack.getItemDamage()).name.substring(5);
|
||||
}
|
||||
|
||||
public int getMetadata(int i) {
|
||||
|
@ -31,8 +31,8 @@ public class ItemBlockOreGem extends ItemBlock {
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
||||
if(Util.isShiftPressed()){
|
||||
for(int i = 0; i < Util.gemTypes.length; i++){
|
||||
if(this.getDamage(stack) == i) list.add(StatCollector.translateToLocal("tooltip.gem" + Util.gemTypes[i] + ".desc"));
|
||||
for(int i = 0; i < Util.gemList.size(); i++){
|
||||
if(this.getDamage(stack) == i) list.add(StatCollector.translateToLocal("tooltip.gem" + Util.gemList.get(i).name.substring(5) + ".desc"));
|
||||
}
|
||||
list.add(EnumChatFormatting.BOLD + StatCollector.translateToLocal("tooltip.gemIsOre.desc"));
|
||||
}
|
||||
|
|
|
@ -12,15 +12,17 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class OreGem extends Block{
|
||||
|
||||
public static final IIcon[] textures = new IIcon[Util.gemTypes.length];
|
||||
public final IIcon[] textures;
|
||||
|
||||
public OreGem() {
|
||||
super(Material.rock);
|
||||
textures = new IIcon[Util.gemList.size()];
|
||||
this.setHardness(3.0F);
|
||||
this.setResistance(5.0F);
|
||||
this.setStepSound(soundTypeStone);
|
||||
|
@ -31,7 +33,7 @@ public class OreGem extends Block{
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void getSubBlocks(Item stack, CreativeTabs tab, List list) {
|
||||
for (int i = 0; i < Util.gemTypes.length; i++) {
|
||||
for (int i = 0; i < Util.gemList.size(); i++) {
|
||||
list.add(new ItemStack(stack, 1, i));
|
||||
}
|
||||
}
|
||||
|
@ -54,8 +56,8 @@ public class OreGem extends Block{
|
|||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconReg) {
|
||||
for (int i = 0; i < Util.gemTypes.length; i++) {
|
||||
textures[i] = iconReg.registerIcon(ThingyCraft.MOD_ID + ":" + this.getUnlocalizedName().substring(5) + Util.gemTypes[i]);
|
||||
for (int i = 0; i < Util.gemList.size(); i++) {
|
||||
textures[i] = iconReg.registerIcon(ThingyCraft.MOD_ID + ":" + this.getUnlocalizedName().substring(5) + Util.gemList.get(i).name.substring(5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package ellpeck.thingycraft.blocks.models;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
|
||||
public class ModelCrucible extends ModelBase{
|
||||
public ModelRenderer floor, rimOne, rimTwo, rimThree, rimFour, wallOne, wallTwo, wallThree, wallFour, supportOne, supportTwo, supportThree, supportFour;
|
||||
|
||||
public ModelCrucible() {
|
||||
this.textureWidth = 64;
|
||||
this.textureHeight = 64;
|
||||
this.supportTwo = new ModelRenderer(this, 0, 0);
|
||||
this.supportTwo.setRotationPoint(-6.5F, 21.0F, 4.5F);
|
||||
this.supportTwo.addBox(0.0F, 0.0F, 0.0F, 2, 3, 2);
|
||||
this.wallTwo = new ModelRenderer(this, 0, 0);
|
||||
this.wallTwo.setRotationPoint(7.0F, 9.5F, -8.0F);
|
||||
this.wallTwo.addBox(0.0F, 0.0F, 0.0F, 1, 9, 16);
|
||||
this.floor = new ModelRenderer(this, 0, 0);
|
||||
this.floor.setRotationPoint(-6.0F, 21.5F, -6.0F);
|
||||
this.floor.addBox(0.0F, 0.0F, 0.0F, 12, 1, 12);
|
||||
this.rimThree = new ModelRenderer(this, 0, 0);
|
||||
this.rimThree.setRotationPoint(6.0F, 18.5F, -6.0F);
|
||||
this.rimThree.addBox(0.0F, 0.0F, 0.0F, 1, 3, 12);
|
||||
this.wallThree = new ModelRenderer(this, 0, 0);
|
||||
this.wallThree.setRotationPoint(-7.0F, 9.5F, 7.0F);
|
||||
this.wallThree.addBox(0.0F, 0.0F, 0.0F, 14, 9, 1);
|
||||
this.rimTwo = new ModelRenderer(this, 0, 0);
|
||||
this.rimTwo.setRotationPoint(-7.0F, 18.5F, 6.0F);
|
||||
this.rimTwo.addBox(0.0F, 0.0F, 0.0F, 14, 3, 1);
|
||||
this.rimOne = new ModelRenderer(this, 0, 0);
|
||||
this.rimOne.setRotationPoint(-7.0F, 18.5F, -7.0F);
|
||||
this.rimOne.addBox(0.0F, 0.0F, 0.0F, 14, 3, 1);
|
||||
this.supportOne = new ModelRenderer(this, 0, 0);
|
||||
this.supportOne.setRotationPoint(4.5F, 21.0F, 4.5F);
|
||||
this.supportOne.addBox(0.0F, 0.0F, 0.0F, 2, 3, 2);
|
||||
this.wallOne = new ModelRenderer(this, 0, 0);
|
||||
this.wallOne.setRotationPoint(-8.0F, 9.5F, -8.0F);
|
||||
this.wallOne.addBox(0.0F, 0.0F, 0.0F, 1, 9, 16);
|
||||
this.supportFour = new ModelRenderer(this, 0, 0);
|
||||
this.supportFour.setRotationPoint(-6.5F, 21.0F, -6.5F);
|
||||
this.supportFour.addBox(0.0F, 0.0F, 0.0F, 2, 3, 2);
|
||||
this.wallFour = new ModelRenderer(this, 0, 0);
|
||||
this.wallFour.setRotationPoint(-7.0F, 9.5F, -8.0F);
|
||||
this.wallFour.addBox(0.0F, 0.0F, 0.0F, 14, 9, 1);
|
||||
this.rimFour = new ModelRenderer(this, 0, 0);
|
||||
this.rimFour.setRotationPoint(-7.0F, 18.5F, -6.0F);
|
||||
this.rimFour.addBox(0.0F, 0.0F, 0.0F, 1, 3, 12);
|
||||
this.supportThree = new ModelRenderer(this, 0, 0);
|
||||
this.supportThree.setRotationPoint(4.5F, 21.0F, -6.5F);
|
||||
this.supportThree.addBox(0.0F, 0.0F, 0.0F, 2, 3, 2);
|
||||
}
|
||||
|
||||
public void render(float f) {
|
||||
this.supportTwo.render(f);
|
||||
this.wallTwo.render(f);
|
||||
this.floor.render(f);
|
||||
this.rimThree.render(f);
|
||||
this.wallThree.render(f);
|
||||
this.rimTwo.render(f);
|
||||
this.rimOne.render(f);
|
||||
this.supportOne.render(f);
|
||||
this.wallOne.render(f);
|
||||
this.supportFour.render(f);
|
||||
this.wallFour.render(f);
|
||||
this.rimFour.render(f);
|
||||
this.supportThree.render(f);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package ellpeck.thingycraft.blocks.models;
|
||||
|
||||
import ellpeck.thingycraft.ThingyCraft;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RendererCrucible extends TileEntitySpecialRenderer{
|
||||
|
||||
public static final ResourceLocation resLoc = new ResourceLocation(ThingyCraft.MOD_ID, "textures/blocks/models/modelCrucible.png");
|
||||
private ModelCrucible model;
|
||||
|
||||
public RendererCrucible(){
|
||||
this.model = new ModelCrucible();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package ellpeck.thingycraft.blocks.models;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RendererHoldingTileEntity implements IItemRenderer {
|
||||
|
||||
ModelCrucible model;
|
||||
ResourceLocation texture;
|
||||
|
||||
public RendererHoldingTileEntity(ModelCrucible model, ResourceLocation res){
|
||||
this.model = model;
|
||||
texture = res;
|
||||
}
|
||||
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data){
|
||||
switch(type){
|
||||
case INVENTORY:
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glTranslatef(-0.5F, -1.27F, 0.5F);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
model.render(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
break;
|
||||
|
||||
case EQUIPPED:
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||
GL11.glTranslatef(0.6F, -1.2F, -0.0F);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
model.render(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
break;
|
||||
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(1.2F, 1.2F, 1.2F);
|
||||
GL11.glRotatef(180, 2F, -0F, 0.1F);
|
||||
GL11.glTranslatef(1.5F, -1.2F, -0.3F);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
model.render(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
break;
|
||||
|
||||
default:
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(1.2F, 1.2F, 1.2F);
|
||||
GL11.glRotatef(180, 2F, -0F, 0.1F);
|
||||
GL11.glTranslatef(0F, -1.2F, 0F);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
||||
model.render(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package ellpeck.thingycraft.container;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.thingycraft.tile.TileEntityCrucible;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
|
||||
public class ContainerCrucible extends Container {
|
||||
|
||||
private TileEntityCrucible tileCrucible;
|
||||
|
||||
private int lastCurrentFluidID;
|
||||
private int lastProcessTime;
|
||||
private int lastProcessTimeNeeded;
|
||||
|
||||
public ContainerCrucible(InventoryPlayer inventoryPlayer, TileEntityCrucible tileCrucible) {
|
||||
this.tileCrucible = tileCrucible;
|
||||
|
||||
this.addSlotToContainer(new Slot(this.tileCrucible, tileCrucible.slotMainInput-4, 32, 23));
|
||||
this.addSlotToContainer(new Slot(this.tileCrucible, tileCrucible.slotMainInput-3, 57, 18));
|
||||
this.addSlotToContainer(new Slot(this.tileCrucible, tileCrucible.slotMainInput-2, 82, 23));
|
||||
this.addSlotToContainer(new Slot(this.tileCrucible, tileCrucible.slotMainInput-1, 27, 48));
|
||||
this.addSlotToContainer(new Slot(this.tileCrucible, tileCrucible.slotMainInput, 57, 48));
|
||||
this.addSlotToContainer(new Slot(this.tileCrucible, tileCrucible.slotMainInput+1, 87, 48));
|
||||
this.addSlotToContainer(new Slot(this.tileCrucible, tileCrucible.slotMainInput+2, 32, 73));
|
||||
this.addSlotToContainer(new Slot(this.tileCrucible, tileCrucible.slotMainInput+3, 57, 78));
|
||||
this.addSlotToContainer(new Slot(this.tileCrucible, tileCrucible.slotMainInput+4, 82, 73));
|
||||
|
||||
this.addSlotToContainer(new Slot(tileCrucible, tileCrucible.slotSmeltGem, 129, 37));
|
||||
this.addSlotToContainer(new Slot(tileCrucible, tileCrucible.slotWater, 149, 37));
|
||||
|
||||
this.addSlotToContainer(new SlotFurnace(inventoryPlayer.player, this.tileCrucible, tileCrucible.slotOutput, 146, 85));
|
||||
|
||||
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, 113 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i){
|
||||
this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 171));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return tileCrucible.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
public void addCraftingToCrafters(ICrafting iCraft){
|
||||
super.addCraftingToCrafters(iCraft);
|
||||
|
||||
iCraft.sendProgressBarUpdate(this, 0, this.tileCrucible.currentFluidID);
|
||||
iCraft.sendProgressBarUpdate(this, 1, this.tileCrucible.currentProcessTime);
|
||||
iCraft.sendProgressBarUpdate(this, 2, this.tileCrucible.processTimeNeeded);
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public void detectAndSendChanges(){
|
||||
super.detectAndSendChanges();
|
||||
for (Object crafter : this.crafters) {
|
||||
ICrafting iCraft = (ICrafting) crafter;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
this.lastCurrentFluidID = this.tileCrucible.currentFluidID;
|
||||
this.lastProcessTime = this.tileCrucible.currentProcessTime;
|
||||
this.lastProcessTimeNeeded = this.tileCrucible.processTimeNeeded;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void updateProgressBar(int par1, int par2){
|
||||
if (par1 == 0) this.tileCrucible.currentFluidID = par2;
|
||||
if (par1 == 1) this.tileCrucible.currentProcessTime = par2;
|
||||
if (par1 == 2) this.tileCrucible.processTimeNeeded = par2;
|
||||
|
||||
}
|
||||
}
|
79
src/main/java/ellpeck/thingycraft/container/GuiCrucible.java
Normal file
79
src/main/java/ellpeck/thingycraft/container/GuiCrucible.java
Normal file
|
@ -0,0 +1,79 @@
|
|||
package ellpeck.thingycraft.container;
|
||||
|
||||
import ellpeck.thingycraft.ThingyCraft;
|
||||
import ellpeck.thingycraft.Util;
|
||||
import ellpeck.thingycraft.tile.TileEntityCrucible;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class GuiCrucible extends GuiContainer{
|
||||
|
||||
private TileEntityCrucible tileCrucible;
|
||||
|
||||
public static final ResourceLocation resLoc = new ResourceLocation(ThingyCraft.MOD_ID, "textures/gui/guiCrucible.png");
|
||||
|
||||
public GuiCrucible(InventoryPlayer inventoryPlayer, TileEntityCrucible tileCrucible) {
|
||||
super(new ContainerCrucible(inventoryPlayer, tileCrucible));
|
||||
this.tileCrucible = tileCrucible;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 195;
|
||||
}
|
||||
|
||||
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.tileCrucible.currentProcessTime > 0){
|
||||
int i = this.tileCrucible.getCraftProcessScaled(32);
|
||||
this.drawTexturedModalRect(guiLeft + 107, guiTop + 55, 176, 0, i, 45);
|
||||
}
|
||||
|
||||
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);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(2).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 200, 59, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(3).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 176, 59+12, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(4).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 188, 59+12, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(5).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 200, 59+12, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(6).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 176, 59+24, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(7).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 188, 59+24, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(8).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 200, 59+24, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(9).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 176, 59+36, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(10).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 188, 59+36, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(11).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 200, 59+36, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(12).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 176, 59+48, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(13).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 188, 59+48, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(14).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 200, 59+48, 12, 12);
|
||||
else if(this.tileCrucible.currentFluidID == Util.gemList.get(15).ID) this.drawTexturedModalRect(guiLeft + 141, guiTop + 7, 176, 59+60, 12, 12);
|
||||
}
|
||||
|
||||
@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);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
if(tileCrucible.output != null){
|
||||
if(par1 >= 112 + guiLeft && par2 >= 65 + guiTop && par1 <= 112 + 16 + guiLeft && par2 <= 65 + 16 + guiTop){
|
||||
this.drawHoveringText(tileCrucible.output.getTooltip(mc.thePlayer, true), par1, par2, mc.fontRenderer);
|
||||
}
|
||||
}
|
||||
if(par1 >= 141 + guiLeft && par2 >= 7 + guiTop && par1 <= 141+12 + guiLeft && par2 <= 7+12 + guiTop){
|
||||
String fluidType;
|
||||
if(tileCrucible.currentFluidID == Util.fluidWater.ID) fluidType = Util.fluidWater.name.substring(5);
|
||||
else if(tileCrucible.currentFluidID == Util.fluidNone.ID) fluidType = Util.fluidNone.name.substring(5);
|
||||
else fluidType = Util.gemList.get(tileCrucible.currentFluidID).name.substring(5);
|
||||
this.drawHoveringText(Arrays.asList(StatCollector.translateToLocal("tooltip.fluid" + fluidType + ".name")), par1, par2, mc.fontRenderer);
|
||||
}
|
||||
}
|
||||
}
|
32
src/main/java/ellpeck/thingycraft/container/GuiHandler.java
Normal file
32
src/main/java/ellpeck/thingycraft/container/GuiHandler.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package ellpeck.thingycraft.container;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import ellpeck.thingycraft.ThingyCraft;
|
||||
import ellpeck.thingycraft.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 ThingyCraft.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 ThingyCraft.guiCrucible:
|
||||
TileEntityCrucible tileCrucible = (TileEntityCrucible) world.getTileEntity(x, y, z);
|
||||
return new GuiCrucible(entityPlayer.inventory, tileCrucible);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package ellpeck.thingycraft.crafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import ellpeck.thingycraft.GemType;
|
||||
import ellpeck.thingycraft.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;
|
||||
|
||||
public class CrucibleCraftingManager{
|
||||
|
||||
public static final CrucibleCraftingManager instance = new CrucibleCraftingManager();
|
||||
public static ArrayList<CrucibleRecipe> recipes = new ArrayList<CrucibleRecipe>();
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public void initRecipes(){
|
||||
this.addRecipe(new ItemStack(Blocks.acacia_stairs), Util.fluidNone, 200, new Object[]{"ccc", "cgc", "ccc", 'c', Blocks.cobblestone, 'g', new ItemStack(Items.stick)});
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
public void addRecipe(ItemStack output, GemType fluidNeeded, int processTimeNeeded, Object ... recipe){
|
||||
String s = "";
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int k = 0;
|
||||
|
||||
if (recipe[i] instanceof String[]){
|
||||
String[] strg = ((String[])recipe[i++]);
|
||||
for(String s1 : strg) {
|
||||
k++;
|
||||
j = s1.length();
|
||||
s = s + s1;
|
||||
}
|
||||
}
|
||||
else{
|
||||
while (recipe[i] instanceof String){
|
||||
String s2 = (String)recipe[i++];
|
||||
k++;
|
||||
j = s2.length();
|
||||
s = s + s2;
|
||||
}
|
||||
}
|
||||
|
||||
HashMap map;
|
||||
for (map = new HashMap(); i < recipe.length; i += 2){
|
||||
Character character = (Character)recipe[i];
|
||||
ItemStack stack1 = null;
|
||||
|
||||
if (recipe[i + 1] instanceof Item){
|
||||
stack1 = new ItemStack((Item)recipe[i + 1], 1, 32767);
|
||||
}
|
||||
else if (recipe[i + 1] instanceof Block){
|
||||
stack1 = new ItemStack((Block)recipe[i + 1], 1, 32767);
|
||||
}
|
||||
else if (recipe[i + 1] instanceof ItemStack){
|
||||
stack1 = (ItemStack)recipe[i + 1];
|
||||
}
|
||||
map.put(character, stack1);
|
||||
}
|
||||
|
||||
ItemStack[] stack2 = new ItemStack[j * k];
|
||||
for (int i1 = 0; i1 < j * k; ++i1){
|
||||
char c0 = s.charAt(i1);
|
||||
if (map.containsKey(Character.valueOf(c0))){
|
||||
stack2[i1] = ((ItemStack)map.get(Character.valueOf(c0))).copy();
|
||||
}
|
||||
else{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-access")
|
||||
public int getProcessTimeNeeded(ItemStack stack){
|
||||
for(CrucibleRecipe recipe : this.recipes){
|
||||
if(recipe.recipeOutput == stack){
|
||||
return recipe.processTimeNeeded;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package ellpeck.thingycraft.crafting;
|
||||
|
||||
import ellpeck.thingycraft.GemType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class CrucibleRecipe{
|
||||
|
||||
public final ItemStack[] recipeItems;
|
||||
public final ItemStack recipeOutput;
|
||||
public final GemType fluidNeeded;
|
||||
public final int processTimeNeeded;
|
||||
|
||||
public CrucibleRecipe(ItemStack[] items, ItemStack output, GemType fluid, int processTimeNeeded){
|
||||
this.recipeItems = items;
|
||||
this.recipeOutput = output;
|
||||
this.fluidNeeded = fluid;
|
||||
this.processTimeNeeded = processTimeNeeded;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package ellpeck.thingycraft.items;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.item.Item;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class InitItems {
|
||||
|
||||
|
|
|
@ -16,9 +16,10 @@ import java.util.List;
|
|||
|
||||
public class ItemGem extends Item {
|
||||
|
||||
public static final IIcon[] textures = new IIcon[Util.gemTypes.length];
|
||||
public final IIcon[] textures;
|
||||
|
||||
public ItemGem(){
|
||||
textures = new IIcon[Util.gemList.size()];
|
||||
this.setHasSubtypes(true);
|
||||
this.setCreativeTab(CreativeTabs.tabBrewing);
|
||||
this.setUnlocalizedName("itemGem");
|
||||
|
@ -28,8 +29,8 @@ public class ItemGem extends Item {
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
||||
if(Util.isShiftPressed()){
|
||||
for(int i = 0; i < Util.gemTypes.length; i++){
|
||||
if(this.getDamage(stack) == i) list.add(StatCollector.translateToLocal("tooltip.gem" + Util.gemTypes[i] + ".desc"));
|
||||
for(int i = 0; i < Util.gemList.size(); i++){
|
||||
if(this.getDamage(stack) == i) list.add(StatCollector.translateToLocal("tooltip.gem" + Util.gemList.get(i).name.substring(5) + ".desc"));
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
@ -38,13 +39,13 @@ public class ItemGem extends Item {
|
|||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack stack){
|
||||
return this.getUnlocalizedName() + Util.gemTypes[stack.getItemDamage()];
|
||||
return this.getUnlocalizedName() + Util.gemList.get(stack.getItemDamage()).name.substring(5);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item item, CreativeTabs tabs, List list){
|
||||
for (int i = 0; i < Util.gemTypes.length; i++) {
|
||||
for (int i = 0; i < Util.gemList.size(); i++) {
|
||||
list.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
}
|
||||
|
@ -56,9 +57,9 @@ public class ItemGem extends Item {
|
|||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconReg){
|
||||
for (int i = 0; i < Util.gemTypes.length; i++) {
|
||||
textures[i] = iconReg.registerIcon(ThingyCraft.MOD_ID + ":" + this.getUnlocalizedName().substring(5) + Util.gemTypes[i]);
|
||||
for (int i = 0; i < Util.gemList.size(); i++) {
|
||||
textures[i] = iconReg.registerIcon(ThingyCraft.MOD_ID + ":" + this.getUnlocalizedName().substring(5) + Util.gemList.get(i).name.substring(5));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
26
src/main/java/ellpeck/thingycraft/proxy/ClientProxy.java
Normal file
26
src/main/java/ellpeck/thingycraft/proxy/ClientProxy.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
package ellpeck.thingycraft.proxy;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import ellpeck.thingycraft.blocks.InitBlocks;
|
||||
import ellpeck.thingycraft.blocks.models.ModelCrucible;
|
||||
import ellpeck.thingycraft.blocks.models.RendererCrucible;
|
||||
import ellpeck.thingycraft.blocks.models.RendererHoldingTileEntity;
|
||||
import ellpeck.thingycraft.tile.TileEntityCrucible;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ClientProxy implements IProxy{
|
||||
|
||||
public void preInit() {
|
||||
|
||||
}
|
||||
|
||||
public void init() {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrucible.class, new RendererCrucible());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(InitBlocks.blockCrucible), new RendererHoldingTileEntity(new ModelCrucible(), RendererCrucible.resLoc));
|
||||
}
|
||||
|
||||
public void postInit() {
|
||||
}
|
||||
}
|
10
src/main/java/ellpeck/thingycraft/proxy/IProxy.java
Normal file
10
src/main/java/ellpeck/thingycraft/proxy/IProxy.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
package ellpeck.thingycraft.proxy;
|
||||
|
||||
public interface IProxy {
|
||||
|
||||
public abstract void preInit();
|
||||
|
||||
public abstract void init();
|
||||
|
||||
public abstract void postInit();
|
||||
}
|
16
src/main/java/ellpeck/thingycraft/proxy/ServerProxy.java
Normal file
16
src/main/java/ellpeck/thingycraft/proxy/ServerProxy.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package ellpeck.thingycraft.proxy;
|
||||
|
||||
public class ServerProxy implements IProxy{
|
||||
|
||||
public void preInit() {
|
||||
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
||||
}
|
||||
|
||||
public void postInit() {
|
||||
|
||||
}
|
||||
}
|
229
src/main/java/ellpeck/thingycraft/tile/TileEntityCrucible.java
Normal file
229
src/main/java/ellpeck/thingycraft/tile/TileEntityCrucible.java
Normal file
|
@ -0,0 +1,229 @@
|
|||
package ellpeck.thingycraft.tile;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import ellpeck.thingycraft.GemType;
|
||||
import ellpeck.thingycraft.Util;
|
||||
import ellpeck.thingycraft.blocks.InitBlocks;
|
||||
import ellpeck.thingycraft.crafting.CrucibleCraftingManager;
|
||||
import ellpeck.thingycraft.items.ItemGem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
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 TileEntity implements ISidedInventory {
|
||||
|
||||
/**
|
||||
* 0-3: Inputs
|
||||
* 4: Main Input
|
||||
* 5-8: Inputs
|
||||
* 9: Water
|
||||
* 10: Gem
|
||||
* 11: Output
|
||||
*/
|
||||
public ItemStack slots[] = new ItemStack[12];
|
||||
public final int slotOutput = 11;
|
||||
public final int slotMainInput = 4;
|
||||
public final int slotWater = 9;
|
||||
public final int slotSmeltGem = 10;
|
||||
|
||||
/*
|
||||
Variables that need to be saved to and loaded from NBT
|
||||
*/
|
||||
public GemType currentFluid = Util.fluidNone;
|
||||
public int currentFluidID;
|
||||
public int currentProcessTime;
|
||||
public int processTimeNeeded;
|
||||
|
||||
private boolean isCrafting = false;
|
||||
public static ItemStack output;
|
||||
|
||||
public void updateEntity(){
|
||||
if(!worldObj.isRemote){
|
||||
this.craft();
|
||||
this.addWaterByWaterSlot();
|
||||
this.colorGemWater();
|
||||
this.currentFluidID = this.currentFluid.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@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++){
|
||||
this.slots[i].stackSize--;
|
||||
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;
|
||||
this.output = null;
|
||||
this.currentProcessTime = 0;
|
||||
this.processTimeNeeded = 0;
|
||||
this.isCrafting = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void colorGemWater(){
|
||||
ItemStack stack = this.slots[slotSmeltGem];
|
||||
if(stack != null && stack.getItem() instanceof ItemGem){
|
||||
if(this.currentFluid == Util.fluidWater) {
|
||||
this.currentFluid = Util.gemList.get(stack.getItemDamage());
|
||||
stack.stackSize--;
|
||||
if(stack.stackSize == 0) this.slots[slotSmeltGem] = stack.getItem().getContainerItem(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addWaterByWaterSlot(){
|
||||
if(this.slots[this.slotWater] != null && this.slots[this.slotWater].getItem() == Items.water_bucket && this.currentFluid == Util.fluidNone){
|
||||
this.currentFluid = Util.fluidWater;
|
||||
this.slots[this.slotWater] = new ItemStack(Items.bucket);
|
||||
}
|
||||
}
|
||||
|
||||
public int getSizeInventory() {
|
||||
return slots.length;
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return slots[i];
|
||||
}
|
||||
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
if (slots[i] != null) {
|
||||
ItemStack stackAt;
|
||||
if (slots[i].stackSize <= j) {
|
||||
stackAt = slots[i];
|
||||
slots[i] = null;
|
||||
return stackAt;
|
||||
} else {
|
||||
stackAt = slots[i].splitStack(j);
|
||||
if (slots[i].stackSize == 0)
|
||||
slots[i] = null;
|
||||
return stackAt;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
return getStackInSlot(i);
|
||||
}
|
||||
|
||||
public void setInventorySlotContents(int i, ItemStack stack){
|
||||
this.slots[i] = stack;
|
||||
}
|
||||
|
||||
public String getInventoryName() {
|
||||
return InitBlocks.blockCrucible.getUnlocalizedName().substring(5);
|
||||
}
|
||||
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64;
|
||||
}
|
||||
|
||||
public void openInventory() {
|
||||
|
||||
}
|
||||
|
||||
public void closeInventory() {
|
||||
|
||||
}
|
||||
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound compound){
|
||||
super.writeToNBT(compound);
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for(int currentIndex = 0; currentIndex < slots.length; ++currentIndex){
|
||||
if (slots[currentIndex] != null){
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte)currentIndex);
|
||||
slots[currentIndex].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
compound.setTag("Items", tagList);
|
||||
|
||||
compound.setInteger("CurrentFluidID", this.currentFluidID);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbtTagCompound){
|
||||
super.readFromNBT(nbtTagCompound);
|
||||
NBTTagList tagList = nbtTagCompound.getTagList("Items", 10);
|
||||
for (int i = 0; i < tagList.tagCount(); ++i){
|
||||
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
|
||||
byte slotIndex = tagCompound.getByte("Slot");
|
||||
if (slotIndex >= 0 && slotIndex < slots.length){
|
||||
slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
this.currentFluidID = nbtTagCompound.getInteger("CurrentFluidID");
|
||||
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);
|
||||
}
|
||||
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
this.writeToNBT(compound);
|
||||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, this.getBlockMetadata(), compound);
|
||||
}
|
||||
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
|
||||
super.onDataPacket(net, packet);
|
||||
this.readFromNBT(packet.func_148857_g());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return InitBlocks.blockCrucible.getUnlocalizedName().substring(5);
|
||||
}
|
||||
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
public boolean canInsertItem(int par1, ItemStack stack, int par3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canExtractItem(int par1, ItemStack stack, int par3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getCraftProcessScaled(int par1){
|
||||
return this.currentProcessTime * par1 / this.processTimeNeeded;
|
||||
}
|
||||
}
|
|
@ -50,4 +50,23 @@ tooltip.gemSphene.desc=Of high luster, unique color shades and an intense fire
|
|||
tooltip.gemParaibaTourlamine.desc=First found in Brazil in 1989, similar material has since been found in Africa.
|
||||
tooltip.gemRhodochrosite.desc=Usually found in an aggregate form with alternating light
|
||||
tooltip.gemClinohumite.desc=Rare gemstone, only three sources of gem-quality material are known
|
||||
tooltip.gemGoshenite.desc=Named after the small town of Goshen in Western Massachusetts
|
||||
tooltip.gemGoshenite.desc=Named after the small town of Goshen in Western Massachusetts
|
||||
|
||||
tooltip.fluidNone.name=Empty
|
||||
tooltip.fluidWater.name=Water
|
||||
tooltip.fluidOnyx.name=Liquid Onyx
|
||||
tooltip.fluidAlmandineGarnet.name=Liquid Almandine Garnet
|
||||
tooltip.fluidChromeDiopside.name=Liquid Chrome Diopside
|
||||
tooltip.fluidJasper.name=Liquid Jasper
|
||||
tooltip.fluidSodalite.name=Liquid Sodalite
|
||||
tooltip.fluidIolite.name=Liquid Iolite
|
||||
tooltip.fluidSmithsonite.name=Liquid Smithsonite
|
||||
tooltip.fluidDanburite.name=Liquid Danburite
|
||||
tooltip.fluidHematite.name=Liquid Hematite
|
||||
tooltip.fluidLepidolite.name=Liquid Lepidolite
|
||||
tooltip.fluidTourmaline.name=Liquid Tourmaline
|
||||
tooltip.fluidSphene.name=Liquid Sphene
|
||||
tooltip.fluidParaibaTourlamine.name=Liquid ParaibaTourmaline
|
||||
tooltip.fluidRhodochrosite.name=Liquid Rhodochrosite
|
||||
tooltip.fluidClinohumite.name=Liquid Clinohumite
|
||||
tooltip.fluidGoshenite.name=Liquid Goshenite
|
Binary file not shown.
After Width: | Height: | Size: 940 B |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 8.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
Loading…
Reference in a new issue