Jump to content

Recommended Posts

Posted

Could someone look this over and tell me what I can do to fix this code its giving me errors but not a way to fix them

(Updated)

 

 

Main Code

 

 

package moderncraft; //Package directory

 

 

 

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.EnumToolMaterial;

import net.minecraft.item.Item;

import net.minecraft.item.ItemFood;

import net.minecraft.item.ItemStack;

import net.minecraft.tileentity.TileEntity;

import net.minecraftforge.common.EnumHelper;

import cpw.mods.fml.client.registry.ClientRegistry;

import cpw.mods.fml.client.registry.RenderingRegistry;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

import moderncraft.blueprintTable;

 

/*

* Basic needed forge stuff

*/

@Mod(modid= moderncraft_mod.modid ,name="ModernCraft",version="v1")

@NetworkMod(clientSideRequired=true,serverSideRequired=false)

 

public class moderncraft_mod {

//private static final String  = null;

public final static String modid = "ModernCraft";

public static CreativeTabs tabYourTab = new TabModernCraft(CreativeTabs.getNextID(), "Modern Craft");

/*

* ToolMaterial

*/

public static EnumToolMaterial  EnumToolMaterialWrench = EnumHelper.addToolMaterial("Wrench", 10, 25, 10.0F, 1, 0);

//Telling forge that we are creating these

 

 

 

 

//Macerator---------------------------------

 

public static Block blockMaceratorIdle;

public static Block blockMaceratorActive;

 

public static final int guiIdMacerator = 8;

 

blockMaceratorIdle = new BlockMacerator(4101, false).setUnlocalizedName("macerator_idle").setHardness(3.7F).setCreativeTab(scratchTab);

blockMaceratorActive = new BlockMacerator(4100, true).setUnlocalizedName("macerator_active").setHardness(3.7F).setLightValue(0.9F);

 

GameRegistry.registerBlock(blockMaceratorIdle, "Macerator");

GameRegistry.registerBlock(blockMaceratorActive, "Macerator");

 

GameRegistry.registerTileEntity(TileEntityMacerator.class, "Macerator");

 

LanguageRegistry.instance().addStringLocalization("container.macerator", "Macerator");

 

NetworkRegistry.instance().registerGuiHandler(this, new GuiHandler());

 

 

 

//------------------------------------------

 

 

 

 

 

 

//Items

public static Item wrench;

 

//armor

//public static Item hazmatHelm;

//public static Item hazmatChest;

//public static Item hazmatLegs;

//public static Item hazmatBoots;

 

//blocks

public static Block blueprintTable = new blueprintTable(4005, Material.wood).setUnlocalizedName("blueprintTable").setTextureName("moderncraft:blueprintTabletexture");

public static Object instance;

 

//Declaring Init

@Init

public void load(FMLInitializationEvent event) {

// define items/blocks

 

 

    //wrench = new ModernWrench(5000, EnumToolMaterialWrench).setUnlocalizedName("wrench");

wrench = new modernwrench(4000, EnumToolMaterialWrench).setUnlocalizedName("Wrench");

//hazmatHelm = new hazmatHelm(4001).setUnlocalizedName("radiationHelmet");

//hazmatChest = new hazmatChest(4002).setUnlocalizedName("radiationChestplate");

//hazmatLegs = new hazmatLegs(4003).setUnlocalizedName("radiationLeggings");

//hazmatBoots = new hazmatBoots(4004).setUnlocalizedName("radiationBoots");

GameRegistry.registerBlock(blueprintTable, "Blueprint Table");

//adding names

ClientRegistry.bindTileEntitySpecialRenderer(TileEntityblueprintTable.class, new TileEntityblueprintTableRenderer());

 

LanguageRegistry.addName(wrench, "Wrench");

//LanguageRegistry.addName(hazmatHelm, "Radiation Helmet");

//LanguageRegistry.addName(hazmatChest, "Radiation Chestplate");

//LanguageRegistry.addName(hazmatLegs, "Radiation Leggings");

//LanguageRegistry.addName(hazmatBoots, "Radiation Boots");

LanguageRegistry.addName(blueprintTable, "Blueprint Table");

//crafting

 

}

 

}

}

 

 

 

 

