
TheTroop
Members-
Posts
76 -
Joined
-
Last visited
Everything posted by TheTroop
-
when my entity randomly spawned in nether every mob start flying and in my console strange thing are going on P.S my entity's hends are in his body don't know why
-
delete globalid don't fixed my problem at alll
-
Do you know any tutorial for make spawn egg?
-
Thank you for help but i don't know other way to make spawn egg
-
i delete (EntityRegistry.registerGlobalEntityID(entityClass, entityName, randomId) but now i can't spawn my Entity
-
And how can i replace it?
-
Entity package com.TheTroop.legendrymod.Mobs; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.world.World; public class EntityWiggenMob extends EntityMob{ public EntityWiggenMob(World par1World) { super(par1World); this.setSize(2F, 1.5F); this.tasks.addTask(0, new EntityAIWander(this, 2.0D)); this.isImmuneToFire = true; } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(1.0D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(10.0D); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(55.0F); } } Render package com.TheTroop.legendrymod.render; import com.TheTroop.legendrymod.Mobs.EntityWiggenMob; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; public class RenderWiggenMob extends RenderLiving{ private static final ResourceLocation mobTextures = new ResourceLocation("lm + textures/entity/Wiggen.png"); public RenderWiggenMob(ModelBase parModelBase, float par2) { super(parModelBase, par2); } protected ResourceLocation getEntityTexture(EntityWiggenMob entity){ return mobTextures; } protected ResourceLocation getEntityTexture(Entity entity){ return this.getEntityTexture((EntityWiggenMob)entity); } } model package com.TheTroop.legendrymod.Model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; public class ModelWiggen extends ModelBase { //fields ModelRenderer head; ModelRenderer body; ModelRenderer body2; ModelRenderer body5; ModelRenderer body3; ModelRenderer leftleg; ModelRenderer body4; ModelRenderer body6; ModelRenderer body7; ModelRenderer body8; ModelRenderer body9; ModelRenderer rightleg; ModelRenderer leftarm1; ModelRenderer leftarm2; ModelRenderer rightarm; public ModelWiggen() { textureWidth = 128; textureHeight = 64; head = new ModelRenderer(this, 0, 0); head.addBox(-4F, -8F, -4F, 11, 10, 10); head.setRotationPoint(-1F, -24F, 0F); head.setTextureSize(128, 64); head.mirror = true; setRotation(head, 0F, 0F, 0F); body = new ModelRenderer(this, 1, 46); body.addBox(-9F, 0F, -2F, 18, 5, 10); body.setRotationPoint(0F, -22F, 0F); body.setTextureSize(128, 64); body.mirror = true; setRotation(body, 0F, 0F, 0F); body2 = new ModelRenderer(this, 3, 37); body2.addBox(-3F, -2F, -2F, 4, 12, 10); body2.setRotationPoint(-6F, -16F, 0F); body2.setTextureSize(128, 64); body2.mirror = true; setRotation(body2, 0F, 0F, 0F); body5 = new ModelRenderer(this, 103, 45); body5.addBox(-1F, -3F, -2F, 4, 14, 4); body5.setRotationPoint(-1F, -9F, 6F); body5.setTextureSize(128, 64); body5.mirror = true; setRotation(body5, 0F, 0F, 0F); body3 = new ModelRenderer(this, 0, 44); body3.addBox(-2F, 0F, -2F, 7, 8, 10); body3.setRotationPoint(-2F, -19F, 0F); body3.setTextureSize(128, 64); body3.mirror = true; setRotation(body3, 0F, 0F, 0.4537856F); leftleg = new ModelRenderer(this, 103, 36); leftleg.addBox(-2F, 0F, -2F, 6, 21, 6); leftleg.setRotationPoint(3F, 3F, 2F); leftleg.setTextureSize(128, 64); leftleg.mirror = true; setRotation(leftleg, 0F, 0F, 0F); body4 = new ModelRenderer(this, 5, 34); body4.addBox(0F, -6F, 0F, 4, 19, 10); body4.setRotationPoint(2F, -17F, -2F); body4.setTextureSize(128, 64); body4.mirror = true; setRotation(body4, 0F, 0F, 0.9075712F); body6 = new ModelRenderer(this, 81, 55); body6.addBox(-9F, -5F, 3F, 18, 4, 4); body6.setRotationPoint(0F, -2F, 0F); body6.setTextureSize(128, 64); body6.mirror = true; setRotation(body6, 0F, 0F, 0F); body7 = new ModelRenderer(this, 84, 48); body7.addBox(0F, -2F, 0F, 4, 4, 10); body7.setRotationPoint(5F, -5F, -3F); body7.setTextureSize(128, 64); body7.mirror = true; setRotation(body7, 0F, 0F, 0F); body8 = new ModelRenderer(this, 71, 48); body8.addBox(0F, 1F, 1F, 18, 4, 10); body8.setRotationPoint(-9F, 0F, -3F); body8.setTextureSize(128, 64); body8.mirror = true; setRotation(body8, 0F, 0F, 0F); body9 = new ModelRenderer(this, 86, 48); body9.addBox(0F, 0F, 0F, 4, 4, 10); body9.setRotationPoint(-9F, -7F, -3F); body9.setTextureSize(128, 64); body9.mirror = true; setRotation(body9, 0F, 0F, 0F); rightleg = new ModelRenderer(this, 103, 36); rightleg.addBox(0F, 0F, -2F, 6, 21, 6); rightleg.setRotationPoint(-7F, 3F, 2F); rightleg.setTextureSize(128, 64); rightleg.mirror = true; setRotation(rightleg, 0F, 0F, 0F); leftarm1 = new ModelRenderer(this, 7, 48); leftarm1.addBox(0F, 0F, 0F, 8, 5, ; leftarm1.setRotationPoint(9F, -21.26667F, -1F); leftarm1.setTextureSize(128, 64); leftarm1.mirror = true; setRotation(leftarm1, 0F, 0F, 0F); leftarm1.addChild(leftarm2); leftarm2 = new ModelRenderer(this, 103, 36); leftarm2.addBox(0F, 0F, 0F, 6, 21, 6); leftarm2.setRotationPoint(10F, -17F, 0F); leftarm2.setTextureSize(128, 64); leftarm2.mirror = true; setRotation(leftarm2, 0F, 0F, 0F); rightarm = new ModelRenderer(this, 0, 30); rightarm.addBox(0F, 0F, 0F, 8, 24, ; rightarm.setRotationPoint(-17F, -21F, 0F); rightarm.setTextureSize(128, 64); rightarm.mirror = true; setRotation(rightarm, 0F, 0F, 0F); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); head.render(f5); body.render(f5); body2.render(f5); body5.render(f5); body3.render(f5); leftleg.render(f5); body4.render(f5); body6.render(f5); body7.render(f5); body8.render(f5); body9.render(f5); rightleg.render(f5); leftarm1.render(f5); leftarm2.render(f5); rightarm.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.head.rotateAngleY = f3 / (180F / (float)Math.PI); this.head.rotateAngleX = f4 / (180F / (float)Math.PI); this.rightarm.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 2.0F * f1 * 0.5F; this.leftarm1.rotateAngleX = MathHelper.cos(f * 0.6662F) * 2.0F * f1 * 0.5F; this.rightarm.rotateAngleZ = 0.0F; this.leftarm1.rotateAngleZ = 0.0F; this.rightleg.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1; this.leftleg.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4F * f1; this.rightleg.rotateAngleY = 0.0F; this.leftleg.rotateAngleY = 0.0F; } } registry package com.TheTroop.legendrymod.Mobs; import net.minecraft.entity.EntityList; import net.minecraft.entity.EnumCreatureType; import net.minecraft.world.biome.BiomeGenBase; import cpw.mods.fml.common.registry.EntityRegistry; import com.TheTroop.legendrymod.LegendryMod; public class EntityMobs { public static void mainRegistry() { registerEntity(); } public static void registerEntity() { createEntity(EntityWiggenMob.class, "Wiggen Mob", 0x6E2B2C, 0x2B0D0E); } public static void createEntity(Class entityClass, String entityName, int solidColor, int spotColor){ int randomId = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerGlobalEntityID(entityClass, entityName, randomId); EntityRegistry.registerModEntity(entityClass, entityName, randomId, LegendryMod.instance, 64, 1, true); EntityRegistry.addSpawn(entityClass, 2, 0, 1, EnumCreatureType.creature, BiomeGenBase.hell); createEgg(randomId, solidColor, spotColor); } private static void createEgg(int randomId, int solidColor, int spotColor){ EntityList.entityEggs.put(Integer.valueOf(randomId), new EntityList.EntityEggInfo(randomId, solidColor, randomId)); } }
-
when i spawn my entty minecraft goes crazy Pic:http://pixs.ru/showimage/2015080418_2831775_18284710.png I Don't know what is the problem
-
I restore my mod folder from my pc to my leptop and when i open it with eclipse i have this error: The project description file (.project) for 'Minecraft' is missing. This file contains important information about the project. The project will not function properly until this file is restored.
-
i am creating new mod but on holideys i am going in another country i need to move my mod to my leptop when i try to move folder and open it with eclipse he say thet he can't find something in .project and before it relocate it can't be open Sorry for my bed english hope you understand what i tryed to say
-
I want to make a arrow, when thrown by a arrow to a mob, make a lightning, but I dont know the code... Sorry for my bad english, hope you can understand what I want and hope you can help me... Thanks!
-
[1.7.10] My custom furnace doesn't change his texture when it's active
TheTroop replied to TheTroop's topic in Modder Support
can anyone help? -
My custom furnace doesn't change his texture when it's active Block class package com.TheTroop.legendrymod; import java.util.Random; import cpw.mods.fml.common.network.internal.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.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class blockOven extends BlockContainer{ private Random rand; private final boolean isActive; private static boolean keepInventory = false; @SideOnly(Side.CLIENT) private IIcon iconFront; public blockOven(boolean blockState) { super(Material.iron); rand = new Random(); isActive = blockState; } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon("lm" + ":" + (this.isActive ? "blockOvenSideOn" : "blockOvenSideOff")); this.iconFront = iconRegister.registerIcon("lm" + ":" + (this.isActive ? "blockOvenFrontOn" : "blockOvenFrontOff")); } @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int metadata) { return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : this.blockIcon); } public void onBlockAdded(World world, int x, int y, int z) { super.onBlockAdded(world, x, y, z); this.setDefaultDirection(world, x, y, z); } private void setDefaultDirection(World world, int x, int y, int z) { if(!world.isRemote) { Block block1 = world.getBlock(x, y, z - 1); Block block2 = world.getBlock(x, y, z +1); Block block3 = world.getBlock(x - 1, y, z); Block block4 = world.getBlock(x + 1, y, z); byte b0 = 3; if(block1.func_149730_j() && !block2.func_149730_j()) { b0 = 3; } if(block1.func_149730_j() && !block1.func_149730_j()) { b0 = 2; } if(block1.func_149730_j() && !block4.func_149730_j()) { b0 = 5; } if(block1.func_149730_j() && !block3.func_149730_j()) { b0 = 4; } world.setBlockMetadataWithNotify(x, y, z, b0, 2); } } public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityPlayer, ItemStack itemstack) { int i = MathHelper.floor_double((double)(entityPlayer.rotationYaw * 4.0F / 360F) + 0.5D) & 3; if(i == 0) { world.setBlockMetadataWithNotify(x, y, z, 2, 2); } if(i == 1) { world.setBlockMetadataWithNotify(x, y, z, 5, 2); } if(i == 2) { world.setBlockMetadataWithNotify(x, y, z, 3, 2); } if(i == 3) { world.setBlockMetadataWithNotify(x, y, z, 4, 2); } if(itemstack.hasDisplayName()) { //((TileEntityblockOven)world.getTileEntity(x, y, z)).setCustomName(itemstack.getDisplayName()); } } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if (world.isRemote) { return true; }else if (!player.isSneaking()) { TileEntityblockOven entity = (TileEntityblockOven) world.getTileEntity(x, y, z); if (entity != null) { FMLNetworkHandler.openGui(player, LegendryMod.instance, LegendryMod.guiIDblockOven, world, x, y, z); } return true; }else{ return false; } } @Override public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { return new TileEntityblockOven(); } public static void updateBlockState(boolean isMashing, World world, int xCoord, int yCoord, int zCoord) { int i = world.getBlockMetadata(xCoord, yCoord, zCoord); TileEntity entity = world.getTileEntity(xCoord, yCoord, zCoord); keepInventory = true; if (isMashing) { world.setBlock(yCoord, yCoord, zCoord, LegendryMod.blockOvenActive); }else{ world.setBlock(yCoord, yCoord, zCoord, LegendryMod.blockOvenIdle); } keepInventory = false; world.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, i, 2); if (entity != null) { entity.validate(); world.setTileEntity(xCoord, yCoord, zCoord, entity); } } }
-
[1.7.10] Custom Furnace save items only in slot 0.
TheTroop replied to TheTroop's topic in Modder Support
my furnace put items from slots 1,2 and 3 only in slot 0 and only saving items in slot 0 if i put items in slot 1,2 or 3 it is't saving items in it and put this items only in slot 0 -
[1.7.10] Custom Furnace save items only in slot 0.
TheTroop replied to TheTroop's topic in Modder Support
Well, you don't save empty slots. So when you have in slots: 1- something 2 - null 3 - something You save: 1 - yes 2 - no 3 - yes In result you get: 1 - something 2 - something Because you haven't added anything to 2nd place of list, so all moves down... and how can i fix it? -
My custom furnace only save items in slot 0 if slot 0 is empty furnace puts item from slot 1,2 or 3 into slot 0 package com.TheTroop.legendrymod; import com.TheTroop.legendrymod.Crafting.blockOvenRecipes; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; public class TileEntityblockOven extends TileEntity implements ISidedInventory{ private ItemStack slots[]; public int dualPower; public int dualCookTime; public static final int maxPower = 10000; public static final int mashingSpeed = 100; private static final int[] slots_top = new int[] {0, 1}; private static final int[] slots_bottom = new int[] {3}; private static final int[] slots_side = new int[] {2}; private String customName; public TileEntityblockOven() { slots = new ItemStack[4]; } @Override public int getSizeInventory() { return slots.length; } @Override public ItemStack getStackInSlot(int i) { return slots[i]; } @Override public ItemStack getStackInSlotOnClosing(int i) { if (slots[i] != null) { ItemStack itemstack = slots[i]; slots[i] = null; return itemstack; }else{ return null; } } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { slots[i] = itemstack; if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { itemstack.stackSize = getInventoryStackLimit(); } } @Override public String getInventoryName() { return this.hasCustomInventoryName() ? this.customName : "container.blockOven"; } @Override public boolean hasCustomInventoryName() { return this.customName != null && this.customName.length() > 0; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { return false; }else{ return player.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64; } } public void openInventory() {} public void closeInventory() {} @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return i == 2? false : (i == 1 ? hasItemPower(itemstack) : true); } public boolean hasItemPower(ItemStack itemstack) { return getItemPower(itemstack) > 0; } private static int getItemPower (ItemStack itemstack) { if (itemstack == null) { return 0; }else{ Item item = itemstack.getItem(); if(item == LegendryMod.Fgem) return 50; return 0; } } public ItemStack decrStackSize(int i, int j) { if (slots[i] != null) { if (slots[i].stackSize <= j) { ItemStack itemstack = slots[i]; slots[i] = null; return itemstack; } ItemStack itemstack1 = slots[i].splitStack(j); if (slots[i].stackSize == 0) { slots[i] = null; } return itemstack1; }else{ return null; } } public void readFromNBT (NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList list = nbt.getTagList("Items", 10); this.slots = new ItemStack[getSizeInventory()]; for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound nbt1 = (NBTTagCompound)list.getCompoundTagAt(i) ; byte b0 =nbt1.getByte("slot"); if (b0 >= 0 && b0 < slots.length) { this.slots[b0] = ItemStack.loadItemStackFromNBT(nbt1); } } dualPower = nbt.getShort("PowerTime"); dualCookTime = nbt.getShort("CookTime"); } public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setShort("PowerTime", (short)dualPower); nbt.setShort("CookTime", (short) dualCookTime); NBTTagList list = new NBTTagList(); for(int i = 0; i < slots.length; i++) { if(slots[i] != null) { NBTTagCompound nbt1 = new NBTTagCompound(); nbt1.setByte("Slot", (byte)i); slots[i].writeToNBT(nbt1); list.appendTag(nbt1); } } nbt.setTag("Items", list); } @Override public int[] getAccessibleSlotsFromSide (int i) { return i == 0 ? slots_bottom : (i == 1 ? slots_top : slots_side); } @Override public boolean canInsertItem(int var1, ItemStack itemstack, int p_102007_3_) { return this.isItemValidForSlot(var1, itemstack); } @Override public boolean canExtractItem(int i, ItemStack itemstack, int j) { return j != 0 || i != 1 || itemstack.getItem() == Items.bucket; } public int getMasherProgressScaled(int i) { return (dualCookTime * i) / this.mashingSpeed; } public int getPowerRemainingScaled(int i) { return (dualPower * i) / maxPower; } private boolean canMash() { if (slots[0] == null || slots[1] == null) { return false; } ItemStack itemstack = blockOvenRecipes.getMashingResult(slots[0].getItem(), slots[1].getItem()); if (itemstack == null) { return false; } if (slots[3] == null) { return true; } if (!slots[3].isItemEqual(itemstack)) { return false; } if (slots[3].stackSize < getInventoryStackLimit() && slots[3].stackSize < slots[3].getMaxStackSize()) { return true; }else{ return slots[3].stackSize < itemstack.getMaxStackSize(); } } private void mashItem() { if (canMash()) { ItemStack itemstack = blockOvenRecipes.getMashingResult(slots[0].getItem(), slots[1].getItem()); if (slots[3] == null) { slots[3] = itemstack.copy(); }else if (slots[3].isItemEqual(itemstack)) { slots[3].stackSize += itemstack.stackSize; } for (int i = 0; i < 2; i++) { if (slots[i].stackSize <= 0) { slots[i] = new ItemStack(slots[i].getItem().setFull3D()); }else{ slots[i].stackSize--; } if(slots[i].stackSize <= 0) { slots[i] = null; } } } } public boolean hasPower() { return dualPower > 0; } public boolean isMashing () { return this.dualCookTime >0; } public void updateEntity() { boolean flag = this.hasPower(); boolean flag1 = false; if(hasPower() && this.isMashing()) { this.dualPower--; } if(!worldObj.isRemote) { if (this.hasItemPower(this.slots[2]) && this.dualPower < (this.maxPower - this.getItemPower(this.slots[2]))) { this.dualPower += getItemPower(this.slots[2]); if(this.slots[2] != null) { flag1 = true; this.slots[2].stackSize--; if(this.slots[2].stackSize == 0) { this.slots[2] = this.slots[2].getItem().getContainerItem(this.slots[2]); } } } if (hasPower() && canMash()) { dualCookTime++; if (this.dualCookTime == this.mashingSpeed) { this.dualCookTime = 0; this.mashItem(); flag1 = true; } }else{ dualCookTime = 0; } if (flag != this.isMashing()) { flag1 = true; blockOven.updateBlockState(this.isMashing(), this.worldObj, this.xCoord, this.yCoord, this.zCoord); } } if (flag1) { this.markDirty(); } } }
-
My custom furnace only save items in slot 0 if slot 0 is empty furnace puts item from slot 1,2 or 3 into slot 0 package com.TheTroop.legendrymod; import com.TheTroop.legendrymod.Crafting.blockOvenRecipes; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; public class TileEntityblockOven extends TileEntity implements ISidedInventory{ private ItemStack slots[]; public int dualPower; public int dualCookTime; public static final int maxPower = 10000; public static final int mashingSpeed = 100; private static final int[] slots_top = new int[] {0, 1}; private static final int[] slots_bottom = new int[] {3}; private static final int[] slots_side = new int[] {2}; private String customName; public TileEntityblockOven() { slots = new ItemStack[4]; } @Override public int getSizeInventory() { return slots.length; } @Override public ItemStack getStackInSlot(int i) { return slots[i]; } @Override public ItemStack getStackInSlotOnClosing(int i) { if (slots[i] != null) { ItemStack itemstack = slots[i]; slots[i] = null; return itemstack; }else{ return null; } } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { slots[i] = itemstack; if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { itemstack.stackSize = getInventoryStackLimit(); } } @Override public String getInventoryName() { return this.hasCustomInventoryName() ? this.customName : "container.blockOven"; } @Override public boolean hasCustomInventoryName() { return this.customName != null && this.customName.length() > 0; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { return false; }else{ return player.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64; } } public void openInventory() {} public void closeInventory() {} @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return i == 2? false : (i == 1 ? hasItemPower(itemstack) : true); } public boolean hasItemPower(ItemStack itemstack) { return getItemPower(itemstack) > 0; } private static int getItemPower (ItemStack itemstack) { if (itemstack == null) { return 0; }else{ Item item = itemstack.getItem(); if(item == LegendryMod.Fgem) return 50; return 0; } } public ItemStack decrStackSize(int i, int j) { if (slots[i] != null) { if (slots[i].stackSize <= j) { ItemStack itemstack = slots[i]; slots[i] = null; return itemstack; } ItemStack itemstack1 = slots[i].splitStack(j); if (slots[i].stackSize == 0) { slots[i] = null; } return itemstack1; }else{ return null; } } public void readFromNBT (NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList list = nbt.getTagList("Items", 10); this.slots = new ItemStack[getSizeInventory()]; for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound nbt1 = (NBTTagCompound)list.getCompoundTagAt(i) ; byte b0 =nbt1.getByte("slot"); if (b0 >= 0 && b0 < slots.length) { this.slots[b0] = ItemStack.loadItemStackFromNBT(nbt1); } } dualPower = nbt.getShort("PowerTime"); dualCookTime = nbt.getShort("CookTime"); } public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setShort("PowerTime", (short)dualPower); nbt.setShort("CookTime", (short) dualCookTime); NBTTagList list = new NBTTagList(); for(int i = 0; i < slots.length; i++) { if(slots[i] != null) { NBTTagCompound nbt1 = new NBTTagCompound(); nbt1.setByte("Slot", (byte)i); slots[i].writeToNBT(nbt1); list.appendTag(nbt1); } } nbt.setTag("Items", list); } @Override public int[] getAccessibleSlotsFromSide (int i) { return i == 0 ? slots_bottom : (i == 1 ? slots_top : slots_side); } @Override public boolean canInsertItem(int var1, ItemStack itemstack, int p_102007_3_) { return this.isItemValidForSlot(var1, itemstack); } @Override public boolean canExtractItem(int i, ItemStack itemstack, int j) { return j != 0 || i != 1 || itemstack.getItem() == Items.bucket; } public int getMasherProgressScaled(int i) { return (dualCookTime * i) / this.mashingSpeed; } public int getPowerRemainingScaled(int i) { return (dualPower * i) / maxPower; } private boolean canMash() { if (slots[0] == null || slots[1] == null) { return false; } ItemStack itemstack = blockOvenRecipes.getMashingResult(slots[0].getItem(), slots[1].getItem()); if (itemstack == null) { return false; } if (slots[3] == null) { return true; } if (!slots[3].isItemEqual(itemstack)) { return false; } if (slots[3].stackSize < getInventoryStackLimit() && slots[3].stackSize < slots[3].getMaxStackSize()) { return true; }else{ return slots[3].stackSize < itemstack.getMaxStackSize(); } } private void mashItem() { if (canMash()) { ItemStack itemstack = blockOvenRecipes.getMashingResult(slots[0].getItem(), slots[1].getItem()); if (slots[3] == null) { slots[3] = itemstack.copy(); }else if (slots[3].isItemEqual(itemstack)) { slots[3].stackSize += itemstack.stackSize; } for (int i = 0; i < 2; i++) { if (slots[i].stackSize <= 0) { slots[i] = new ItemStack(slots[i].getItem().setFull3D()); }else{ slots[i].stackSize--; } if(slots[i].stackSize <= 0) { slots[i] = null; } } } } public boolean hasPower() { return dualPower > 0; } public boolean isMashing () { return this.dualCookTime >0; } public void updateEntity() { boolean flag = this.hasPower(); boolean flag1 = false; if(hasPower() && this.isMashing()) { this.dualPower--; } if(!worldObj.isRemote) { if (this.hasItemPower(this.slots[2]) && this.dualPower < (this.maxPower - this.getItemPower(this.slots[2]))) { this.dualPower += getItemPower(this.slots[2]); if(this.slots[2] != null) { flag1 = true; this.slots[2].stackSize--; if(this.slots[2].stackSize == 0) { this.slots[2] = this.slots[2].getItem().getContainerItem(this.slots[2]); } } } if (hasPower() && canMash()) { dualCookTime++; if (this.dualCookTime == this.mashingSpeed) { this.dualCookTime = 0; this.mashItem(); flag1 = true; } }else{ dualCookTime = 0; } if (flag != this.isMashing()) { flag1 = true; blockOven.updateBlockState(this.isMashing(), this.worldObj, this.xCoord, this.yCoord, this.zCoord); } } if (flag1) { this.markDirty(); } } }
-
[1.7.10] My custom furnace doesn't save item when i restar minecraft
TheTroop replied to TheTroop's topic in Modder Support
now it is saving only in slot 0 and if lot 0 empty and i put item in slot 1, 2 or 3 it put this item in slot 0 -
[1.7.10] My custom furnace doesn't save item when i restar minecraft
TheTroop replied to TheTroop's topic in Modder Support
package com.TheTroop.legendrymod; import com.TheTroop.legendrymod.Crafting.blockOvenRecipes; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; public class TileEntityblockOven extends TileEntity implements ISidedInventory{ private ItemStack slots[]; public int dualPower; public int dualCookTime; public static final int maxPower = 10000; public static final int mashingSpeed = 100; private static final int[] slots_top = new int[] {0, 1}; private static final int[] slots_bottom = new int[] {3}; private static final int[] slots_side = new int[] {2}; private String customName; public TileEntityblockOven() { slots = new ItemStack[4]; } @Override public int getSizeInventory() { return slots.length; } @Override public ItemStack getStackInSlot(int i) { return slots[i]; } @Override public ItemStack getStackInSlotOnClosing(int i) { if (slots[i] != null) { ItemStack itemstack = slots[i]; slots[i] = null; return itemstack; }else{ return null; } } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { slots[i] = itemstack; if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { itemstack.stackSize = getInventoryStackLimit(); } } @Override public String getInventoryName() { return this.hasCustomInventoryName() ? this.customName : "container.blockOven"; } @Override public boolean hasCustomInventoryName() { return this.customName != null && this.customName.length() > 0; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) { return false; }else{ return player.getDistanceSq((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64; } } public void openInventory() {} public void closeInventory() {} @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return i == 2? false : (i == 1 ? hasItemPower(itemstack) : true); } public boolean hasItemPower(ItemStack itemstack) { return getItemPower(itemstack) > 0; } private static int getItemPower (ItemStack itemstack) { if (itemstack == null) { return 0; }else{ Item item = itemstack.getItem(); if(item == LegendryMod.Fgem) return 50; return 0; } } public ItemStack decrStackSize(int i, int j) { if (slots[i] != null) { if (slots[i].stackSize <= j) { ItemStack itemstack = slots[i]; slots[i] = null; return itemstack; } ItemStack itemstack1 = slots[i].splitStack(j); if (slots[i].stackSize == 0) { slots[i] = null; } return itemstack1; }else{ return null; } } public void redFromNBT (NBTTagCompound nbt) { super.readFromNBT(nbt); NBTTagList list = nbt.getTagList("Items", 10); this.slots = new ItemStack[getSizeInventory()]; for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound nbt1 = (NBTTagCompound)list.getCompoundTagAt(i) ; byte b0 =nbt1.getByte("slot"); if (b0 >= 0 && b0 < slots.length) { this.slots[b0] = ItemStack.loadItemStackFromNBT(nbt1); } } dualPower = nbt.getShort("PowerTime"); dualCookTime = nbt.getShort("CookTime"); } public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setShort("PowerTime", (short)dualPower); nbt.setShort("CookTime", (short) dualCookTime); NBTTagList list = new NBTTagList(); for(int i = 0; i < slots.length; i++) { if(slots[i] != null) { NBTTagCompound nbt1 = new NBTTagCompound(); nbt1.setByte("Slot", (byte)i); slots[i].writeToNBT(nbt1); list.appendTag(nbt1); } } nbt.setTag("Items", list); } @Override public int[] getAccessibleSlotsFromSide (int i) { return i == 0 ? slots_bottom : (i == 1 ? slots_top : slots_side); } @Override public boolean canInsertItem(int var1, ItemStack itemstack, int p_102007_3_) { return this.isItemValidForSlot(var1, itemstack); } @Override public boolean canExtractItem(int i, ItemStack itemstack, int j) { return j != 0 || i != 1 || itemstack.getItem() == Items.bucket; } public int getMasherProgressScaled(int i) { return (dualCookTime * i) / this.mashingSpeed; } public int getPowerRemainingScaled(int i) { return (dualPower * i) / maxPower; } private boolean canMash() { if (slots[0] == null || slots[1] == null) { return false; } ItemStack itemstack = blockOvenRecipes.getMashingResult(slots[0].getItem(), slots[1].getItem()); if (itemstack == null) { return false; } if (slots[3] == null) { return true; } if (!slots[3].isItemEqual(itemstack)) { return false; } if (slots[3].stackSize < getInventoryStackLimit() && slots[3].stackSize < slots[3].getMaxStackSize()) { return true; }else{ return slots[3].stackSize < itemstack.getMaxStackSize(); } } private void mashItem() { if (canMash()) { ItemStack itemstack = blockOvenRecipes.getMashingResult(slots[0].getItem(), slots[1].getItem()); if (slots[3] == null) { slots[3] = itemstack.copy(); }else if (slots[3].isItemEqual(itemstack)) { slots[3].stackSize += itemstack.stackSize; } for (int i = 0; i < 2; i++) { if (slots[i].stackSize <= 0) { slots[i] = new ItemStack(slots[i].getItem().setFull3D()); }else{ slots[i].stackSize--; } if(slots[i].stackSize <= 0) { slots[i] = null; } } } } public boolean hasPower() { return dualPower > 0; } public boolean isMashing () { return this.dualCookTime >0; } public void updateEntity() { boolean flag = this.hasPower(); boolean flag1 = false; if(hasPower() && this.isMashing()) { this.dualPower--; } if(!worldObj.isRemote) { if (this.hasItemPower(this.slots[2]) && this.dualPower < (this.maxPower - this.getItemPower(this.slots[2]))) { this.dualPower += getItemPower(this.slots[2]); if(this.slots[2] != null) { flag1 = true; this.slots[2].stackSize--; if(this.slots[2].stackSize == 0) { this.slots[2] = this.slots[2].getItem().getContainerItem(this.slots[2]); } } } if (hasPower() && canMash()) { dualCookTime++; if (this.dualCookTime == this.mashingSpeed) { this.dualCookTime = 0; this.mashItem(); flag1 = true; } }else{ dualCookTime = 0; } if (flag != this.isMashing()) { flag1 = true; blockOven.updateBlockState(this.isMashing(), this.worldObj, this.xCoord, this.yCoord, this.zCoord); } } if (flag1) { this.markDirty(); } } } -
[1.7.10] When i spawn my Mob Minecraft is Crazy
TheTroop replied to TheTroop's topic in Modder Support
maybe it is texture i change it's size in techne it is't 64X32 anymore now it is 124X64 -
[1.7.10] My custom furnace doesn't save item when i restar minecraft
TheTroop replied to TheTroop's topic in Modder Support
no-one can help? -
[1.7.10] When i spawn my Mob Minecraft is Crazy
TheTroop replied to TheTroop's topic in Modder Support
https://gist.github.com/TheTroop/f3eb593cfcc266d09256 -
[1.7.10] My custom furnace doesn't save item when i restar minecraft
TheTroop replied to TheTroop's topic in Modder Support
where it is't complit ?