- 93
- 0
Код:
---- Minecraft Crash Report ----
// Don't be sad, have a hug! <3
Time: 27.03.16 22:54
Description: Initializing game
java.lang.NullPointerException: Initializing game
at cpw.mods.fml.common.network.NetworkRegistry.registerGuiHandler(NetworkRegistry.java:219)
at ru.nlo_92.CommonProxy.registerNetworkStuff(CommonProxy.java:16)
at ru.nlo_92.main.load(main.java:590)
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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
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.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
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.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
at cpw.mods.fml.common.Loader.initializeMods(Loader.java:737)
at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:311)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:597)
at net.minecraft.client.Minecraft.run(Minecraft.java:942)
at net.minecraft.client.main.Main.main(Main.java:164)
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:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Stacktrace:
at cpw.mods.fml.common.network.NetworkRegistry.registerGuiHandler(NetworkRegistry.java:219)
at ru.nlo_92.CommonProxy.registerNetworkStuff(CommonProxy.java:16)
at ru.nlo_92.main.load(main.java:590)
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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)
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.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
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.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
at cpw.mods.fml.common.Loader.initializeMods(Loader.java:737)
at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:311)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:597)
-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:942)
at net.minecraft.client.main.Main.main(Main.java:164)
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:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)
-- System Details --
Details:
Minecraft Version: 1.7.10
Operating System: Windows 8.1 (amd64) version 6.3
Java Version: 1.8.0_71, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 806007224 bytes (768 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
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1558 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHI mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
UCHI FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar)
UCHI Forge{10.13.4.1558} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1558-1.7.10.jar)
UCHE mod{1.0.0} [RealLifeРЎraft] (bin)
GL info: ' Vendor: 'Intel' Version: '4.2.0 - Build 10.18.10.3379' Renderer: 'Intel(R) HD Graphics 4400'
Launched Version: 1.7.10
LWJGL: 2.9.1
OpenGL: Intel(R) HD Graphics 4400 GL version 4.2.0 - Build 10.18.10.3379, Intel
GL Caps: Using GL 1.3 multitexturing.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Anisotropic filtering is supported and maximum anisotropy is 16.
Shaders are available because OpenGL 2.1 is supported.
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: Р СѓСЃСЃРєРёР№ (Р РѕСЃСЃРёСЏ)
Profiler Position: N/A (disabled)
Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Anisotropic Filtering: Off (1)
Код:
public class iron_furnace extends BlockContainer{
@SideOnly(Side.CLIENT)
private IIcon top;
@SideOnly(Side.CLIENT)
private IIcon front;
private static boolean isBurning;
private final boolean isBurning2;
private final Random random = new Random();
protected iron_furnace(boolean isActive) {
super(Material.iron);
this.setHarvestLevel("pickaxe", 1);
this.setResistance(0.5F);
isBurning2 = isActive;
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconregister) {
this.blockIcon = iconregister.registerIcon("mod" + ":iron_furnaceSide");
this.front = iconregister.registerIcon(this.isBurning2 ? "mod" + ":iron_furnaceActive" : "mod" + ":iron_furnaceInactive");
this.top = iconregister.registerIcon("mod" + ":iron_furnaceTop");
}
public IIcon getIcon(int side, int meta) {
if (side == 1) {
return top;
} else if (side == 3) {
return front;
} else {
return this.blockIcon;
}
}
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
player.openGui(main.instance, 0, world, x, y, z);
return true;
}
public Item getItemDropped(int par1, Random random, int par3) {
return Item.getItemFromBlock(main.iron_furnace_idle);
}
public Item getItem(World world, int par2, int par3, int par4) {
return Item.getItemFromBlock(main.iron_furnace_idle);
}
/**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
public TileEntity createNewTileEntity(World world, int par2)
{
return new TileEntityiron_furnace();
}
@SideOnly(Side.CLIENT)
public void onBlockAdded(World world, int x, int y, int z) {
super.onBlockAdded(world, x, y, z);
this.direction(world, x, y, z);
}
private void direction(World world, int x, int y, int z) {
if (!world.isRemote) {
Block direction = world.getBlock(x, y, z - 1);
Block direction1 = world.getBlock(x, y, z + 1);
Block direction2 = world.getBlock(x - 1, y, z);
Block direction3 = world.getBlock(x + 1, y, z);
byte byte0 = 3;
if (direction.func_149730_j() && direction.func_149730_j()) {
byte0 = 3;
}
if (direction1.func_149730_j() && direction1.func_149730_j()) {
byte0 = 2;
}
if (direction2.func_149730_j() && direction2.func_149730_j()) {
byte0 = 5;
}
if (direction3.func_149730_j() && direction3.func_149730_j()) {
byte0 = 4;
}
world.setBlockMetadataWithNotify(x, y, z, byte0, 2);
}
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack) {
int direction = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (direction == 0) {
world.setBlockMetadataWithNotify(x, y, z, 2, 2);
}
if (direction == 1) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
if (direction == 2) {
world.setBlockMetadataWithNotify(x, y, z, 3, 2);
}
if (direction == 3) {
world.setBlockMetadataWithNotify(x, y, z, 4, 2);
}
if (itemstack.hasDisplayName()) {
((TileEntityiron_furnace) world.getTileEntity(x, y, z)).furnaceName(itemstack.getDisplayName());
}
}
public static void updateBlockState(boolean burning, World world, int x, int y, int z) {
int direction = world.getBlockMetadata(x, y, z);
TileEntity tileentity = world.getTileEntity(x, y, z);
isBurning = true;
if (burning) {
world.setBlock(x, y, z, main.iron_furnace_active);
} else {
world.setBlock(x, y, z, main.iron_furnace_idle);
}
isBurning = false;
world.setBlockMetadataWithNotify(x, y, z, direction, 2);
if (tileentity != null) {
tileentity.validate();
world.setTileEntity(x, y, z, tileentity);
}
}
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
if (!isBurning) {
TileEntityiron_furnace tileentitytutfurnace = (TileEntityiron_furnace) world.getTileEntity(x, y, z);
if (tileentitytutfurnace != null) {
for (int i = 0; i < tileentitytutfurnace.getSizeInventory(); ++i) {
ItemStack itemstack = tileentitytutfurnace.getStackInSlot(i);
if (itemstack != null) {
float f = this.random.nextFloat() * 0.6F + 0.1F;
float f1 = this.random.nextFloat() * 0.6F + 0.1F;
float f2 = this.random.nextFloat() * 0.6F + 0.1F;
while (itemstack.stackSize > 0) {
int j = this.random.nextInt(21) + 10;
if (j > itemstack.stackSize) {
j = itemstack.stackSize;
}
itemstack.stackSize -= j;
EntityItem entityitem = new EntityItem(world, (double) ((float) x + f), (double) ((float) y + f1), (double) ((float) z + f2), new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
if (itemstack.hasTagCompound()) {
entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
}
float f3 = 0.025F;
entityitem.motionX = (double) ((float) this.random.nextGaussian() * f3);
entityitem.motionY = (double) ((float) this.random.nextGaussian() * f3 + 0.1F);
entityitem.motionZ = (double) ((float) this.random.nextGaussian() * f3);
world.spawnEntityInWorld(entityitem);
}
}
}
world.func_147453_f(x, y, z, block);
}
}
super.breakBlock(world, x, y, z, block, meta);
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
if (this.isBurning2) {
int direction = world.getBlockMetadata(x, y, z);
float xx = (float) x + 0.5F, yy = (float) y + random.nextFloat() * 6.0F / 16.0F, zz = (float) z + 0.5F, xx2 = random.nextFloat() * 0.3F - 0.2F, zz2 = 0.5F;
if (direction == 4) {
world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
} else if (direction == 5) {
world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
} else if (direction == 3) {
world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
} else if (direction == 2) {
world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
}
}
}
}
Код:
public class TileEntityiron_furnace extends TileEntity implements ISidedInventory{
private static final int[] slotsTop = new int[] { 0 };
private static final int[] slotsBottom = new int[] { 2, 1 };
private static final int[] slotsSides = new int[] { 1 };
private ItemStack[] furnaceItemStacks = new ItemStack[3];
public int furnaceBurnTime;
public int currentBurnTime;
public int furnaceCookTime;
private String furnaceName;
public void furnaceName(String string){
this.furnaceName = string;
}
@Override
public int getSizeInventory() {
return this.furnaceItemStacks.length;
}
@Override
public ItemStack getStackInSlot(int slot) {
return this.furnaceItemStacks[slot];
}
@Override
public ItemStack decrStackSize(int par1, int par2) {
if (this.furnaceItemStacks[par1] != null) {
ItemStack itemstack;
if (this.furnaceItemStacks[par1].stackSize <= par2) {
itemstack = this.furnaceItemStacks[par1];
this.furnaceItemStacks[par1] = null;
return itemstack;
} else {
itemstack = this.furnaceItemStacks[par1].splitStack(par2);
if (this.furnaceItemStacks[par1].stackSize == 0) {
this.furnaceItemStacks[par1] = null;
}
return itemstack;
}
} else {
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
if (this.furnaceItemStacks[slot] != null) {
ItemStack itemstack = this.furnaceItemStacks[slot];
this.furnaceItemStacks[slot] = null;
return itemstack;
} else {
return null;
}
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemstack) {
this.furnaceItemStacks[slot] = itemstack;
if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) {
itemstack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public String getInventoryName() {
return this.hasCustomInventoryName() ? this.furnaceName : "Iron furnace";
}
@Override
public boolean hasCustomInventoryName() {
return this.furnaceName != null && this.furnaceName.length() > 0;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
public void readFromNBT(NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
NBTTagList tagList = tagCompound.getTagList("Items", 10);
this.furnaceItemStacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < tagList.tagCount(); ++i) {
NBTTagCompound tabCompound1 = tagList.getCompoundTagAt(i);
byte byte0 = tabCompound1.getByte("Slot");
if (byte0 >= 0 && byte0 < this.furnaceItemStacks.length) {
this.furnaceItemStacks[byte0] = ItemStack.loadItemStackFromNBT(tabCompound1);
}
}
this.furnaceBurnTime = tagCompound.getShort("BurnTime");
this.furnaceCookTime = tagCompound.getShort("CookTime");
this.currentBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);
if (tagCompound.hasKey("CustomName", 8)) {
this.furnaceName = tagCompound.getString("CustomName");
}
}
public void writeToNBT(NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound);
tagCompound.setShort("BurnTime", (short) this.furnaceBurnTime);
tagCompound.setShort("CookTime", (short) this.furnaceBurnTime);
NBTTagList tagList = new NBTTagList();
for (int i = 0; i < this.furnaceItemStacks.length; ++i) {
if (this.furnaceItemStacks[i] != null) {
NBTTagCompound tagCompound1 = new NBTTagCompound();
tagCompound1.setByte("Slot", (byte) i);
this.furnaceItemStacks[i].writeToNBT(tagCompound1);
tagList.appendTag(tagCompound1);
}
}
tagCompound.setTag("Items", tagList);
if (this.hasCustomInventoryName()) {
tagCompound.setString("CustomName", this.furnaceName);
}
}
@SideOnly(Side.CLIENT)
public int getCookProgressScaled(int par1) {
return this.furnaceCookTime * par1 / 200;
}
@SideOnly(Side.CLIENT)
public int getBurnTimeRemainingScaled(int par1) {
if (this.currentBurnTime == 0) {
this.currentBurnTime = 200;
}
return this.furnaceBurnTime * par1 / this.currentBurnTime;
}
public boolean isBurning() {
return this.furnaceBurnTime > 0;
}
public void updateEntity() {
boolean flag = this.furnaceBurnTime > 0;
boolean flag1 = false;
if (this.furnaceBurnTime > 0) {
--this.furnaceBurnTime;
}
if (!this.worldObj.isRemote) {
if (this.furnaceBurnTime == 0 && this.canSmelt()) {
this.currentBurnTime = this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);
if (this.furnaceBurnTime > 0) {
flag1 = true;
if (this.furnaceItemStacks[1] != null) {
--this.furnaceItemStacks[1].stackSize;
if (this.furnaceItemStacks[1].stackSize == 0) {
this.furnaceItemStacks[1] = furnaceItemStacks[1].getItem().getContainerItem(this.furnaceItemStacks[1]);
}
}
}
}
if (this.isBurning() && this.canSmelt()) {
++this.furnaceCookTime;
if (this.furnaceCookTime == 200) {
this.furnaceCookTime = 0;
this.smeltItem();
flag1 = true;
}
} else {
this.furnaceCookTime = 0;
}
}
if (flag != this.furnaceBurnTime > 0) {
flag1 = true;
iron_furnace.updateBlockState(this.furnaceBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
if (flag1) {
this.markDirty();
}
}
private boolean canSmelt() {
if (this.furnaceItemStacks[0] == null) {
return false;
} else {
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);
if (itemstack == null) return false;
if (this.furnaceItemStacks[2] == null) return true;
if (!this.furnaceItemStacks[2].isItemEqual(itemstack)) return false;
int result = furnaceItemStacks[2].stackSize + itemstack.stackSize;
return result <= getInventoryStackLimit() && result <= this.furnaceItemStacks[2].getMaxStackSize();
}
}
public void smeltItem() {
if (this.canSmelt()) {
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);
if (this.furnaceItemStacks[2] == null) {
this.furnaceItemStacks[2] = itemstack.copy();
} else if (this.furnaceItemStacks[2].getItem() == itemstack.getItem()) {
this.furnaceItemStacks[2].stackSize += itemstack.stackSize;
}
--this.furnaceItemStacks[0].stackSize;
if(this.furnaceItemStacks[0].stackSize >= 0){
this.furnaceItemStacks[0] = null;
}
}
}
public static int getItemBurnTime(ItemStack itemstack){
if(itemstack == null){
return 0;
}else{
Item item = itemstack.getItem();
if(item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air){
Block block = Block.getBlockFromItem(item);
if (block == Blocks.wooden_slab)
{
return 150;
}
if (block.getMaterial() == Material.wood)
{
return 300;
}
if (block == Blocks.coal_block)
{
return 16000;
}
}
if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return 200;
if (item instanceof ItemHoe && ((ItemHoe)item).getToolMaterialName().equals("WOOD")) return 200;
if (item == Items.stick) return 100;
if (item == Items.coal) return 1600;
if (item == Items.lava_bucket) return 20000;
if (item == Item.getItemFromBlock(Blocks.sapling)) return 100;
if (item == Items.blaze_rod) return 2400;
return GameRegistry.getFuelValue(itemstack);
}
}
public static boolean isItemFuel(ItemStack itemstack){
return getItemBurnTime(itemstack) > 0;
}
@Override
public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : p_70300_1_.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
}
@Override
public void openInventory() {
// TODO Auto-generated method stub
}
@Override
public void closeInventory() {
// TODO Auto-generated method stub
}
@Override
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
return p_94041_1_ == 2 ? false : (p_94041_1_ == 1 ? isItemFuel(p_94041_2_) : true);
}
@Override
public int[] getAccessibleSlotsFromSide(int p_94128_1_) {
return p_94128_1_ == 0 ? slotsBottom : (p_94128_1_ == 1 ? slotsTop : slotsSides);
}
@Override
public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) {
return this.isItemValidForSlot(p_102007_1_, p_102007_2_);
}
@Override
public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) {
return p_102008_3_ != 0 || p_102008_1_ != 1 || p_102008_2_.getItem() == Items.bucket;
}
}
main(588-591):
Код:
@EventHandler
public static void load(FMLInitializationEvent event){
proxy.registerNetworkStuff();
}
CommonProxy:
Код:
public class CommonProxy {
public void registerRenderers()
{
}
public void registerTileEntities(){
GameRegistry.registerTileEntity(TileEntityiron_furnace.class,"mod" + "TileEntityTutFurnace");
}
public void registerNetworkStuff(){
NetworkRegistry.INSTANCE.registerGuiHandler(main.instance, new GuiHandler());
}
}
Код:
public class GuiHandler implements IGuiHandler {
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if(ID == 0){
TileEntityiron_furnace tileEntityFurnace = (TileEntityiron_furnace) world.getTileEntity(x, y, z);
return new Containeriron_furnace(player.inventory, tileEntityFurnace);
}
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if(ID == 0){
TileEntityiron_furnace tileEntityTestContainer = (TileEntityiron_furnace) world.getTileEntity(x, y, z);
return new Guiiron_furnace(player.inventory, tileEntityTestContainer);
}
return null;
}
}
Код:
public class Containeriron_furnace extends Container{
private TileEntityiron_furnace tileFurnace;
private int lastCookTime;
private int lastBurnTime;
private int lastItemBurnTime;
public Containeriron_furnace(InventoryPlayer player, TileEntityiron_furnace tileEntityFurnace){
this.tileFurnace = tileEntityFurnace;
this.addSlotToContainer(new Slot(tileEntityFurnace, 0, 56, 17));
this.addSlotToContainer(new Slot(tileEntityFurnace, 1, 56, 53));
this.addSlotToContainer(new SlotFurnace(player.player, tileEntityFurnace, 2, 116, 35));
int i;
for(i = 0; i < 3; ++i){
for(int j = 0; j < 9; ++j){
this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for(i = 0; i < 9; ++i){
this.addSlotToContainer(new Slot(player, i , 8 + i * 18 , 142));
}
}
public void addCraftingToCrafters(ICrafting craft){
super.addCraftingToCrafters(craft);
craft.sendProgressBarUpdate(this, 0, this.tileFurnace.furnaceCookTime);
craft.sendProgressBarUpdate(this, 1, this.tileFurnace.furnaceBurnTime);
craft.sendProgressBarUpdate(this, 2, this.tileFurnace.currentBurnTime);
}
public void detectAndSendChanges(){
super.detectAndSendChanges();
for(int i = 0; i < this.crafters.size(); ++i){
ICrafting craft = (ICrafting) this.crafters.get(i);
if(this.lastCookTime != this.tileFurnace.furnaceCookTime){
craft.sendProgressBarUpdate(this, 0, this.tileFurnace.furnaceCookTime);
}
if(this.lastBurnTime != this.tileFurnace.furnaceBurnTime){
craft.sendProgressBarUpdate(this, 1, this.tileFurnace.furnaceBurnTime);
}
if(this.lastItemBurnTime != this.tileFurnace.currentBurnTime){
craft.sendProgressBarUpdate(this, 2, this.tileFurnace.currentBurnTime);
}
}
this.lastBurnTime = this.tileFurnace.furnaceBurnTime;
this.lastCookTime = this.tileFurnace.furnaceCookTime;
this.lastItemBurnTime = this.tileFurnace.currentBurnTime;
}
@SideOnly(Side.CLIENT)
public void updateProgressBar(int par1, int par2){
if(par1 == 0){
this.tileFurnace.furnaceCookTime = par2;
}
if(par1 == 1){
this.tileFurnace.furnaceBurnTime = par2;
}
if(par1 == 2){
this.tileFurnace.currentBurnTime = par2;
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return this.tileFurnace.isUseableByPlayer(player);
}
public ItemStack transferStackInSlot(EntityPlayer player, 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(FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null){
if(!this.mergeItemStack(itemstack1, 0, 1, false)){
return null;
}
}else if(TileEntityiron_furnace.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(player, itemstack1);
}
return itemstack;
}
}
Код:
@SideOnly(Side.CLIENT)
public class Guiiron_furnace extends GuiContainer{
private static final ResourceLocation furnaceGuiTextures = new ResourceLocation("textures/gui/container/iron_furnace_gui.png");
private TileEntityiron_furnace tileFurnace;
public Guiiron_furnace(InventoryPlayer invPlayer, TileEntityiron_furnace tile) {
super(new Containeriron_furnace(invPlayer, tile));
this.tileFurnace = tile;
}
protected void drawGuiContainerForegroundLayer(int par1, int par2){
String string = this.tileFurnace.hasCustomInventoryName() ? this.tileFurnace.getInventoryName() : I18n.format(this.tileFurnace.getInventoryName(), new Object[0]);
this.fontRendererObj.drawString(string, this.xSize / 2 - this.fontRendererObj.getStringWidth(string), 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 94, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(furnaceGuiTextures);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
int i1;
if (this.tileFurnace.isBurning())
{
i1 = this.tileFurnace.getBurnTimeRemainingScaled(12);
this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
}
i1 = this.tileFurnace.getCookProgressScaled(24);
this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
}
}