BlockMacerator

 

 

 

package moderncraft;

 

 

import java.util.Random;

 

import cpw.mods.fml.common.network.FMLNetworkHandler;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.block.Block;

import net.minecraft.block.BlockContainer;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.inventory.Container;

import net.minecraft.inventory.IInventory;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.Icon;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

 

 

 

 

public class BlockMacerator extends BlockContainer{

 

private final Random maceratorRand = new Random();

 

private final boolean isActive;

 

private static boolean keepMaceratorInventory;

@SideOnly(Side.CLIENT)

private Icon maceratorIconTop;

 

public BlockMacerator(int id, boolean isActive) {

super(id, Material.rock);

 

this.isActive = isActive;

}

 

@SideOnly(Side.CLIENT)

public void registerIcons(IconRegister iconRegister){

this.blockIcon = iconRegister.registerIcon(moderncraft_mod.modid + ":" + "macerator_side");

this.maceratorIconTop = iconRegister.registerIcon(moderncraft_mod.modid + ":" + (this.isActive ? "macerator_front_lit" : "macerator_front_idle"));

}

 

@SideOnly(Side.CLIENT)

 

/**

* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata

*/

public Icon getIcon(int par1, int par2)

{

return par1 == 1 ? this.blockIcon : (par1 == 0 ? this.blockIcon : (par1 != par2 ? this.blockIcon : this.maceratorIconTop));

}

 

/**

* Returns the ID of the items to drop on destruction.

*/

public int idDropped(int par1, Random par2Random, int par3)

{

return moderncraft_mod.blockMaceratorIdle.blockID;

 

/**

* Called whenever the block is added into the world. Args: world, x, y, z

*/

public void onBlockAdded(World par1World, int par2, int par3, int par4)

{

super.onBlockAdded(par1World, par2, par3, par4);

this.setDefaultDirection(par1World, par2, par3, par4);

}

 

/**

* set a blocks direction

*/

private void setDefaultDirection(World par1World, int par2, int par3, int par4)

{

if (!par1World.isRemote)

{

int l = par1World.getBlockId(par2, par3, par4 - 1);

int i1 = par1World.getBlockId(par2, par3, par4 + 1);

int j1 = par1World.getBlockId(par2 - 1, par3, par4);

int k1 = par1World.getBlockId(par2 + 1, par3, par4);

byte b0 = 3;

 

if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[i1])

{

b0 = 3;

}

 

if (Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[l])

{

b0 = 2;

}

 

if (Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[k1])

{

b0 = 5;

}

 

if (Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[j1])

{

b0 = 4;

}

 

par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 2);

}

}

 

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {

if(!world.isRemote) {

FMLNetworkHandler.openGui(player, moderncraft_mod.instance, moderncraft_mod.guiIdMacerator, world, x, y, z);

}

 

return true;

}

 

/**

* Update which block ID the furnace is using depending on whether or not it is burning

*/

public static void updateFurnaceBlockState(boolean par0, World par1World, int par2, int par3, int par4)

{

int l = par1World.getBlockMetadata(par2, par3, par4);

TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4);

keepMaceratorInventory = true;

 

if (par0)

{

par1World.setBlock(par2, par3, par4, moderncraft_mod.blockMaceratorActive.blockID);

}

else

{

par1World.setBlock(par2, par3, par4, moderncraft_mod.blockMaceratorIdle.blockID);

}

 

keepMaceratorInventory = false;

par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 2);

 

if (tileentity != null)

{

tileentity.validate();

par1World.setBlockTileEntity(par2, par3, par4, tileentity);

}

}

 

/**

* Returns a new instance of a block's tile entity class. Called on placing the block.

*/

public TileEntity createNewTileEntity1(World par1World)

{

return new TileEntityMacerator();

}

 

/**

* Called when the block is placed in the world.

*/

public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)

{

int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

 

if (l == 0)

{

par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2);

}

 

if (l == 1)

{

par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2);

}

 

if (l == 2)

{

par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2);

}

 

if (l == 3)

{

par1World.setBlockMetadataWithNotify(par2, par3, par4, 4, 2);

}

 

if (par6ItemStack.hasDisplayName())

{

((TileEntityMacerator)par1World.getBlockTileEntity(par2, par3, par4)).setGuiDisplayName(par6ItemStack.getDisplayName());

}

}

 

/**

* ejects contained items into the world, and notifies neighbours of an update, as appropriate

*/

public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)

{

if (!keepMaceratorInventory)

{

TileEntityMacerator TileEntityMacerator = (TileEntityMacerator)par1World.getBlockTileEntity(par2, par3, par4);

 

if (TileEntityMacerator != null)

{

for (int j1 = 0; j1 < TileEntityMacerator.getSizeInventory(); ++j1)

{

ItemStack itemstack = TileEntityMacerator.getStackInSlot(j1);

 

if (itemstack != null)

{

float f = this.maceratorRand.nextFloat() * 0.8F + 0.1F;

float f1 = this.maceratorRand.nextFloat() * 0.8F + 0.1F;

float f2 = this.maceratorRand.nextFloat() * 0.8F + 0.1F;

 

while (itemstack.stackSize > 0)

{

int k1 = this.maceratorRand.nextInt(21) + 10;

 

if (k1 > itemstack.stackSize)

{

k1 = itemstack.stackSize;

}

 

itemstack.stackSize -= k1;

EntityItem entityitem = new EntityItem(par1World, (double)((float)par2 + f), (double)((float)par3 + f1), (double)((float)par4 + f2), new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));

 

if (itemstack.hasTagCompound())

{

entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());

}

 

float f3 = 0.05F;

entityitem.motionX = (double)((float)this.maceratorRand.nextGaussian() * f3);

entityitem.motionY = (double)((float)this.maceratorRand.nextGaussian() * f3 + 0.2F);

entityitem.motionZ = (double)((float)this.maceratorRand.nextGaussian() * f3);

par1World.spawnEntityInWorld(entityitem);

}

}

}

 

par1World.func_96440_m(par2, par3, par4, par5);

}

}

 

super.breakBlock(par1World, par2, par3, par4, par5, par6);

}

 

/**

* If this returns true, then comparators facing away from this block will use the value from

* getComparatorInputOverride instead of the actual redstone signal strength.

*/

public boolean hasComparatorInputOverride()

{

return true;

}

 

/**

* If hasComparatorInputOverride returns true, the return value from this is used instead of the redstone signal

* strength when this block inputs to a comparator.

*/

public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5)

{

return Container.calcRedstoneFromInventory((IInventory)par1World.getBlockTileEntity(par2, par3, par4));

}

 

@SideOnly(Side.CLIENT)

 

/**

* only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative)

*/

public int idPicked(World par1World, int par2, int par3, int par4)

{

return moderncraft_mod.blockMaceratorIdle.blockID;

}

 

@Override

public TileEntity createNewTileEntity(World world) {

 

return null;

}

 

}

 

 

 

 

Tile Entity Macerator

 

 

 

package moderncraft;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.inventory.ISidedInventory;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.item.crafting.FurnaceRecipes;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.nbt.NBTTagList;

import net.minecraft.tileentity.TileEntity;

import net.minecraftforge.oredict.OreDictionary;

 

public class TileEntityMacerator extends TileEntity implements ISidedInventory{

private static final int[] slots_top = new int[] {0};

private static final int[] slots_bottom = new int[] {2, 1};

private static final int[] slots_sides = new int[] {1};

 

/**

* The ItemStacks that hold the items currently being used in the furnace

*/

private ItemStack[] slots = new ItemStack[3];

 

/** the speed of this furnace, 200 is normal / how many ticks it takes : 30 ticks = 1 second */

public int maceratingSpeed = 100;

 

/** The number of ticks that the furnace will keep burning */

public int power;

public int maxPower = 15000;

 

/** The number of ticks that the current item has been cooking for */

public int cookTime;

 

private String field_94130_e;

 

    /**

    * Returns the number of slots in the inventory.

    */

    public int getSizeInventory()

    {

        return this.slots.length;

    }

 

    /**

    * Returns the stack in slot i

    */

    public ItemStack getStackInSlot(int par1)

    {

        return this.slots[par1];

    }

 

    /**

    * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a

    * new stack.

    */

    public ItemStack decrStackSize(int par1, int par2)

    {

        if (this.slots[par1] != null)

        {

            ItemStack itemstack;

 

            if (this.slots[par1].stackSize <= par2)

          {

                itemstack = this.slots[par1];

                this.slots[par1] = null;

              return itemstack;

            }

            else

            {

                itemstack = this.slots[par1].splitStack(par2);

 

                if (this.slots[par1].stackSize == 0)

                {

                    this.slots[par1] = null;

              }

 

                return itemstack;

            }

        }

        else

        {

            return null;

        }

    }

 

    /**

    * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -

    * like when you close a workbench GUI.

    */

    public ItemStack getStackInSlotOnClosing(int par1)

    {

        if (this.slots[par1] != null)

        {

            ItemStack itemstack = this.slots[par1];

            this.slots[par1] = null;

            return itemstack;

        }else{

            return null;

        }

    }

 

    /**

    * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).

    */

    public void setInventorySlotContents(int par1, ItemStack par2ItemStack)

    {

        this.slots[par1] = par2ItemStack;

 

        if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())

        {

        par2ItemStack.stackSize = this.getInventoryStackLimit();

        }

    }

 

    /**

    * Returns the name of the inventory.

    */

    public String getInvName()

    {

        return this.isInvNameLocalized() ? this.field_94130_e : "container.macerator";

    }

 

    /**

    * If this returns false, the inventory name will be used as an unlocalized name, and translated into the player's

    * language. Otherwise it will be used directly.

    */

    public boolean isInvNameLocalized()

    {

        return this.field_94130_e != null && this.field_94130_e.length() > 0;

    }

 

    /**

    * Sets the custom display name to use when opening a GUI linked to this tile entity.

    */

    public void setGuiDisplayName(String par1Str)

    {

        this.field_94130_e = par1Str;

    }

 

    /**

    * Reads a tile entity from NBT.

    */

    public void readFromNBT(NBTTagCompound par1NBTTagCompound)

    {

        super.readFromNBT(par1NBTTagCompound);

        NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items");

        this.slots = new ItemStack[this.getSizeInventory()];

 

        for (int i = 0; i < nbttaglist.tagCount(); ++i)

        {

            NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);

            byte b0 = nbttagcompound1.getByte("Slot");

 

            if (b0 >= 0 && b0 < this.slots.length)

            {

                this.slots[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);

            }

        }

 

        this.power = par1NBTTagCompound.getShort("power");

        this.cookTime = par1NBTTagCompound.getShort("CookTime");

 

        if (par1NBTTagCompound.hasKey("CustomName"))

        {

            this.field_94130_e = par1NBTTagCompound.getString("CustomName");

        }

    }

 

    /**

    * Writes a tile entity to NBT.

    */

    public void writeToNBT(NBTTagCompound par1NBTTagCompound)

    {

        super.writeToNBT(par1NBTTagCompound);

        par1NBTTagCompound.setShort("power", (short)this.power);

        par1NBTTagCompound.setShort("CookTime", (short)this.cookTime);

        NBTTagList nbttaglist = new NBTTagList();

 

        for (int i = 0; i < this.slots.length; ++i)

        {

            if (this.slots != null)

            {

                NBTTagCompound nbttagcompound1 = new NBTTagCompound();

                nbttagcompound1.setByte("Slot", (byte)i);

                this.slots.writeToNBT(nbttagcompound1);

                nbttaglist.appendTag(nbttagcompound1);

            }

        }

 

        par1NBTTagCompound.setTag("Items", nbttaglist);

 

        if (this.isInvNameLocalized())

        {

            par1NBTTagCompound.setString("CustomName", this.field_94130_e);

        }

    }

 

    /**

    * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't

    * this more of a set than a get?*

    */

    public int getInventoryStackLimit()

    {

        return 64;

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * Returns an integer between 0 and the passed value representing how close the current item is to being completely

    * cooked

    */

    public int getCookProgressScaled(int par1)

    {

      return this.cookTime * par1 / this.maceratingSpeed;

    }

   

    public int getPowerRemainingScaled(int par1){

        return this.power * par1 / this.maxPower;

    }

 

    /**

    * Returns true if the furnace is currently burning

    */

    public boolean hasPower()

    {

        return this.power > 0;

    }

   

    public boolean isMacerating(){

    return this.cookTime > 0;

    }

 

    /**

    * Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count

    * ticks and creates a new spawn inside its implementation.

    */

    public void updateEntity(){

    boolean flag = this.power > 0;

        boolean flag1 = false;

   

        if (hasPower() && isMacerating()){

            this.power--;

        }

 

        if (!this.worldObj.isRemote){

            if (this.power < this.maxPower && this.getItemPower(this.slots[1]) > 0){

            this.power += getItemPower(this.slots[1]);

 

            flag1 = true;

           

            if (this.slots[1] != null){

                    this.slots[1].stackSize--;

 

                    if (this.slots[1].stackSize == 0){

                        this.slots[1] = this.slots[1].getItem().getContainerItemStack(slots[1]);

                    }

                }               

            }

 

            if (this.hasPower() && this.canSmelt())

            {

                ++this.cookTime;

 

                if (this.cookTime == this.maceratingSpeed)

                {

                    this.cookTime = 0;

                    this.smeltItem();

                  flag1 = true;

                }

            }

            else

            {

                this.cookTime = 0;

            }

 

            if (flag != this.power > 0)

            {

                flag1 = true;

                BlockMacerator.updateFurnaceBlockState(this.power > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);

            }

        }

 

        if (flag1){

            this.onInventoryChanged();

        }

    }

   

    public boolean isOre(ItemStack itemstack){

    String[] oreNames = OreDictionary.getOreNames();

   

    for(int i = 0; i < oreNames.length; i++){

    if(oreNames.contains("ore")){

    if(OreDictionary.getOres(oreNames) != null){

    if(OreDictionary.getOres(oreNames).get(0).itemID == itemstack.itemID){

    return true;       

    }

    }

    }

    }

   

    return false;

    }

 

    /**

    * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.

    */

    private boolean canSmelt(){

        if (this.slots[0] == null){

            return false;

        }else{

            ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.slots[0]);

            if(itemstack == null) return false;

            if(!isOre(this.slots[0])) return false;

            if(this.slots[2] == null) return true;

            if(!this.slots[2].isItemEqual(itemstack)) return false;

            int result = slots[2].stackSize + (itemstack.stackSize*2);

            return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize());

        }

    }

 

    /**

    * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack

    */

    public void smeltItem(){

        if(this.canSmelt()){

            ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.slots[0]);

           

            if(this.slots[2] == null){

                this.slots[2] = itemstack.copy();

                this.slots[2].stackSize*=2;

            }else if (this.slots[2].isItemEqual(itemstack)){

                slots[2].stackSize += (itemstack.stackSize*2);

            }

 

            --this.slots[0].stackSize;

 

            if(this.slots[0].stackSize <= 0){

                this.slots[0] = null;

            }

        }

    }

 

 

    /**

    * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't

    * fuel

    */

    public static int getItemPower(ItemStack par0ItemStack){

        if (par0ItemStack == null){

            return 0;

        }else{

        int i = par0ItemStack.getItem().itemID;

       

        if (i == Item.redstone.itemID) return 10;

            return 0;

        }

    }

 

    /**

    * Return true if item is a fuel source (getItempower() > 0).

    */

    public static boolean isItemFuel(ItemStack par0ItemStack)

    {

        return getItemPower(par0ItemStack) > 0;

    }

 

    /**

    * Do not make give this method the name canInteractWith because it clashes with Container

    */

    public boolean isUseableByPlayer1(EntityPlayer par1EntityPlayer)

    {

        return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;

    }

 

    public void openChest() {}

 

    public void closeChest() {}

 

    /**

    * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.

*/

public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack)

{

return par1 == 2 ? false : (par1 == 1 ? isItemFuel(par2ItemStack) : true);

}

 

    /**

    * Returns an array containing the indices of the slots that can be accessed by automation on the given side of this

    * block.

    */

    public int[] getAccessibleSlotsFromSide(int par1)

    {

        return par1 == 0 ? slots_bottom : (par1 == 1 ? slots_top : slots_sides);

    }

 

    /**

    * Returns true if automation can insert the given item in the given slot from the given side. Args: Slot, item,

    * side

    */

    public boolean canInsertItem(int par1, ItemStack par2ItemStack, int par3)

{

        return this.isItemValidForSlot(par1, par2ItemStack);

    }

 

    /**

    * Returns true if automation can extract the given item in the given slot from the given side. Args: Slot, item,

    * side

    */

    public boolean canExtractItem(int par1, ItemStack par2ItemStack, int par3)

{

      return par3 != 0 || par1 != 1 || par2ItemStack.itemID == Item.bucketEmpty.itemID;

}

 

@Override

public boolean isUseableByPlayer(EntityPlayer entityplayer) {

// TODO Auto-generated method stub

return false;

}

}

 

 

 

GuiMacerator

 

 

 

package moderncraft;

 

import org.lwjgl.opengl.GL11;

 

import net.minecraft.client.Minecraft;

import net.minecraft.client.gui.inventory.GuiContainer;

import net.minecraft.client.resources.I18n;

import net.minecraft.entity.player.InventoryPlayer;

import net.minecraft.util.ResourceLocation;

 

public class GuiMacerator extends GuiContainer{

public static final ResourceLocation texture = new ResourceLocation(moderncraft_mod.modid, "textures/gui/macerator.png");

 

public TileEntityMacerator macerator;

 

public GuiMacerator(InventoryPlayer invPlayer, TileEntityMacerator entity) {

super(new ContainerMacerator(invPlayer, entity));

 

this.macerator = entity;

 

this.xSize = 176;

this.ySize = 165;

}

 

public void drawGuiContainerForegroundLayer(int par1, int par2){

String s = this.macerator.isInvNameLocalized() ? this.macerator.getInvName() : I18n.getString(this.macerator.getInvName());

this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);

this.fontRenderer.drawString(I18n.getString("container.inventory"), 8, this.ySize - 96 + 5, 4210752);

}

 

public void drawGuiContainerBackgroundLayer(float f, int j, int i) {

GL11.glColor4f(1F, 1F, 1F, 1F);

 

Minecraft.getMinecraft().getTextureManager().

bindTexture(texture);

 

drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);

 

int i1;

 

if(this.macerator.hasPower()){

i1 = this.macerator.getPowerRemainingScaled(45);

this.drawTexturedModalRect(guiLeft + 8, guiTop + 53 - i1, 176, 62 - i1, 16, i1);

}

 

i1 = this.macerator.getCookProgressScaled(24);

this.drawTexturedModalRect(guiLeft + 79, guiTop + 34, 176, 0, i1 + 1, 16);

}

}

 

 

 

 

 

Container

 

 

 

package moderncraft;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.player.InventoryPlayer;

import net.minecraft.inventory.Container;

import net.minecraft.inventory.ICrafting;

import net.minecraft.inventory.Slot;

import net.minecraft.inventory.SlotFurnace;

import net.minecraft.item.ItemStack;

 

public class ContainerMacerator extends Container

{

private TileEntityMacerator macerator;

private int lastCookTime;

private int lastBurnTime;

 

public ContainerMacerator(InventoryPlayer par1InventoryPlayer, TileEntityMacerator par2TileEntityFurnace)

{

this.macerator = par2TileEntityFurnace;

this.addSlotToContainer(new Slot(par2TileEntityFurnace, 0, 56, 35));

this.addSlotToContainer(new Slot(par2TileEntityFurnace, 1, 8, 56));

this.addSlotToContainer(new SlotFurnace(par1InventoryPlayer.player, par2TileEntityFurnace, 2, 116, 35));

int i;

 

for (i = 0; i < 3; ++i)

{

for (int j = 0; j < 9; ++j)

{

this.addSlotToContainer(new Slot(par1InventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));

}

}

 

for (i = 0; i < 9; ++i)

{

this.addSlotToContainer(new Slot(par1InventoryPlayer, i, 8 + i * 18, 142));

}

}

 

public void addCraftingToCrafters(ICrafting par1ICrafting)

{

super.addCraftingToCrafters(par1ICrafting);

par1ICrafting.sendProgressBarUpdate(this, 0, this.macerator.cookTime);

par1ICrafting.sendProgressBarUpdate(this, 1, this.macerator.power);

}

 

/**

* Looks for changes made in the container, sends them to every listener.

*/

public void detectAndSendChanges()

{

super.detectAndSendChanges();

 

for (int i = 0; i < this.crafters.size(); ++i)

{

ICrafting icrafting = (ICrafting)this.crafters.get(i);

 

if (this.lastCookTime != this.macerator.cookTime)

{

icrafting.sendProgressBarUpdate(this, 0, this.macerator.cookTime);

}

 

if (this.lastBurnTime != this.macerator.power)

{

icrafting.sendProgressBarUpdate(this, 1, this.macerator.power);

}

}

 

this.lastCookTime = this.macerator.cookTime;

this.lastBurnTime = this.macerator.power;

}

 

@SideOnly(Side.CLIENT)

public void updateProgressBar(int par1, int par2)

{

if (par1 == 0)

{

this.macerator.cookTime = par2;

}

 

if (par1 == 1)

{

this.macerator.power = par2;

}

}

 

public boolean canInteractWith1(EntityPlayer par1EntityPlayer)

{

return this.macerator.isUseableByPlayer(par1EntityPlayer);

}

 

/**

* Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.

*/

public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)

{

ItemStack itemstack = null;

Slot slot = (Slot)this.inventorySlots.get(par2);

 

if (slot != null && slot.getHasStack())

{

ItemStack itemstack1 = slot.getStack();

itemstack = itemstack1.copy();

 

if (par2 == 2)

{

if (!this.mergeItemStack(itemstack1, 3, 39, true))

{

return null;

}

 

slot.onSlotChange(itemstack1, itemstack);

}

else if (par2 != 1 && par2 != 0)

{

if (OreRecipes.ores().smelting().getSmeltingResult(itemstack1) != null)

{

if (!this.mergeItemStack(itemstack1, 0, 1, false))

{

return null;

}

}

else if (TileEntityMacerator.isItemFuel(itemstack1))

{

if (!this.mergeItemStack(itemstack1, 1, 2, false))

{

return null;

}

}

else if (par2 >= 3 && par2 < 30)

{

if (!this.mergeItemStack(itemstack1, 30, 39, false))

{

return null;

}

}

else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false))

{

return null;

}

}

else if (!this.mergeItemStack(itemstack1, 3, 39, false))

{

return null;

}

 

if (itemstack1.stackSize == 0)

{

slot.putStack((ItemStack)null);

}

else

{

slot.onSlotChanged();

}

 

if (itemstack1.stackSize == itemstack.stackSize)

{

return null;

}

 

slot.onPickupFromSlot(par1EntityPlayer, itemstack1);

}

 

return itemstack;

}

 

@Override

public boolean canInteractWith(EntityPlayer entityplayer) {

// TODO Auto-generated method stub

return false;

}

}

 

 

 

 

 

 

OreRecipes

 

 

 

package moderncraft;

 

import net.minecraft.block.Block;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.item.crafting.FurnaceRecipes;

 

public class OreRecipes{

 

private static final FurnaceRecipes oreBase = FurnaceRecipes.smelting();

 

public static FurnaceRecipes ores(){

return oreBase;

}

 

static{

oreBase.addSmelting(Block.oreCoal.blockID, new ItemStack(Item.coal), 1F);

}

 

}

 

 

 

 

 

Error report

 

 

 

---- Minecraft Crash Report ----

// My bad.

 

Time: 1/22/14 4:27 PM

Description: Initializing game

 

java.lang.Error: Unresolved compilation problems:

Syntax error on token ";", { expected after this token

Syntax error on token "(", ; expected

Syntax error on token ")", ; expected

 

at moderncraft.moderncraft_mod.<init>(moderncraft_mod.java:52)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at java.lang.Class.newInstance(Unknown Source)

at cpw.mods.fml.common.ILanguageAdapter$JavaAdapter.getNewInstance(ILanguageAdapter.java:174)

at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:518)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:201)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:181)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:112)

at cpw.mods.fml.common.Loader.loadMods(Loader.java:511)

at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:183)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:473)

at net.minecraft.client.Minecraft.run(Minecraft.java:808)

at net.minecraft.client.main.Main.main(Main.java:93)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)

at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at moderncraft.moderncraft_mod.<init>(moderncraft_mod.java:52)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at java.lang.Class.newInstance(Unknown Source)

at cpw.mods.fml.common.ILanguageAdapter$JavaAdapter.getNewInstance(ILanguageAdapter.java:174)

at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:518)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:201)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:181)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:112)

at cpw.mods.fml.common.Loader.loadMods(Loader.java:511)

at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:183)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:473)

 

-- Initialization --

Details:

Stacktrace:

at net.minecraft.client.Minecraft.run(Minecraft.java:808)

at net.minecraft.client.main.Main.main(Main.java:93)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:131)

at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

 

-- System Details --

Details:

Minecraft Version: 1.6.4

Operating System: Windows 7 (amd64) version 6.1

Java Version: 1.7.0_25, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 930494416 bytes (887 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

Suspicious classes: FML and Forge are installed

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v8.11 FML v6.4.49.965 Minecraft Forge 9.11.1.965 4 mods loaded, 4 mods active

mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed

FML{6.4.49.965} [Forge Mod Loader] (bin) Unloaded->Constructed

Forge{9.11.1.965} [Minecraft Forge] (bin) Unloaded->Constructed

ModernCraft{v1} [ModernCraft] (bin) Unloaded

Launched Version: 1.6

LWJGL: 2.9.0

OpenGL: Intel® HD Graphics Family GL version 3.0.0 - Build 8.15.10.2342, Intel

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Resource Pack: Default

Current Language: English (US)

Profiler Position: N/A (disabled)

Vec3 Pool Size: ~~ERROR~~ NullPointerException: null

 

 

 

Posted

Hooray!  You posted code!

 

Boo!  You didn't post the errors!

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Diesieben07 has some advice for you.

 

You can't just write code inside a class outside a method. Please learn basic java before modding.

 

I can't tell where the problem is, even though I know what the problem is.  Because forums are bad at autoformatting.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.