Everything posted by jewell012
-
Mob Max Health
There's no need to use a DataWatcher, applyEntityAttributes() is called on both sides. @OP: Add @Override to all of your methods you intend to override, it will tell you something is wrong. You missed the s at the end of your applyEntityAttributes() method. Alright so for the Health, adding the s at the end of applyEntityAttributes actually worked, however, Now the mob is like OP strong, no matter what I set the damage value to it is like a 2 hit kill and the lower I set it ex 9.0D the strong it gets. while even when I set it to 90.0D it does half damage but then anything higher it does higher damage
-
Mob Max Health
Alright, so the mob is killed with a normal sword after three hits when it is suppose to have 300 health. I copied the health from the wither, either way though 300.0d and 300.0D do nothing to improve its health. protected void applyEntityAttribute(){ super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(300.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.45D); this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(25.0D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(50.0D); } Heres the entire classfile if you need it package com.phantasyrealms.entity; import com.phantasyrealms.item.PhantasyRealmsItems; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMoveThroughVillage; import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class EntityHildeBearMob extends EntityMob implements IBossDisplayData{ public EntityHildeBearMob(World par1World) { super(par1World); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 0.3D, false)); this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.45D)); this.tasks.addTask(7, new EntityAIWander(this, 0.4D)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true)); this.setSize(1.9F, 2.5F); } public boolean isAIEnabled(){ return true; } protected boolean canDespawn() { return false; } protected void applyEntityAttribute(){ super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(300.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.45D); this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(25.0D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(50.0D); } protected void entityInit() { super.entityInit(); } protected Item getDropItem() { return PhantasyRealmsItems.saber; } /** * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param * par2 - Level of Looting used to kill this mob. */ protected void dropFewItems(boolean par1, int par2) { int dropType = rand.nextInt(40); if(dropType == 1){ this.dropItem(PhantasyRealmsItems.rsaber, 1); } if(dropType == 3){ this.dropItem(PhantasyRealmsItems.scimitar, 1); } if(dropType == 5){ this.dropItem(PhantasyRealmsItems.rsword3, 1); } if(dropType == 7){ this.dropItem(PhantasyRealmsItems.brand2, 1); } if(dropType == 9){ this.dropItem(PhantasyRealmsItems.reHelmet, 1); } if(dropType == 11){ this.dropItem(PhantasyRealmsItems.rePlate, 1); } if(dropType == 13){ this.dropItem(PhantasyRealmsItems.rePants, 1); } if(dropType == 15){ this.dropItem(PhantasyRealmsItems.reBoots, 1); } if(dropType == 17){ this.dropItem(PhantasyRealmsItems.teHelmet, 1); } if(dropType == 19){ this.dropItem(PhantasyRealmsItems.tePlate, 1); } if(dropType == 21){ this.dropItem(PhantasyRealmsItems.tePants, 1); } if(dropType == 23){ this.dropItem(PhantasyRealmsItems.teBoots, 1); } if(dropType == 31){ this.dropItem(PhantasyRealmsItems.rsaber1, 1); } if(dropType == 37){ this.dropItem(PhantasyRealmsItems.baxe1, 1); } if(dropType == 25){ this.dropItem(PhantasyRealmsItems.meseta, 30); } if(dropType == 27){ this.dropItem(PhantasyRealmsItems.meseta, 35); } if(dropType == 29){ this.dropItem(PhantasyRealmsItems.meseta, 40); } } protected void dropRareDrop(int p_70600_1_) { this.entityDropItem(new ItemStack(PhantasyRealmsItems.digrinder, 1, 1), 0.0F); } }
-
Mob Animations Help
Yeah the addChild did it, but I decided not to use the mob anyway thanks for your help though.
-
Mob Animations Help
Alright so I get that, now I dont know what to do about it, In the Techne I positioned the rotation point in the same spot, when I did that with the nose and then set it to the head it worked just fine. and then before I set the rotation point to the same as the head it was the same problem. So should I again adjust the model of it?
-
Mob Animations Help
What do you mean? the setRotation? or the setRotationPoint?
-
1.7 Item Particles, Specifing location
Alright, so I have been tinkering with particle effects when a player holds an Item and I have gotten It down, the only part I cant really figure out now is adjusting it to where its on the sword or Item rather than the player. The issue I have had with trying to set it on the Item specifically is when adjusting it gets stuck in a fixed position always either south or east of the player. This is the normal code, It spawns particles around player. Sorry for the format, the code insert isn't working for me @SideOnly(Side.CLIENT) public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { EntityPlayer player = (EntityPlayer) par3Entity; Random rand = new Random(); if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().getItem() == PhantasyRealmsItems.drsabre) { for(int countparticles = 0; countparticles <= 2; ++countparticles) { par2World.spawnParticle("portal", player.posX + (rand.nextDouble() - 0.5D) * (double)player.width, player.posY + rand.nextDouble() * (double)player.height - (double)player.yOffset, player.posZ + (rand.nextDouble() - 0.5D) * (double)player.width, 0.0D, 0.0D, 0.0D); } } }
-
Mob Animations Help
I have been working with custom models for a while now, and Its only until now I have been stumped, I did a lot of Trial and error and worked out part of the issue but some still remain. Anyways, the problem is making the leaves move with the head as a whole, I have got the nose to do it but I just cant get the leaves to do it. package com.phantasyrealms.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelPoisonLilyMob extends ModelBase { //fields ModelRenderer head; ModelRenderer body; ModelRenderer nose; ModelRenderer Leaf1; ModelRenderer Base; ModelRenderer Leaf2; ModelRenderer Leaf3; public ModelPoisonLilyMob() { textureWidth = 64; textureHeight = 32; head = new ModelRenderer(this, 0, 0); head.addBox(-4F, -8F, -7F, 8, 8, ; head.setRotationPoint(0F, -7F, -1F); head.setTextureSize(64, 32); head.mirror = true; setRotation(head, 0F, 0F, 0F); body = new ModelRenderer(this, 56, -1); body.addBox(-1F, 0F, -1F, 2, 30, 2); body.setRotationPoint(0F, -7F, 0F); body.setTextureSize(64, 32); body.mirror = true; setRotation(body, 0F, 0F, 0F); nose = new ModelRenderer(this, 32, 6); nose.addBox(-2F, -6F, -15F, 4, 4, ; nose.setRotationPoint(0F, -7F, -1F); nose.setTextureSize(64, 32); nose.mirror = true; setRotation(nose, 0F, 0F, 0F); Leaf1 = new ModelRenderer(this, 37, 19); Leaf1.addBox(-6F, 6F, -3F, 6, 10, 1); Leaf1.setRotationPoint(0F, -7F, -1F); Leaf1.setTextureSize(64, 32); Leaf1.mirror = true; setRotation(Leaf1, -2.792527F, 0F, 0.9250245F); Base = new ModelRenderer(this, 0, 18); Base.addBox(-6F, -1F, -6F, 12, 2, 12); Base.setRotationPoint(0F, 23F, 0F); Base.setTextureSize(64, 32); Base.mirror = true; setRotation(Base, 0F, 0F, 0F); Leaf2 = new ModelRenderer(this, 37, 19); Leaf2.addBox(0F, 6F, -3F, 6, 10, 1); Leaf2.setRotationPoint(0F, -7F, -1F); Leaf2.setTextureSize(64, 32); Leaf2.mirror = true; setRotation(Leaf2, -2.792527F, 0F, -0.9250245F); Leaf3 = new ModelRenderer(this, 37, 19); Leaf3.addBox(-3F, 0F, -1F, 6, 10, 1); Leaf3.setRotationPoint(0F, -7F, -1F); Leaf3.setTextureSize(64, 32); Leaf3.mirror = true; setRotation(Leaf3, -0.418879F, 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); nose.render(f5); Leaf1.render(f5); Base.render(f5); Leaf2.render(f5); Leaf3.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 p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity p_78087_7_) { float f6 = (180F / (float)Math.PI); this.head.rotateAngleX = p_78087_5_ / (180F / (float)Math.PI); this.head.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI); this.nose.rotateAngleX = this.head.rotateAngleX; this.nose.rotateAngleY = this.head.rotateAngleY; this.Leaf1.rotateAngleX = this.head.rotateAngleX; this.Leaf1.rotateAngleY = this.head.rotateAngleY; this.Leaf2.rotateAngleX = this.head.rotateAngleX; this.Leaf2.rotateAngleY = this.head.rotateAngleY; this.Leaf3.rotateAngleX = this.head.rotateAngleX; this.Leaf3.rotateAngleY = this.head.rotateAngleY; } } It is suppose to look like this https://docs.google.com/document/d/1Wo2BtzfXjKHsbRPiAQ39DxPQb8CrX1B2ZLE-ux9HbaU/edit Instead it looks like this https://docs.google.com/document/d/19T9rCgbAHni5z14ugwJIGupIXKxa5ojlTmVfhvs1ymQ/edit
-
Custom Mob Follow Player/Despawn.
How would I do this, I have never touched NBT methods and usage before.
-
Custom Mob Follow Player/Despawn.
So basically, the mob is spawned in by onRightClick in the ItemMag.class, it is suppose to follow the player and be like directly behind the player and by its shoulder at all times but problem 1. Dont know how to set position for it, it usually stays up high, because I modeled it in the Ideal location so really its just a matter of keeping close behind the player. problem 2. the Mob wont follow the player at all, I think its the ItemMag.class error. problem 3. is onLeftClick doesnt despawn the mob, when it should. I want a player to only be able to spawn 1 of the entity. Here are my classes. ItemMag.class package com.phantasyrealms.item; import com.phantasyrealms.entity.EntityMag; import com.phantasyrealms.lib.Strings; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.world.World; public class ItemMag extends Item{ EntityMag par1; public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player){ if(par1 == null){ par1 = new EntityMag(world); par1.setPosition(player.posX, player.posY+1,player.posZ-2); par1.func_152115_b(player.getUniqueID().toString()); world.spawnEntityInWorld(par1); player.inventory.addItemStackToInventory(new ItemStack(PhantasyRealmsItems.mag)); --itemstack.stackSize; } else{ player.addChatComponentMessage(new ChatComponentTranslation ("Already Have one!")); } return null; } public ItemStack onItemLeftClick(ItemStack itemstack, World world, EntityPlayer player){ par1.func_152115_b(player.getUniqueID().toString()); world.removeEntity(par1); player.addChatComponentMessage(new ChatComponentTranslation ("RETURN!")); player.inventory.addItemStackToInventory(new ItemStack(PhantasyRealmsItems.mag)); return null; } } EntityMag.class package com.phantasyrealms.entity; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EnumCreatureAttribute; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIBeg; import net.minecraft.entity.ai.EntityAIFollowOwner; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILeapAtTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMate; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtTarget; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAITargetNonTamed; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.DamageSource; import net.minecraft.world.World; public class EntityMag extends EntityTameable { public EntityMag(World world) { super(world); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true)); this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(9, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, false)); this.setSize(0.9F, 0.9F); } protected void applyEntityAttributes(){ super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.2); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); } public boolean attackEntityAsMob(Entity par1Entity) { int i = 5; return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), 5.0F); } protected boolean isAIEnabled() { return true; } public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); } public EnumCreatureAttribute getCreatureAttribute() { return EnumCreatureAttribute.UNDEFINED; } public boolean interact(EntityPlayer par1EntityPlayer){ this.func_152115_b(par1EntityPlayer.getUniqueID().toString()); return true; } protected boolean canDespawn() { return false; } protected void dropFewItems(boolean par1, int par2) { } public EntityAgeable createChild(EntityAgeable entityageable) { return null; } }
-
Designating HotBar slot as CustomArmor slot
Perfect Thank you
-
Designating HotBar slot as CustomArmor slot
Hmm alright, I thought it wouldve just been easier to use an existing one. Thanks for the help though!
-
Designating HotBar slot as CustomArmor slot
No I mean like designate the hot bar slot to the far right, number 9, as a armor slot, except you can only put a Item or Armor of a specific type in that slot. An example would be a type being a Ring, so only a Ring Typed Item would be able to be in Hotbar slot 9.
-
Designating HotBar slot as CustomArmor slot
I am just curious as to how one would go about doing this. Would it be as simple as just creating a method that sets a slot number as the Armor slot?
-
Error AL lib: (EE) alc_cleanup: 1 device not closed
Will you take a look at my KeyHandler code, and MainRegistry, the game runs fine now after initializing however the GUI doesn't pop up on button press, the button doesnt even show on the controls menu
-
Error AL lib: (EE) alc_cleanup: 1 device not closed
I changed it but still a crash, am I not initializing it right? MainRegistry package com.phantasyrealms.main; import java.io.File; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import sun.net.NetworkServer; import sun.security.krb5.Config; import net.minecraftforge.common.MinecraftForge; import com.phantasyrealms.entity.EntityBoomaMob; import com.phantasyrealms.entity.PhantasyRealmsEntity; import com.phantasyrealms.eventhandler.EventHandlerEntity; import com.phantasyrealms.eventhandler.EventHandlerNetwork; import com.phantasyrealms.item.PhantasyRealmsItems; import com.phantasyrealms.lib.Strings; import com.phantasyrealms.packethandling.PacketHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; @Mod(modid = Strings.MODID, name = Strings.name, version = Strings.version) public class MainRegistry { public static final int GUI = 0; @SidedProxy(clientSide = "com.phantasyrealms.main.ClientProxy", serverSide = "com.phantasyrealms.main.ServerProxy") public static ServerProxy proxy; @Instance(Strings.MODID) public static MainRegistry modInstance; public static Object instance; public static File modDir; public static EventHandlerEntity entityEventHandler; public static EventHandlerNetwork entityEventNetwork; public static ServerProxy GuiHandler; public class RegisterKeyBindings { } /** * Loads before * @param PostEvent */ @EventHandler public static void PreLoad(FMLPreInitializationEvent PreEvent){ PhantasyRealmsEntity.mainRegistry(); proxy.registerRenderThings(); PhantasyRealmsItems.mainRegistry(); CraftingManager.mainRegistry(); modDir = PreEvent.getModConfigurationDirectory(); entityEventHandler = new EventHandlerEntity(); entityEventNetwork = new EventHandlerNetwork(); MinecraftForge.EVENT_BUS.register(entityEventHandler); FMLCommonHandler.instance().bus().register(entityEventNetwork); NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy); GuiHandler.init(); PacketHandler.init(); } /** * Loads during * @param event */ @EventHandler public static void load(FMLInitializationEvent event){ } /** * Loads after * @param PostEvent */ @EventHandler public static void PostLoad(FMLPostInitializationEvent PostEvent){ } } ServerProxy package com.phantasyrealms.main; import com.phantasyrealms.eventhandler.KeyHandler; import com.phantasyrealms.inventory.InventoryPR; import com.phantasyrealms.packethandling.PacketOpenNormalInventory; import com.phantasyrealms.packethandling.PacketOpenPRInventory; import com.phantasyrealms.packethandling.PacketSyncPR; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import cpw.mods.fml.relauncher.Side; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.storage.WorldInfo; public class ServerProxy implements IGuiHandler { public KeyHandler keyHandler; public void registerHandlers() {} public void registerRenderThings(){ } // In your server proxy (mine is named CommonProxy): /** * Returns a side-appropriate EntityPlayer for use during message handling */ public EntityPlayer getPlayerEntity(MessageContext ctx) { return ctx.getServerHandler().playerEntity; } public int addArmor(String armor){ return 0; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case MainRegistry.GUI: return new InventoryPR(player); } return null; } public Object getClientWorld() { // TODO Auto-generated method stub return null; } public static void init() { } }
-
Error AL lib: (EE) alc_cleanup: 1 device not closed
ah thanks
-
Error AL lib: (EE) alc_cleanup: 1 device not closed
I dont know which class you specifically need to see... But here is everything Main Registry package com.phantasyrealms.main; import java.io.File; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import sun.net.NetworkServer; import sun.security.krb5.Config; import net.minecraftforge.common.MinecraftForge; import com.phantasyrealms.entity.EntityBoomaMob; import com.phantasyrealms.entity.PhantasyRealmsEntity; import com.phantasyrealms.eventhandler.EventHandlerEntity; import com.phantasyrealms.eventhandler.EventHandlerNetwork; import com.phantasyrealms.item.PhantasyRealmsItems; import com.phantasyrealms.lib.Strings; import com.phantasyrealms.packethandling.PacketHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; @Mod(modid = Strings.MODID, name = Strings.name, version = Strings.version) public class MainRegistry { public static final int GUI = 0; @SidedProxy(clientSide = "com.phantasyrealms.main.ClientProxy", serverSide = "com.phantasyrealms.main.ServerProxy") public static ServerProxy proxy; @Instance(Strings.MODID) public static MainRegistry modInstance; public static Object instance; public static File modDir; public static EventHandlerEntity entityEventHandler; public static EventHandlerNetwork entityEventNetwork; public class RegisterKeyBindings { } /** * Loads before * @param PostEvent */ @EventHandler public static void PreLoad(FMLPreInitializationEvent PreEvent){ PhantasyRealmsEntity.mainRegistry(); proxy.registerRenderThings(); PhantasyRealmsItems.mainRegistry(); CraftingManager.mainRegistry(); modDir = PreEvent.getModConfigurationDirectory(); entityEventHandler = new EventHandlerEntity(); entityEventNetwork = new EventHandlerNetwork(); MinecraftForge.EVENT_BUS.register(entityEventHandler); FMLCommonHandler.instance().bus().register(entityEventNetwork); PacketHandler.init(); } /** * Loads during * @param event */ @EventHandler public static void load(FMLInitializationEvent event){ NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy); } /** * Loads after * @param PostEvent */ @EventHandler public static void PostLoad(FMLPostInitializationEvent PostEvent){ } } ClientProxy package com.phantasyrealms.main; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelCreeper; import net.minecraft.client.renderer.entity.RenderBiped; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.storage.WorldInfo; import com.phantasyrealms.entity.EntityBoomaMob; import com.phantasyrealms.entity.EntityEvilSharkMob; import com.phantasyrealms.entity.EntityGoBoomaMob; import com.phantasyrealms.entity.EntityRagRappyMob; import com.phantasyrealms.entity.EntityRappyMob; import com.phantasyrealms.model.ModelBoomaMob; import com.phantasyrealms.model.ModelEvilSharkMob; import com.phantasyrealms.model.ModelGoBoomaMob; import com.phantasyrealms.model.ModelRagRappyMob; import com.phantasyrealms.model.ModelRappyMob; import com.phantasyrealms.render.RenderBoomaMob; import com.phantasyrealms.render.RenderEvilSharkMob; import com.phantasyrealms.render.RenderGoBoomaMob; import com.phantasyrealms.render.RenderRagRappyMob; import com.phantasyrealms.render.RenderRappyMob; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; public class ClientProxy extends ServerProxy{ public void registerRenderThings(){ RenderingRegistry.registerEntityRenderingHandler(EntityGoBoomaMob.class, new RenderGoBoomaMob(new ModelGoBoomaMob(), 0)); RenderingRegistry.registerEntityRenderingHandler(EntityBoomaMob.class, new RenderBoomaMob(new ModelBoomaMob(), 0)); RenderingRegistry.registerEntityRenderingHandler(EntityRappyMob.class, new RenderRappyMob(new ModelRappyMob(), 0)); RenderingRegistry.registerEntityRenderingHandler(EntityRagRappyMob.class, new RenderRagRappyMob(new ModelRagRappyMob(), 0)); RenderingRegistry.registerEntityRenderingHandler(EntityEvilSharkMob.class, new RenderEvilSharkMob(new ModelEvilSharkMob(), 0)); } // In your client proxy: @Override public EntityPlayer getPlayerEntity(MessageContext ctx) { // Note that if you simply return 'Minecraft.getMinecraft().thePlayer', // your packets will not work because you will be getting a client // player even when you are on the server! Sounds absurd, but it's true. // Solution is to double-check side before returning the player: return (ctx.side.isClient() ? Minecraft.getMinecraft().thePlayer : super.getPlayerEntity(ctx)); } public int addArmor(String armor){ return RenderingRegistry.addNewArmourRendererPrefix(armor); } } ServerProxy package com.phantasyrealms.main; import com.phantasyrealms.eventhandler.KeyHandler; import com.phantasyrealms.inventory.InventoryPR; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraft.world.storage.WorldInfo; public class ServerProxy implements IGuiHandler { public KeyHandler keyHandler; public void registerHandlers() {} public void registerRenderThings(){ } // In your server proxy (mine is named CommonProxy): /** * Returns a side-appropriate EntityPlayer for use during message handling */ public EntityPlayer getPlayerEntity(MessageContext ctx) { return ctx.getServerHandler().playerEntity; } public int addArmor(String armor){ return 0; } public static NBTTagCompound getEntityData(String saveKey) { // TODO Auto-generated method stub return null; } public void registerRenderers() { // TODO Auto-generated method stub } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { switch (ID) { case MainRegistry.GUI: return new InventoryPR(player); } return null; } public Object getClientWorld() { // TODO Auto-generated method stub return null; } } PlayerHandler package com.phantasyrealms.lib; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.HashMap; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import com.google.common.io.Files; import com.phantasyrealms.inventory.InventoryPR; public class PlayerHandler { private static HashMap<String, InventoryPR> playerPR = new HashMap<String, InventoryPR>(); public static void clearPlayerPR(EntityPlayer player) { playerPR.remove(player.getDisplayName()); } public static InventoryPR getPlayerPR(EntityPlayer player) { if (!playerPR.containsKey(player.getDisplayName())) { InventoryPR inventory = new InventoryPR(player); playerPR.put(player.getDisplayName(), inventory); } return playerPR.get(player.getDisplayName()); } public static void setPlayerPR(EntityPlayer player, InventoryPR inventory) { playerPR.put(player.getDisplayName(), inventory); } public static void loadPlayerPR(EntityPlayer player, File file1, File file2) { if (player != null && !player.worldObj.isRemote) { try { NBTTagCompound data = null; boolean save = false; if (file1 != null && file1.exists()) { try { FileInputStream fileinputstream = new FileInputStream( file1); data = CompressedStreamTools .readCompressed(fileinputstream); fileinputstream.close(); } catch (Exception e) { e.printStackTrace(); } } if (file1 == null || !file1.exists() || data == null || data.hasNoTags()) { if (file2 != null && file2.exists()) { try { FileInputStream fileinputstream = new FileInputStream( file2); data = CompressedStreamTools .readCompressed(fileinputstream); fileinputstream.close(); save = true; } catch (Exception e) { e.printStackTrace(); } } } if (data != null) { InventoryPR inventory = new InventoryPR(player); inventory.readNBT(data); playerPR.put(player.getDisplayName(), inventory); if (save) savePlayerPR(player, file1, file2); } } catch (Exception exception1) { exception1.printStackTrace(); } } } public static void savePlayerPR(EntityPlayer player, File file1, File file2) { if (player != null && !player.worldObj.isRemote) { try { if (file1 != null && file1.exists()) { try { Files.copy(file1, file2); } catch (Exception e) { } } try { if (file1 != null) { InventoryPR inventory = getPlayerPR(player); NBTTagCompound data = new NBTTagCompound(); inventory.saveNBT(data); FileOutputStream fileoutputstream = new FileOutputStream( file1); CompressedStreamTools.writeCompressed(data, fileoutputstream); fileoutputstream.close(); } } catch (Exception e) { e.printStackTrace(); if (file1.exists()) { try { file1.delete(); } catch (Exception e2) { } } } } catch (Exception exception1) {; exception1.printStackTrace(); } } } } PacketHandler package com.phantasyrealms.packethandling; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableBiMap; import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; import com.jcraft.jogg.Packet; import com.phantasyrealms.lib.Strings; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; public class PacketHandler { public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(Strings.MODID.toLowerCase()); public static void init() { INSTANCE.registerMessage(PacketOpenPRInventory.class, PacketOpenPRInventory.class, 0, Side.SERVER); INSTANCE.registerMessage(PacketOpenNormalInventory.class, PacketOpenNormalInventory.class, 1, Side.SERVER); INSTANCE.registerMessage(PacketSyncPR.class, PacketSyncPR.class, 2, Side.CLIENT); } } PacketOpenNormalInventory package com.phantasyrealms.packethandling; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; public class PacketOpenNormalInventory implements IMessage, IMessageHandler<PacketOpenNormalInventory, IMessage> { public PacketOpenNormalInventory() {} public PacketOpenNormalInventory(EntityPlayer player) {} @Override public void toBytes(ByteBuf buffer) {} @Override public void fromBytes(ByteBuf buffer) {} @Override public IMessage onMessage(PacketOpenNormalInventory message, MessageContext ctx) { ctx.getServerHandler().playerEntity.openContainer.onContainerClosed(ctx.getServerHandler().playerEntity); ctx.getServerHandler().playerEntity.openContainer = ctx.getServerHandler().playerEntity.inventoryContainer; return null; } } PacketOpenPRInventory package com.phantasyrealms.packethandling; import com.phantasyrealms.main.MainRegistry; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; public class PacketOpenPRInventory implements IMessage, IMessageHandler<PacketOpenPRInventory, IMessage> { public PacketOpenPRInventory() {} public PacketOpenPRInventory(EntityPlayer player) {} @Override public void toBytes(ByteBuf buffer) {} @Override public void fromBytes(ByteBuf buffer) {} @Override public IMessage onMessage(PacketOpenPRInventory message, MessageContext ctx) { ctx.getServerHandler().playerEntity.openGui(MainRegistry.instance, MainRegistry.GUI, ctx.getServerHandler().playerEntity.worldObj, (int)ctx.getServerHandler().playerEntity.posX, (int)ctx.getServerHandler().playerEntity.posY, (int)ctx.getServerHandler().playerEntity.posZ); return null; } } PacketSyncPR package com.phantasyrealms.packethandling; import io.netty.buffer.ByteBuf; import java.io.IOException; import com.phantasyrealms.lib.PlayerHandler; import com.phantasyrealms.main.MainRegistry; import cpw.mods.fml.common.network.ByteBufUtils; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.common.network.simpleimpl.MessageContext; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraft.world.World; public class PacketSyncPR implements IMessage, IMessageHandler<PacketSyncPR, IMessage> { int slot; int playerId; ItemStack pr=null; public PacketSyncPR() {} public PacketSyncPR(EntityPlayer player, int slot) { this.slot = slot; this.pr = PlayerHandler.getPlayerPR(player).getStackInSlot(slot); this.playerId = player.getEntityId(); } @Override public void toBytes(ByteBuf buffer) { buffer.writeByte(slot); buffer.writeInt(playerId); ByteBufUtils.writeItemStack(buffer, pr); } @Override public void fromBytes(ByteBuf buffer) { slot = buffer.readByte(); playerId = buffer.readInt(); pr = ByteBufUtils.readItemStack(buffer); } @Override public IMessage onMessage(PacketSyncPR message, MessageContext ctx) { World world = (World) MainRegistry.proxy.getClientWorld(); if (world==null) return null; Entity p = world.getEntityByID(message.playerId); if (p !=null && p instanceof EntityPlayer) { PlayerHandler.getPlayerPR((EntityPlayer) p).stackList[message.slot]=message.pr; } return null; } } ContainerPlayerExpanded package com.phantasyrealms.inventory; import com.phantasyrealms.lib.PlayerHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryCraftResult; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.Slot; import net.minecraft.inventory.SlotCrafting; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; public class ContainerPlayerExpanded extends Container { /** * The crafting matrix inventory. */ public InventoryCrafting craftMatrix = new InventoryCrafting(this, 2, 2); public IInventory craftResult = new InventoryCraftResult(); public InventoryPR pr; /** * Determines if inventory manipulation should be handled. */ public boolean isLocalWorld; private final EntityPlayer thePlayer; public ContainerPlayerExpanded(InventoryPlayer playerInv, boolean par2, EntityPlayer player) { this.isLocalWorld = par2; this.thePlayer = player; pr = new InventoryPR(player); pr.setEventHandler(this); if (!player.worldObj.isRemote) { pr.stackList = PlayerHandler.getPlayerPR(player).stackList; } this.addSlotToContainer(new SlotCrafting(playerInv.player, this.craftMatrix, this.craftResult, 0, 144, 36)); int i; int j; for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 2, 106 + j * 18, 26 + i * 18)); } } for (i = 0; i < 4; ++i) { final int k = i; this.addSlotToContainer(new Slot(playerInv, playerInv.getSizeInventory() - 1 - i, 8, 8 + i * 18) { @Override public int getSlotStackLimit() { return 1; } @Override public boolean isItemValid(ItemStack par1ItemStack) { if (par1ItemStack == null) return false; return par1ItemStack.getItem().isValidArmor(par1ItemStack, k, thePlayer); } }); } this.addSlotToContainer(new SlotMag(pr,PRType.MAG,0,80,8 + 0 * 18)); for (i = 0; i < 3; ++i) { for (j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(playerInv, j + (i + 1) * 9, 8 + j * 18, 84 + i * 18)); } } for (i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142)); } this.onCraftMatrixChanged(this.craftMatrix); } /** * Callback for when the crafting matrix is changed. */ @Override public void onCraftMatrixChanged(IInventory par1IInventory) { this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.thePlayer.worldObj)); } /** * Called when the container is closed. */ @Override public void onContainerClosed(EntityPlayer player) { super.onContainerClosed(player); for (int i = 0; i < 4; ++i) { ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); if (itemstack != null) { player.dropPlayerItemWithRandomChoice(itemstack, false); } } this.craftResult.setInventorySlotContents(0, (ItemStack)null); if (!player.worldObj.isRemote) { PlayerHandler.setPlayerPR(player, pr); } } @Override public boolean canInteractWith(EntityPlayer par1EntityPlayer) { return true; } /** * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. */ @Override 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 == 0) { if (!this.mergeItemStack(itemstack1, 9+4, 45+4, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); } else if (par2 >= 1 && par2 < 5) { if (!this.mergeItemStack(itemstack1, 9+4, 45+4, false)) { return null; } } else if (par2 >= 5 && par2 < 9) { if (!this.mergeItemStack(itemstack1, 9+4, 45+4, false)) { return null; } } else if (itemstack.getItem() instanceof ItemArmor && !((Slot)this.inventorySlots.get(5 + ((ItemArmor)itemstack.getItem()).armorType)).getHasStack()) { int j = 5 + ((ItemArmor)itemstack.getItem()).armorType; if (!this.mergeItemStack(itemstack1, j, j + 1, false)) { return null; } } else if (itemstack.getItem() instanceof IPR && ((IPR)itemstack.getItem()).getPRType(itemstack)==PRType.MAG && ((IPR)itemstack.getItem()).canEquip(itemstack, thePlayer) && !((Slot)this.inventorySlots.get(9)).getHasStack()) { int j = 9; if (!this.mergeItemStack(itemstack1, j, j + 1, false)) { return null; } } else if (par2 >= 9+4 && par2 < 36+4) { if (!this.mergeItemStack(itemstack1, 36+4, 45+4, false)) { return null; } } else if (par2 >= 36+4 && par2 < 45+4) { if (!this.mergeItemStack(itemstack1, 9+4, 36+4, false)) { return null; } } else if (!this.mergeItemStack(itemstack1, 9+4, 45+4, false, slot)) { 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; } private void unequippr(ItemStack stack) { // if (stack.getItem() instanceof IBauble) { // ((IBauble)stack.getItem()).onUnequipped(stack, thePlayer); // } } @Override public void putStacksInSlots(ItemStack[] p_75131_1_) { pr.blockEvents=true; super.putStacksInSlots(p_75131_1_); } protected boolean mergeItemStack(ItemStack par1ItemStack, int par2, int par3, boolean par4, Slot ss) { boolean flag1 = false; int k = par2; if (par4) { k = par3 - 1; } Slot slot; ItemStack itemstack1; if (par1ItemStack.isStackable()) { while (par1ItemStack.stackSize > 0 && (!par4 && k < par3 || par4 && k >= par2)) { slot = (Slot)this.inventorySlots.get(k); itemstack1 = slot.getStack(); if (itemstack1 != null && itemstack1.getItem() == par1ItemStack.getItem() && (!par1ItemStack.getHasSubtypes() || par1ItemStack.getItemDamage() == itemstack1.getItemDamage()) && ItemStack.areItemStackTagsEqual(par1ItemStack, itemstack1)) { int l = itemstack1.stackSize + par1ItemStack.stackSize; if (l <= par1ItemStack.getMaxStackSize()) { if (ss instanceof SlotMag) unequippr(par1ItemStack); par1ItemStack.stackSize = 0; itemstack1.stackSize = l; slot.onSlotChanged(); flag1 = true; } else if (itemstack1.stackSize < par1ItemStack.getMaxStackSize()) { if (ss instanceof SlotMag) unequippr(par1ItemStack); par1ItemStack.stackSize -= par1ItemStack.getMaxStackSize() - itemstack1.stackSize; itemstack1.stackSize = par1ItemStack.getMaxStackSize(); slot.onSlotChanged(); flag1 = true; } } if (par4) { --k; } else { ++k; } } } if (par1ItemStack.stackSize > 0) { if (par4) { k = par3 - 1; } else { k = par2; } while (!par4 && k < par3 || par4 && k >= par2) { slot = (Slot)this.inventorySlots.get(k); itemstack1 = slot.getStack(); if (itemstack1 == null) { if (ss instanceof SlotMag) unequippr(par1ItemStack); slot.putStack(par1ItemStack.copy()); slot.onSlotChanged(); par1ItemStack.stackSize = 0; flag1 = true; break; } if (par4) { --k; } else { ++k; } } } return flag1; } public boolean canMergeSlot(ItemStack par1ItemStack, Slot par2Slot) { return par2Slot.inventory != this.craftResult && super.canDragIntoSlot(par2Slot); } } InventoryPR package com.phantasyrealms.inventory; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; import com.phantasyrealms.main.MainRegistry; import com.phantasyrealms.packethandling.PacketSyncPR; import net.minecraft.entity.Entity; 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.nbt.NBTTagList; import net.minecraft.util.IChatComponent; import net.minecraft.util.MathHelper; public class InventoryPR implements IInventory { public ItemStack[] stackList; private Container eventHandler; public WeakReference<EntityPlayer> player; public boolean blockEvents=false; public InventoryPR(EntityPlayer player) { this.stackList = new ItemStack[4]; this.player = new WeakReference<EntityPlayer>(player); } public Container getEventHandler() { return eventHandler; } public void setEventHandler(Container eventHandler) { this.eventHandler = eventHandler; } /** * Returns the number of slots in the inventory. */ @Override public int getSizeInventory() { return this.stackList.length; } /** * Returns the stack in slot i */ @Override public ItemStack getStackInSlot(int par1) { return par1 >= this.getSizeInventory() ? null : this.stackList[par1]; } /** * Returns the name of the inventory */ @Override public String getInventoryName() { return null; } /** * Returns if the inventory is named */ @Override public boolean hasCustomInventoryName() { return false; } public IChatComponent getDisplayName() { 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. */ @Override public ItemStack getStackInSlotOnClosing(int par1) { if (this.stackList[par1] != null) { ItemStack itemstack = this.stackList[par1]; this.stackList[par1] = null; return itemstack; } else { return null; } } /** * Removes from an inventory slot (first arg) up to a specified number * (second arg) of items and returns them in a new stack. */ @Override public ItemStack decrStackSize(int par1, int par2) { if (this.stackList[par1] != null) { ItemStack itemstack; if (this.stackList[par1].stackSize <= par2) { itemstack = this.stackList[par1]; if (itemstack != null && itemstack.getItem() instanceof IPR) { ((IPR) itemstack.getItem()).onUnequipped(itemstack, player.get()); } this.stackList[par1] = null; if (eventHandler != null) this.eventHandler.onCraftMatrixChanged(this); syncSlotToClients(par1); return itemstack; } else { itemstack = this.stackList[par1].splitStack(par2); if (itemstack != null && itemstack.getItem() instanceof IPR) { ((IPR) itemstack.getItem()).onUnequipped(itemstack, player.get()); } if (this.stackList[par1].stackSize == 0) { this.stackList[par1] = null; } if (eventHandler != null) this.eventHandler.onCraftMatrixChanged(this); syncSlotToClients(par1); return itemstack; } } else { return null; } } /** * Sets the given item stack to the specified slot in the inventory (can be * crafting or armor sections). */ @Override public void setInventorySlotContents(int par1, ItemStack stack) { if(!blockEvents && this.stackList[par1] != null) { ((IPR)stackList[par1].getItem()).onUnequipped(stackList[par1], player.get()); } this.stackList[par1] = stack; if (!blockEvents && stack != null && stack.getItem() instanceof IPR) { ((IPR) stack.getItem()).onEquipped(stack, player.get()); } if (eventHandler != null) this.eventHandler.onCraftMatrixChanged(this); syncSlotToClients(par1); } /** * Returns the maximum stack size for a inventory slot. */ @Override public int getInventoryStackLimit() { return 1; } /** * For tile entities, ensures the chunk containing the tile entity is saved * to disk later - the game won't think it hasn't changed and skip it. */ @Override public void markDirty() { try { player.get().inventory.markDirty(); } catch (Exception e) { } } /** * Do not make give this method the name canInteractWith because it clashes * with Container */ @Override public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) { return true; } @Override public void openInventory() { } @Override public void closeInventory() { } /** * Returns true if automation is allowed to insert the given stack (ignoring * stack size) into the given slot. */ @Override public boolean isItemValidForSlot(int i, ItemStack stack) { if (stack == null || !(stack.getItem() instanceof IPR) || !((IPR) stack.getItem()).canEquip(stack, player.get())) return false; if (i == 0 && ((IPR) stack.getItem()).getPRType(stack) == PRType.MAG) return true; return false; } public int getField(int id) { return 0; } public void setField(int id, int value) { } public int getFieldCount() { return 0; } public void clear() { for(int i = 0; i < stackList.length; i++) { stackList[i] = null; } } public void saveNBT(EntityPlayer player) { NBTTagCompound tags = player.getEntityData(); saveNBT(tags); } public void saveNBT(NBTTagCompound tags) { NBTTagList tagList = new NBTTagList(); NBTTagCompound invSlot; for (int i = 0; i < this.stackList.length; ++i) { if (this.stackList[i] != null) { invSlot = new NBTTagCompound(); invSlot.setByte("Slot", (byte) i); this.stackList[i].writeToNBT(invSlot); tagList.appendTag(invSlot); } } tags.setTag("PR.Inventory", tagList); } public void readNBT(EntityPlayer player) { NBTTagCompound tags = player.getEntityData(); readNBT(tags); } public void readNBT(NBTTagCompound tags) { NBTTagList tagList = tags.getTagList("PR.Inventory", 10); for (int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound nbttagcompound = (NBTTagCompound) tagList .getCompoundTagAt(i); int j = nbttagcompound.getByte("Slot") & 255; ItemStack itemstack = ItemStack .loadItemStackFromNBT(nbttagcompound); if (itemstack != null) { this.stackList[j] = itemstack; } } } public void dropItems(ArrayList<EntityItem> drops) { for (int i = 0; i < 4; ++i) { if (this.stackList[i] != null) { EntityItem ei = new EntityItem(player.get().worldObj, player.get().posX, player.get().posY + player.get().getEyeHeight(), player.get().posZ, this.stackList[i].copy()); float f1 = player.get().worldObj.rand.nextFloat() * 0.5F; float f2 = player.get().worldObj.rand.nextFloat() * (float) Math.PI * 2.0F; ei.motionX = (double) (-MathHelper.sin(f2) * f1); ei.motionZ = (double) (MathHelper.cos(f2) * f1); ei.motionY = 0.20000000298023224D; drops.add(ei); this.stackList[i] = null; syncSlotToClients(i); } } } public void dropItemsAt(List<EntityItem> drops, Entity e) { for (int i = 0; i < 4; ++i) { if (this.stackList[i] != null) { EntityItem ei = new EntityItem(e.worldObj, e.posX, e.posY + e.getEyeHeight(), e.posZ, this.stackList[i].copy()); float f1 = e.worldObj.rand.nextFloat() * 0.5F; float f2 = e.worldObj.rand.nextFloat() * (float) Math.PI * 2.0F; ei.motionX = (double) (-MathHelper.sin(f2) * f1); ei.motionZ = (double) (MathHelper.cos(f2) * f1); ei.motionY = 0.20000000298023224D; drops.add(ei); this.stackList[i] = null; syncSlotToClients(i); } } } public void syncSlotToClients(int slot) { try { if (MainRegistry.proxy.getClientWorld() == null) { com.phantasyrealms.packethandling.PacketHandler.INSTANCE.sendToAll(new PacketSyncPR(player.get(), slot)); } } catch (Exception e) { e.printStackTrace(); } } } IPR package com.phantasyrealms.inventory; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; /** * * This interface should be extended by items that can be worn in bauble slots * * @author Azanor */ public interface IPR { /** * This method return the type of bauble this is. * Type is used to determine the slots it can go into. */ public PRType getPRType(ItemStack itemstack); /** * This method is called once per tick if the bauble is being worn by a player */ public void onWornTick(ItemStack itemstack, EntityLivingBase player); /** * This method is called when the bauble is equipped by a player */ public void onEquipped(ItemStack itemstack, EntityLivingBase player); /** * This method is called when the bauble is unequipped by a player */ public void onUnequipped(ItemStack itemstack, EntityLivingBase player); /** * can this bauble be placed in a bauble slot */ public boolean canEquip(ItemStack itemstack, EntityLivingBase player); /** * Can this bauble be removed from a bauble slot */ public boolean canUnequip(ItemStack itemstack, EntityLivingBase player); } PRAPI package com.phantasyrealms.inventory; import java.lang.reflect.Method; import cpw.mods.fml.common.FMLLog; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; /** * @author Azanor */ public class PRAPI { static Method getPR; /** * Retrieves the baubles inventory for the supplied player */ public static IInventory getMainRegistry(EntityPlayer player) { IInventory ot = null; try { if(getPR == null) { Class<?> fake = Class.forName("phantasyrealms.common.lib.PlayerHandler"); getPR = fake.getMethod("getPlayerPR", EntityPlayer.class); } ot = (IInventory) getPR.invoke(null, player); } catch(Exception ex) { FMLLog.warning("[PR API] Could not invoke com.phantasyrealms.lib.PlayerHandler method getPlayerPR"); } return ot; } } PRType package com.phantasyrealms.inventory; public enum PRType { MAG } SlotMag package com.phantasyrealms.inventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class SlotMag extends Slot { PRType type; public SlotMag(IInventory par2IInventory, PRType type, int par3, int par4, int par5) { super(par2IInventory, par3, par4, par5); this.type = type; } /** * Check if the stack is a valid item for this slot. Always true beside for the armor slots. */ @Override public boolean isItemValid(ItemStack stack) { return stack!=null && stack.getItem() !=null && stack.getItem() instanceof IPR && ((IPR)stack.getItem()).getPRType(stack)==this.type && ((IPR)stack.getItem()).canEquip(stack, ((InventoryPR)this.inventory).player.get()); } @Override public boolean canTakeStack(EntityPlayer player) { return this.getStack()!=null && ((IPR)this.getStack().getItem()).canUnequip(this.getStack(), player); } @Override public int getSlotStackLimit() { return 1; } } EventHandlerEntity package com.phantasyrealms.eventhandler; import java.io.File; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.event.entity.player.PlayerDropsEvent; import net.minecraftforge.event.entity.player.PlayerEvent; import com.google.common.io.Files; import com.phantasyrealms.inventory.IPR; import com.phantasyrealms.inventory.InventoryPR; import com.phantasyrealms.lib.PlayerHandler; import com.sun.swing.internal.plaf.basic.resources.basic_es; import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class EventHandlerEntity { @SubscribeEvent public void playerTick(PlayerEvent.LivingUpdateEvent event) { // player events if (event.entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entity; InventoryPR PR = PlayerHandler.getPlayerPR(player); for (int a = 0; a < PR.getSizeInventory(); a++) { if (PR.getStackInSlot(a) != null && PR.getStackInSlot(a).getItem() instanceof IPR) { ((IPR) PR.getStackInSlot(a).getItem()).onWornTick( PR.getStackInSlot(a), player); } } } } @SubscribeEvent public void playerDeath(PlayerDropsEvent event) { if (event.entity instanceof EntityPlayer && !event.entity.worldObj.isRemote && !event.entity.worldObj.getGameRules() .getGameRuleBooleanValue("keepInventory")) { PlayerHandler.getPlayerPR(event.entityPlayer).dropItemsAt( event.drops,event.entityPlayer); } } @SubscribeEvent public void playerLoad(PlayerEvent.LoadFromFile event) { PlayerHandler.clearPlayerPR(event.entityPlayer); File file1 = getPlayerFile("baub", event.playerDirectory, event.entityPlayer.getDisplayName()); if (!file1.exists()) { File filep = event.getPlayerFile("baub"); if (filep.exists()) { try { Files.copy(filep, file1); filep.delete(); File fb = event.getPlayerFile("baubback"); if (fb.exists()) fb.delete(); } catch (IOException e) {} } else { File filet = getLegacyFileFromPlayer(event.entityPlayer); if (filet.exists()) { try { Files.copy(filet, file1); } catch (IOException e) {} } } } PlayerHandler.loadPlayerPR(event.entityPlayer, file1, getPlayerFile("baubback", event.playerDirectory, event.entityPlayer.getDisplayName())); EventHandlerNetwork.syncPR(event.entityPlayer); } public File getPlayerFile(String suffix, File playerDirectory, String playername) { if ("dat".equals(suffix)) throw new IllegalArgumentException("The suffix 'dat' is reserved"); return new File(playerDirectory, playername+"."+suffix); } public static File getLegacyFileFromPlayer(EntityPlayer player) { try { File playersDirectory = new File(player.worldObj.getSaveHandler().getWorldDirectory(), "players"); return new File(playersDirectory, player.getDisplayName() + ".baub"); } catch (Exception e) { e.printStackTrace(); } return null; } @SubscribeEvent public void playerSave(PlayerEvent.SaveToFile event) { PlayerHandler.savePlayerPR(event.entityPlayer, getPlayerFile("baub", event.playerDirectory, event.entityPlayer.getDisplayName()), getPlayerFile("baubback", event.playerDirectory, event.entityPlayer.getDisplayName())); } } EventHandlerNetwork package com.phantasyrealms.eventhandler; import com.phantasyrealms.lib.PlayerHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; import cpw.mods.fml.relauncher.Side; import net.minecraft.entity.player.EntityPlayer; public class EventHandlerNetwork { @SubscribeEvent public void playerLoggedInEvent (PlayerEvent.PlayerLoggedInEvent event) { Side side = FMLCommonHandler.instance().getEffectiveSide(); if (side == Side.SERVER) { syncPR(event.player); } } public static void syncPR(EntityPlayer player) { for (int a = 0; a < 4; a++) { PlayerHandler.getPlayerPR(player).syncSlotToClients(a); } } } GuiEvent package com.phantasyrealms.eventhandler; import java.lang.reflect.Method; import com.phantasyrealms.packethandling.PacketHandler; import com.phantasyrealms.packethandling.PacketOpenNormalInventory; import com.phantasyrealms.packethandling.PacketOpenPRInventory; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.resources.I18n; import net.minecraftforge.client.event.GuiScreenEvent; public class GuiEvents { @SideOnly(value = Side.CLIENT) @SubscribeEvent public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) { if (event.gui instanceof GuiInventory || event.gui instanceof GuiPlayerExpanded) { int xSize = 176; int ySize = 166; int guiLeft = (event.gui.width - xSize) / 2; int guiTop = (event.gui.height - ySize) / 2; if (!event.gui.mc.thePlayer.getActivePotionEffects().isEmpty() && isNeiHidden()) { guiLeft = 160 + (event.gui.width - xSize - 200) / 2; } event.buttonList.add(new GuiPRButton(55, guiLeft + 66, guiTop + 9, 10, 10, I18n.format((event.gui instanceof GuiInventory)?"button.pr":"button.normal", new Object[0]))); } } @SideOnly(value = Side.CLIENT) @SubscribeEvent public void guiPostAction(GuiScreenEvent.ActionPerformedEvent.Post event) { if (event.gui instanceof GuiInventory) { if (event.button.id == 55) { PacketHandler.INSTANCE.sendToServer(new PacketOpenPRInventory(event.gui.mc.thePlayer)); } } if (event.gui instanceof GuiPlayerExpanded) { if (event.button.id == 55) { event.gui.mc.displayGuiScreen(new GuiInventory(event.gui.mc.thePlayer)); PacketHandler.INSTANCE.sendToServer(new PacketOpenNormalInventory(event.gui.mc.thePlayer)); } } } static Method isNEIHidden; boolean isNeiHidden() { boolean hidden=true; try { if (isNEIHidden==null) { Class fake = Class.forName("codechicken.nei.NEIClientConfig"); isNEIHidden = fake.getMethod("isHidden"); } hidden = (Boolean) isNEIHidden.invoke(null); } catch(Exception ex) { } return hidden; } } GuiPlayerExpanded package com.phantasyrealms.eventhandler; import java.io.IOException; import org.lwjgl.opengl.GL11; import com.phantasyrealms.inventory.ContainerPlayerExpanded; import com.phantasyrealms.inventory.InventoryPR; import com.phantasyrealms.lib.Strings; import com.phantasyrealms.main.MainRegistry; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.achievement.GuiAchievements; import net.minecraft.client.gui.achievement.GuiStats; import net.minecraft.client.renderer.InventoryEffectRenderer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.resources.I18n; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Slot; import net.minecraft.util.ResourceLocation; public class GuiPlayerExpanded extends InventoryEffectRenderer { public static final ResourceLocation background = new ResourceLocation(Strings.MODID + ":Gui.png"); /** x size of the inventory window in pixels. Defined as float, passed as int */ private float xSize_lo; /** y size of the inventory window in pixels. Defined as float, passed as int. */ private float ySize_lo; public GuiPlayerExpanded(EntityPlayer player) { super(new ContainerPlayerExpanded(player.inventory, !player.worldObj.isRemote, player)); this.allowUserInput = true; } /** * Called from the main game loop to update the screen. */ @Override public void updateScreen() { try { ((ContainerPlayerExpanded)inventorySlots).pr.blockEvents=false; } catch (Exception e) { } this.updateActivePotionEffects(); } private void updateActivePotionEffects() { // TODO Auto-generated method stub } /** * Adds the buttons (and other controls) to the screen in question. */ @Override public void initGui() { this.buttonList.clear(); super.initGui(); } /** * Draw the foreground layer for the GuiContainer (everything in front of the items) */ @Override protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { this.fontRendererObj.drawString(I18n.format("container.crafting", new Object[0]), 106, 16, 4210752); } /** * Draws the screen and all the components in it. */ @Override public void drawScreen(int par1, int par2, float par3) { super.drawScreen(par1, par2, par3); this.xSize_lo = (float)par1; this.ySize_lo = (float)par2; } @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(background); 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; drawPlayerModel(k + 51, l + 75, 30, (float)(k + 51) - this.xSize_lo, (float)(l + 75 - 50) - this.ySize_lo, this.mc.thePlayer); } public static void drawPlayerModel(int x, int y, int scale, float yaw, float pitch, EntityLivingBase entity) { GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glPushMatrix(); GL11.glTranslatef(x, y, 50.0F); GL11.glScalef(-scale, scale, scale); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); float f2 = entity.renderYawOffset; float f3 = entity.rotationYaw; float f4 = entity.rotationPitch; float f5 = entity.prevRotationYawHead; float f6 = entity.rotationYawHead; GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-((float) Math.atan(pitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F); entity.renderYawOffset = (float) Math.atan(yaw / 40.0F) * 20.0F; entity.rotationYaw = (float) Math.atan(yaw / 40.0F) * 40.0F; entity.rotationPitch = -((float) Math.atan(pitch / 40.0F)) * 20.0F; entity.rotationYawHead = entity.rotationYaw; entity.prevRotationYawHead = entity.rotationYaw; GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); RenderManager.instance.playerViewY = 180.0F; RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); entity.renderYawOffset = f2; entity.rotationYaw = f3; entity.rotationPitch = f4; entity.prevRotationYawHead = f5; entity.rotationYawHead = f6; GL11.glPopMatrix(); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL11.GL_ALPHA_SCALE); OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glDisable(GL11.GL_TEXTURE_2D); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); } @Override protected void actionPerformed(GuiButton button) { if (button.id == 0) { this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.getStatFileWriter())); } if (button.id == 1) { this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.getStatFileWriter())); } } @Override protected void keyTyped(char par1, int par2) { if (par2 == MainRegistry.proxy.keyHandler.key.getKeyCode()) { this.mc.thePlayer.closeScreen(); } else super.keyTyped(par1, par2); } } GuiPRButton package com.phantasyrealms.eventhandler; import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.renderer.OpenGlHelper; public class GuiPRButton extends GuiButton { public GuiPRButton(int buttonId, int x, int y, int width, int height, String buttonText) { super(buttonId, x, y, width, height, buttonText); } public void drawButton(Minecraft mc, int xx, int yy) { if (this.visible) { FontRenderer fontrenderer = mc.fontRenderer; mc.getTextureManager().bindTexture(GuiPlayerExpanded.background); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.enabled = xx >= this.xPosition && yy >= this.yPosition && xx < this.xPosition + this.width && yy < this.yPosition + this.height; int k = this.getHoverState(this.enabled); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (k==1) { this.drawTexturedModalRect(this.xPosition, this.yPosition, 200, 48, 10, 10); } else { this.drawTexturedModalRect(this.xPosition, this.yPosition, 210, 48, 10, 10); this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + 5, this.yPosition + this.height, 0xffffff); } this.mouseDragged(mc, xx, yy); } } } KeyHandler package com.phantasyrealms.eventhandler; import net.minecraft.client.settings.KeyBinding; import org.lwjgl.input.Keyboard; import com.phantasyrealms.packethandling.PacketHandler; import com.phantasyrealms.packethandling.PacketOpenPRInventory; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class KeyHandler { public KeyBinding key = new KeyBinding("Mag Inventory", Keyboard.KEY_B, "key.categories.inventory"); public KeyHandler() { ClientRegistry.registerKeyBinding(key); } @SideOnly(Side.CLIENT) @SubscribeEvent public void playerTick(PlayerTickEvent event) { if (event.side == Side.SERVER) return; if (event.phase == Phase.START ) { if (key.isPressed() && FMLClientHandler.instance().getClient().inGameHasFocus) { PacketHandler.INSTANCE.sendToServer(new PacketOpenPRInventory(event.player)); } } } }
-
Error AL lib: (EE) alc_cleanup: 1 device not closed
[15:21:32] [main/INFO] [GradleStart]: Extra: [] [15:21:32] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --accessToken, {REDACTED}, --assetIndex, 1.7.10, --assetsDir, C:/Users/Chris/.gradle/caches/minecraft/assets, --version, 1.7.10, --tweakClass, cpw.mods.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.GradleStartCommon$GradleStartTweaker] [15:21:32] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLTweaker [15:21:32] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLTweaker [15:21:32] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.GradleStartCommon$GradleStartTweaker [15:21:32] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLTweaker [15:21:32] [main/INFO] [FML]: Forge Mod Loader version 7.10.85.1277 for Minecraft 1.7.10 loading [15:21:32] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_71, running on Windows 7:amd64:6.1, installed at C:\Program Files\Java\jre7 [15:21:32] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation [15:21:32] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.GradleStartCommon$GradleStartTweaker [15:21:32] [main/INFO] [GradleStart]: Injecting location in coremod cpw.mods.fml.relauncher.FMLCorePlugin [15:21:32] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin [15:21:32] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [15:21:32] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker [15:21:32] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [15:21:32] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [15:21:32] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [15:21:33] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work! [15:21:36] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing [15:21:36] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [15:21:36] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker [15:21:38] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.TerminalTweaker [15:21:38] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.TerminalTweaker [15:21:38] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main} [15:21:43] [main/INFO]: Setting user: Player168 [15:21:46] [Client thread/INFO]: LWJGL Version: 2.9.1 [15:21:51] [Client thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization [15:21:51] [Client thread/INFO] [FML]: MinecraftForge v10.13.2.1277 Initialized [15:21:51] [Client thread/INFO] [FML]: Replaced 183 ore recipies [15:21:51] [Client thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization [15:21:51] [Client thread/INFO] [FML]: Config directory created successfully [15:21:52] [Client thread/INFO] [FML]: Searching C:\Users\Chris\Desktop\MTD\eclipse\mods for mods [15:22:02] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load [15:22:03] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, pr] at CLIENT [15:22:03] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, pr] at SERVER [15:22:04] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Phantasy realms [15:22:04] [Client thread/INFO] [FML]: Processing ObjectHolder annotations [15:22:04] [Client thread/INFO] [FML]: Found 341 ObjectHolder annotations [15:22:04] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0 [15:22:05] [Client thread/INFO] [FML]: Applying holder lookups [15:22:05] [Client thread/INFO] [FML]: Holder lookups applied [15:22:06] [sound Library Loader/INFO] [sTDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [15:22:06] [sound Library Loader/INFO] [sTDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: Starting up SoundSystem... [15:22:06] [Thread-5/INFO] [sTDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: Initializing LWJGL OpenAL [15:22:06] [Thread-5/INFO] [sTDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) [15:22:08] [Thread-5/INFO] [sTDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: OpenAL initialized. [15:22:08] [sound Library Loader/INFO] [sTDOUT]: [paulscode.sound.SoundSystemLogger:message:69]: [15:22:08] [sound Library Loader/INFO]: Sound engine started [15:22:13] [Client thread/INFO]: Created: 512x256 textures/blocks-atlas [15:22:14] [Client thread/INFO]: Created: 512x512 textures/items-atlas [15:22:14] [Client thread/ERROR] [FML]: Fatal errors were detected during the transition from INITIALIZATION to POSTINITIALIZATION. Loading cannot continue [15:22:14] [Client thread/ERROR] [FML]: mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized FML{7.10.85.1277} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.2.1277.jar) Unloaded->Constructed->Pre-initialized->Initialized Forge{10.13.2.1277} [Minecraft Forge] (forgeSrc-1.7.10-10.13.2.1277.jar) Unloaded->Constructed->Pre-initialized->Initialized pr{0.01 ALPHA} [Phantasy realms] (bin) Unloaded->Constructed->Pre-initialized->Errored [15:22:14] [Client thread/ERROR] [FML]: The following problems were captured during this phase [15:22:14] [Client thread/ERROR] [FML]: Caught exception from pr java.lang.NullPointerException at cpw.mods.fml.common.network.NetworkRegistry.registerGuiHandler(NetworkRegistry.java:217) ~[forgeSrc-1.7.10-10.13.2.1277.jar:?] at com.phantasyrealms.main.MainRegistry.load(MainRegistry.java:100) ~[bin/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_71] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_71] at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513) ~[forgeSrc-1.7.10-10.13.2.1277.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_71] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_71] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[forgeSrc-1.7.10-10.13.2.1277.jar:?] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[forgeSrc-1.7.10-10.13.2.1277.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_71] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_71] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118) [LoadController.class:?] at cpw.mods.fml.common.Loader.initializeMods(Loader.java:691) [Loader.class:?] at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:288) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:586) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:931) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_71] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_71] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?] at GradleStart.main(GradleStart.java:45) [start/:?] [15:22:14] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ---- // My bad. Time: 1/8/15 3:22 PM Description: Initializing game java.lang.NullPointerException: Initializing game at cpw.mods.fml.common.network.NetworkRegistry.registerGuiHandler(NetworkRegistry.java:217) at com.phantasyrealms.main.MainRegistry.load(MainRegistry.java:100) 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:513) 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:208) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187) 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:118) at cpw.mods.fml.common.Loader.initializeMods(Loader.java:691) at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:288) at net.minecraft.client.Minecraft.startGame(Minecraft.java:586) at net.minecraft.client.Minecraft.run(Minecraft.java:931) 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(GradleStartCommon.java:78) at GradleStart.main(GradleStart.java:45) 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:217) at com.phantasyrealms.main.MainRegistry.load(MainRegistry.java:100) 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:513) 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:208) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187) 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:118) at cpw.mods.fml.common.Loader.initializeMods(Loader.java:691) at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:288) at net.minecraft.client.Minecraft.startGame(Minecraft.java:586) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:931) 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(GradleStartCommon.java:78) at GradleStart.main(GradleStart.java:45) -- System Details -- Details: Minecraft Version: 1.7.10 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_71, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 908883072 bytes (866 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 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.85.1277 Minecraft Forge 10.13.2.1277 4 mods loaded, 4 mods active mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized FML{7.10.85.1277} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.2.1277.jar) Unloaded->Constructed->Pre-initialized->Initialized Forge{10.13.2.1277} [Minecraft Forge] (forgeSrc-1.7.10-10.13.2.1277.jar) Unloaded->Constructed->Pre-initialized->Initialized pr{0.01 ALPHA} [Phantasy realms] (bin) Unloaded->Constructed->Pre-initialized->Errored Launched Version: 1.7.10 LWJGL: 2.9.1 OpenGL: GeForce 9800 GTX+/PCIe/SSE2 GL version 3.3.0, NVIDIA Corporation 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: English (US) Profiler Position: N/A (disabled) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Anisotropic Filtering: Off (1) [15:22:14] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:398]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Chris\Desktop\MTD\eclipse\.\crash-reports\crash-2015-01-08_15.22.14-client.txt AL lib: (EE) alc_cleanup: 1 device not closed I updated and does the error log say anything?
-
Error AL lib: (EE) alc_cleanup: 1 device not closed
I don't know whats wrong, no error shown in eclipse, I have looked up this problem and it seems to be between duplicates or something wrong with constructed but I cant find anything. [14:31:27] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLTweaker [14:31:27] [main/INFO] [LaunchWrapper]: Using primary tweak class name cpw.mods.fml.common.launcher.FMLTweaker [14:31:27] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLTweaker [14:31:28] [main/INFO] [FML]: Forge Mod Loader version 7.2.217.1147 for Minecraft 1.7.2 loading [14:31:28] [main/INFO] [FML]: Java is Java HotSpot 64-Bit Server VM, version 1.7.0_71, running on Windows 7:amd64:6.1, installed at C:\Program Files\Java\jre7 [14:31:28] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation [14:31:28] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [14:31:28] [main/INFO] [LaunchWrapper]: Loading tweak class name cpw.mods.fml.common.launcher.FMLDeobfTweaker [14:31:28] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [14:31:28] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLInjectionAndSortingTweaker [14:31:28] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [14:31:28] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work! [14:31:31] [main/ERROR] [FML]: The minecraft jar file:/C:/Users/Chris/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.2-10.12.2.1147/forgeSrc-1.7.2-10.12.2.1147.jar!/net/minecraft/client/ClientBrandRetriever.class appears to be corrupt! There has been CRITICAL TAMPERING WITH MINECRAFT, it is highly unlikely minecraft will work! STOP NOW, get a clean copy and try again! [14:31:31] [main/ERROR] [FML]: FML has been ordered to ignore the invalid or missing minecraft certificate. This is very likely to cause a problem! [14:31:31] [main/ERROR] [FML]: Technical information: ClientBrandRetriever was at jar:file:/C:/Users/Chris/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.2-10.12.2.1147/forgeSrc-1.7.2-10.12.2.1147.jar!/net/minecraft/client/ClientBrandRetriever.class, there were 0 certificates for it [14:31:31] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing [14:31:31] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.relauncher.CoreModManager$FMLPluginWrapper [14:31:31] [main/INFO] [LaunchWrapper]: Calling tweak class cpw.mods.fml.common.launcher.FMLDeobfTweaker [14:31:33] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main} [14:31:35] [main/INFO]: Setting user: Player365 [14:31:39] [Client thread/INFO]: LWJGL Version: 2.9.0 [14:31:39] [Client thread/ERROR]: Couldn't set icon javax.imageio.IIOException: Can't read input file! at javax.imageio.ImageIO.read(Unknown Source) ~[?:1.7.0_71] at net.minecraft.client.Minecraft.readImage(Minecraft.java:629) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:458) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:880) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:112) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_71] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_71] at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?] [14:31:43] [Client thread/INFO] [MinecraftForge]: Attempting early MinecraftForge initialization [14:31:43] [Client thread/INFO] [FML]: MinecraftForge v10.12.2.1147 Initialized [14:31:43] [Client thread/INFO] [FML]: Replaced 182 ore recipies [14:31:43] [Client thread/INFO] [MinecraftForge]: Completed early MinecraftForge initialization [14:31:44] [Client thread/INFO] [FML]: Searching C:\Users\Chris\Desktop\MTD\eclipse\mods for mods [14:31:48] [Client thread/ERROR] [FML]: FML has detected a mod that is using a package name based on 'net.minecraft.src' : net.minecraft.src.FMLRenderAccessLibrary. This is generally a severe programming error. There should be no mod code in the minecraft namespace. MOVE YOUR MOD! If you're in eclipse, select your source code and 'refactor' it into a new package. Go on. DO IT NOW! [14:31:54] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load [14:31:55] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Phantasy realms [14:31:55] [Client thread/INFO] [FML]: Processing ObjectHolder annotations [14:31:55] [Client thread/INFO] [FML]: Found 341 ObjectHolder annotations [14:31:55] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0 [14:31:56] [Client thread/INFO] [FML]: Applying holder lookups [14:31:56] [Client thread/INFO] [FML]: Holder lookups applied Starting up SoundSystem... Initializing LWJGL OpenAL (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) OpenAL initialized. [14:31:58] [sound Library Loader/INFO]: Sound engine started [14:31:59] [Client thread/INFO]: Created: 512x256 textures/blocks-atlas [14:31:59] [Client thread/INFO]: Created: 512x512 textures/items-atlas [14:31:59] [Client thread/ERROR] [FML]: Fatal errors were detected during the transition from INITIALIZATION to POSTINITIALIZATION. Loading cannot continue [14:31:59] [Client thread/ERROR] [FML]: mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized FML{7.2.217.1147} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.2.1147.jar) Unloaded->Constructed->Pre-initialized->Initialized Forge{10.12.2.1147} [Minecraft Forge] (forgeSrc-1.7.2-10.12.2.1147.jar) Unloaded->Constructed->Pre-initialized->Initialized pr{0.01 ALPHA} [Phantasy realms] (bin) Unloaded->Constructed->Pre-initialized->Errored [14:31:59] [Client thread/ERROR] [FML]: The following problems were captured during this phase [14:31:59] [Client thread/ERROR] [FML]: Caught exception from pr java.lang.NullPointerException at cpw.mods.fml.common.network.NetworkRegistry.registerGuiHandler(NetworkRegistry.java:217) ~[NetworkRegistry.class:?] at com.phantasyrealms.main.MainRegistry.load(MainRegistry.java:100) ~[MainRegistry.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_71] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_71] at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513) ~[FMLModContainer.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_71] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_71] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) ~[guava-15.0.jar:?] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47) ~[guava-15.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) ~[guava-15.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) ~[guava-15.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:267) ~[guava-15.0.jar:?] at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[LoadController.class:?] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[LoadController.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_71] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_71] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) ~[guava-15.0.jar:?] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47) ~[guava-15.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) ~[guava-15.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) ~[guava-15.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:267) ~[guava-15.0.jar:?] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118) [LoadController.class:?] at cpw.mods.fml.common.Loader.initializeMods(Loader.java:690) [Loader.class:?] at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:288) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:573) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:880) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:112) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_71] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_71] at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?] ---- Minecraft Crash Report ---- // I'm sorry, Dave. Time: 1/8/15 2:31 PM Description: Initializing game java.lang.NullPointerException: Initializing game at cpw.mods.fml.common.network.NetworkRegistry.registerGuiHandler(NetworkRegistry.java:217) at com.phantasyrealms.main.MainRegistry.load(MainRegistry.java:100) 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:513) 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:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) 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:208) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187) 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:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) 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:118) at cpw.mods.fml.common.Loader.initializeMods(Loader.java:690) at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:288) at net.minecraft.client.Minecraft.startGame(Minecraft.java:573) at net.minecraft.client.Minecraft.run(Minecraft.java:880) at net.minecraft.client.main.Main.main(Main.java:112) 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:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) 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:217) at com.phantasyrealms.main.MainRegistry.load(MainRegistry.java:100) 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:513) 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:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) 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:208) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187) 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:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) 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:118) at cpw.mods.fml.common.Loader.initializeMods(Loader.java:690) at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:288) at net.minecraft.client.Minecraft.startGame(Minecraft.java:573) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:880) at net.minecraft.client.main.Main.main(Main.java:112) 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:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_71, Oracle Corporation Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 975985056 bytes (930 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 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.03 FML v7.2.217.1147 Minecraft Forge 10.12.2.1147 4 mods loaded, 4 mods active mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized FML{7.2.217.1147} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.2.1147.jar) Unloaded->Constructed->Pre-initialized->Initialized Forge{10.12.2.1147} [Minecraft Forge] (forgeSrc-1.7.2-10.12.2.1147.jar) Unloaded->Constructed->Pre-initialized->Initialized pr{0.01 ALPHA} [Phantasy realms] (bin) Unloaded->Constructed->Pre-initialized->Errored Launched Version: 1.6 LWJGL: 2.9.0 OpenGL: GeForce 9800 GTX+/PCIe/SSE2 GL version 3.3.0, NVIDIA Corporation Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: [] Current Language: ~~ERROR~~ NullPointerException: null Profiler Position: N/A (disabled) Vec3 Pool Size: ~~ERROR~~ NullPointerException: null Anisotropic Filtering: Off (1) #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Chris\Desktop\MTD\eclipse\.\crash-reports\crash-2015-01-08_14.31.59-client.txt AL lib: (EE) alc_cleanup: 1 device not closed
-
InventorySlot/PacketHandler
Yes everything else as shown in my examples work fine when I just run minecraft except for that they arent setup right actually work. Anyways I added the Synchronizing event handler, so how exactly do I call these setInventorySlotContents decrStackSize dropItems to sync? In a format such as this? public class SynchronizedCounter { private int c = 0; public synchronized void increment() { c++; } public synchronized void decrement() { c--; } public synchronized int value() { return c; } } and where should I place the PacketDispatcher.sendToAll(new PacketSynchronizeInventory(player.get(), slot)); because anywhere I try placing in my PacketDispatcher errors just appear.
-
InventorySlot/PacketHandler
Here is everything I have pertaining to custom inventory slot. I am not asking you to write a whole mod, this is just a small part of my mod, though one that makes that much more interesting. Here is my MainRegistry package com.phantasyrealms.main; import sun.net.NetworkServer; import net.minecraftforge.common.MinecraftForge; import com.phantasyrealms.entity.EntityBoomaMob; import com.phantasyrealms.entity.PhantasyRealmsEntity; import com.phantasyrealms.eventhandler.PhantasyEventHandler; import com.phantasyrealms.item.PhantasyRealmsItems; import com.phantasyrealms.lib.Strings; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; @Mod(modid = Strings.MODID, name = Strings.name, version = Strings.version) public class MainRegistry { @SidedProxy(clientSide = "com.phantasyrealms.main.ClientProxy", serverSide = "com.phantasyrealms.main.ServerProxy") public static ServerProxy proxy; @Instance(Strings.MODID) public static MainRegistry modInstance; public static Object instance; public class RegisterKeyBindings { } /** * Loads before * @param PostEvent */ @EventHandler public static void PreLoad(FMLPreInitializationEvent PreEvent){ PhantasyRealmsEntity.mainRegistry(); proxy.registerRenderThings(); PhantasyRealmsItems.mainRegistry(); CraftingManager.mainRegistry(); } /** * Loads during * @param event */ @EventHandler public static void load(FMLInitializationEvent event){ } /** * Loads after * @param PostEvent */ @EventHandler public static void PostLoad(FMLPostInitializationEvent PostEvent){ } } Here is my PacketHandler package com.phantasyrealms.packethandling; import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import com.google.common.collect.BiMap; import com.google.common.collect.ImmutableBiMap; import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; import com.jcraft.jogg.Packet; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; import cpw.mods.fml.relauncher.Side; public abstract class PacketHandler<T extends IMessage> implements IMessageHandler <T, IMessage> { public static final String CHANNEL = "myChannel"; private static final BiMap<Integer, Class<? extends PacketHandler>> idMap; static { ImmutableBiMap.Builder<Integer, Class<? extends PacketHandler>> builder = ImmutableBiMap.builder(); // we add all our packets here later idMap = builder.build(); } public static PacketHandler constructPacket(int packetId) throws ProtocolException, ReflectiveOperationException { Class<? extends PacketHandler> clazz = idMap.get(Integer.valueOf(packetId)); if (clazz == null) { throw new ProtocolException("Unknown Packet Id!"); } else { return clazz.newInstance(); } } public static class ProtocolException extends Exception { public ProtocolException() { } public ProtocolException(String message, Throwable cause) { super(message, cause); } public ProtocolException(String message) { super(message); } public ProtocolException(Throwable cause) { super(cause); } } public final int getPacketId() { if (idMap.inverse().containsKey(getClass())) { return idMap.inverse().get(getClass()).intValue(); } else { throw new RuntimeException("Packet " + getClass().getSimpleName() + " is missing a mapping!"); } } public final Packet makePacket() { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeByte(getPacketId()); write(out); return PacketDispatcher.getPacket(CHANNEL, out.toByteArray()); } public abstract void write(ByteArrayDataOutput out); public abstract void read(ByteArrayDataInput in); public abstract void execute(EntityPlayer player, Side side); } Here is my PacketDispatcher package com.phantasyrealms.packethandling; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import com.jcraft.jogg.Packet; import com.phantasyrealms.lib.Strings; import com.phantasyrealms.main.MainRegistry; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; /** * * This class will house the SimpleNetworkWrapper instance, which I will name 'dispatcher', * as well as give us a logical place from which to register our packets. These two things * could be done anywhere, however, even in your Main class, but I will be adding other * functionality (see below) that gives this class a bit more utility. * * While unnecessary, I'm going to turn this class into a 'wrapper' for SimpleNetworkWrapper * so that instead of writing "PacketDispatcher.dispatcher.{method}" I can simply write * "PacketDispatcher.{method}" All this does is make it quicker to type and slightly shorter; * if you do not care about that, then make the 'dispatcher' field public instead of private, * or, if you do not want to add a new class just for one field and one static method that * you could put anywhere, feel free to put them wherever. * * For further convenience, I have also added two extra sendToAllAround methods: one which * takes an EntityPlayer and one which takes coordinates. * */ public class PacketDispatcher { // a simple counter will allow us to get rid of 'magic' numbers used during packet registration private static byte packetId = 0; public static final SimpleNetworkWrapper dispatcher = NetworkRegistry.INSTANCE.newSimpleChannel(Strings.MODID); /** * Call this during pre-init or loading and register all of your packets (messages) here */ public static final void registerPackets() { // Using an incrementing field instead of hard-coded numerals, I don't need to think // about what number comes next or if I missed on should I ever rearrange the order // of registration (for instance, if you wanted to alphabetize them... yeah...) // It's even easier if you create a convenient 'registerMessage' method // If you don't want to make a 'registerMessage' method, you can do it directly: //PacketDispatcher.dispatcher.registerMessage(OpenGuiMessage.OpenGuiMessageHandler.class, OpenGuiMessage.class, packetId++, Side.SERVER); //PacketDispatcher.dispatcher.registerMessage(SyncPlayerPropsMessage.SyncPlayerPropsMessageHandler.class, SyncPlayerPropsMessage.class, packetId++, Side.CLIENT); } /** * Registers a message and message handler */ private static final void registerMessage(Class handlerClass, Class messageClass, Side side) { PacketDispatcher.dispatcher.registerMessage(handlerClass, messageClass, packetId++, side); } //========================================================// // The following methods are the 'wrapper' methods; again, // this just makes sending a message slightly more compact // and is purely a matter of stylistic preference //========================================================// /** * Send this message to the specified player. * See {@link SimpleNetworkWrapper#sendTo(IMessage, EntityPlayerMP)} */ public static final void sendTo(IMessage message, EntityPlayerMP player) { PacketDispatcher.dispatcher.sendTo(message, player); } /** * Send this message to everyone within a certain range of a point. * See {@link SimpleNetworkWrapper#sendToDimension(IMessage, NetworkRegistry.TargetPoint)} */ public static final void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) { PacketDispatcher.dispatcher.sendToAllAround(message, point); } /** * Sends a message to everyone within a certain range of the coordinates in the same dimension. */ public static final void sendToAllAround(IMessage message, int dimension, double x, double y, double z, double range) { PacketDispatcher.sendToAllAround(message, new NetworkRegistry.TargetPoint(dimension, x, y, z, range)); } /** * Sends a message to everyone within a certain range of the player provided. */ public static final void sendToAllAround(IMessage message, EntityPlayer player, double range) { PacketDispatcher.sendToAllAround(message, player.worldObj.provider.dimensionId, player.posX, player.posY, player.posZ, range); } /** * Send this message to everyone within the supplied dimension. * See {@link SimpleNetworkWrapper#sendToDimension(IMessage, int)} */ public static final void sendToDimension(IMessage message, int dimensionId) { PacketDispatcher.dispatcher.sendToDimension(message, dimensionId); } /** * Send this message to the server. * See {@link SimpleNetworkWrapper#sendToServer(IMessage)} */ public static final void sendToServer(IMessage message) { PacketDispatcher.dispatcher.sendToServer(message); } public static Packet getPacket(String channel, byte[] byteArray) { // TODO Auto-generated method stub return null; } } Here is my ContainerCustomPlayer package com.phantasyrealms.inventory; import com.phantasyrealms.item.ItemMag; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; public class ContainerCustomPlayer extends Container { /** Avoid magic numbers! This will greatly reduce the chance of you making errors in 'transferStackInSlot' method */ private static final int ARMOR_START = InventoryCustomPlayer.INV_SIZE, ARMOR_END = ARMOR_START+3, INV_START = ARMOR_END+1, INV_END = INV_START+26, HOTBAR_START = INV_END+1, HOTBAR_END = HOTBAR_START+8; public ContainerCustomPlayer(EntityPlayer player, InventoryPlayer inventoryPlayer, InventoryCustomPlayer inventoryCustom) { int i; //Add CUSTOM slots - we'll just add two for now, both of the same type. //Make a new Slot class for each different item type you want to add this.addSlotToContainer(new Slot(inventoryCustom, 0, 80, ); this.addSlotToContainer(new Slot(inventoryCustom, 1, 80, 26)); //Add ARMOR slots; note you need to make a public version of SlotArmor //just copy and paste the vanilla code into a new class and change what you need for (i = 0; i < 4; ++i) { this.addSlotToContainer(new SlotMag(player, inventoryPlayer, inventoryPlayer.getSizeInventory() - 1 - i, 8, 8 + i * 18, i)); } //Add vanilla PLAYER INVENTORY - just copied/pasted from vanilla classes for (i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } //Add ACTION BAR - just copied/pasted from vanilla classes for (i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142)); } } /** * This should always return true, since custom inventory can be accessed from anywhere */ @Override public boolean canInteractWith(EntityPlayer player) { return true; } /** * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. * Basically the same as every other container I make, since I define the same constant indices for all of them */ 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(); //Either armor slot or custom item slot was clicked if (par2 < INV_START) { //try to place in player inventory / action bar if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); } //Item is in inventory / hotbar, try to place either in custom or armor slots else { //if item is our custom item if (itemstack1.getItem() instanceof ItemMag) { if (!this.mergeItemStack(itemstack1, 0, InventoryCustomPlayer.INV_SIZE, false)) { return null; } } //if item is armor else if (itemstack1.getItem() instanceof ItemArmor) { int type = ((ItemArmor) itemstack1.getItem()).armorType; if (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, false)) { return null; } } //item in player's inventory, but not in action bar else if (par2 >= INV_START && par2 < HOTBAR_START) { //place in action bar if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_START + 1, false)) { return null; } } //item in action bar - place in player inventory else if (par2 >= HOTBAR_START && par2 < HOTBAR_END + 1) { if (!this.mergeItemStack(itemstack1, INV_START, INV_END + 1, 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; } } Here is my ExtendedPlayer package com.phantasyrealms.inventory; import java.io.DataOutputStream; import ibxm.Player; import org.apache.commons.io.output.ByteArrayOutputStream; import com.phantasyrealms.main.MainRegistry; import com.phantasyrealms.main.ServerProxy; import com.phantasyrealms.packethandling.PacketHandler; import cpw.mods.fml.common.FMLCommonHandler; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.common.IExtendedEntityProperties; public class ExtendedPlayer implements IExtendedEntityProperties { /* Here I create a constant EXT_PROP_NAME for this class of properties You need a unique name for every instance of IExtendedEntityProperties you make, and doing it at the top of each class as a constant makes it very easy to organize and avoid typos. It's easiest to keep the same constant name in every class, as it will be distinguished by the class name: ExtendedPlayer.EXT_PROP_NAME vs. ExtendedEntity.EXT_PROP_NAME Note that a single entity can have multiple extended properties, so each property should have a unique name. Try to come up with something more unique than the tutorial example. */ public final static String EXT_PROP_NAME = "ExtendedPlayer"; public final InventoryCustomPlayer inventory = new InventoryCustomPlayer(); /** * Used to register these extended properties for the player during EntityConstructing event * This method is for convenience only; it will make your code look nicer */ public static final void register(EntityPlayer player) { player.registerExtendedProperties(ExtendedPlayer.EXT_PROP_NAME, new ExtendedPlayer()); } /** * Returns ExtendedPlayer properties for player * This method is for convenience only; it will make your code look nicer */ public static final ExtendedPlayer get(EntityPlayer player) { return (ExtendedPlayer) player.getExtendedProperties(EXT_PROP_NAME); } // Save any custom data that needs saving here @Override public void saveNBTData(NBTTagCompound compound) { // We need to create a new tag compound that will save everything for our Extended Properties NBTTagCompound properties = new NBTTagCompound(); // Write custom inventory to NBT this.inventory.writeToNBT(properties); compound.setTag(EXT_PROP_NAME, properties); } // Load whatever data you saved @Override public void loadNBTData(NBTTagCompound compound) { NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME); this.inventory.readFromNBT(properties); } private static final String getSaveKey(EntityPlayer player) { // no longer a username field, so use the command sender name instead: return player.getCommandSenderName() + ":" + EXT_PROP_NAME; } public static final void loadProxyData(EntityPlayer player) { ExtendedPlayer playerData = ExtendedPlayer.get(player); NBTTagCompound savedData = ServerProxy.getEntityData(getSaveKey(player)); if (savedData != null) { playerData.loadNBTData(savedData); } } /* I personally have yet to find a use for this method. If you know of any, please let me know and I'll add it in! */ @Override public void init(Entity entity, World world) { } public void sync() { // TODO Auto-generated method stub } } Here is my GuiCustomPlayerInventory package com.phantasyrealms.inventory; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.resources.I18n; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; public class GuiCustomPlayerInventory extends GuiContainer { /** x size of the inventory window in pixels. Defined as float, passed as int */ private float xSize_lo; /** y size of the inventory window in pixels. Defined as float, passed as int. */ private float ySize_lo; /** Normally I use '(ModInfo.MOD_ID, "textures/...")', but it can be done this way as well */ private static final ResourceLocation iconLocation = new ResourceLocation("tutorial:textures/gui/custom_inventory.png"); /** Could use IInventory type to be more generic, but this way will save an import... */ private final InventoryCustomPlayer inventory; public GuiCustomPlayerInventory(EntityPlayer player, InventoryPlayer inventoryPlayer, InventoryCustomPlayer inventoryCustom) { super(new ContainerCustomPlayer(player, inventoryPlayer, inventoryCustom)); this.inventory = inventoryCustom; //if you need the player for something later on, store it in a local variable here as well } /** * Draws the screen and all the components in it. */ public void drawScreen(int par1, int par2, float par3) { super.drawScreen(par1, par2, par3); this.xSize_lo = (float)par1; this.ySize_lo = (float)par2; } /** * Draw the foreground layer for the GuiContainer (everything in front of the items) */ protected void drawGuiContainerForegroundLayer(int par1, int par2) { //This method will simply draw inventory names on the screen - you could do without it entirely //if that's not important to you, since we are overriding the default inventory rather than //creating a specific type of inventory String s = this.inventory.hasCustomInventoryName() ? this.inventory.getInventoryName() : I18n.format(this.inventory.getInventoryName()); //with the name "Custom Inventory", the 'Cu' will be drawn in the first slot this.fontRendererObj.drawString(s, this.xSize - this.fontRendererObj.getStringWidth(s), 12, 4210752); //this just adds "Inventory" above the player's inventory below this.fontRendererObj.drawString(I18n.format("container.inventory"), 80, this.ySize - 96, 4210752); } /** * Draw the background layer for the GuiContainer (everything behind the items) */ protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(iconLocation); 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; drawPlayerModel(k + 51, l + 75, 30, (float)(k + 51) - this.xSize_lo, (float)(l + 75 - 50) - this.ySize_lo, this.mc.thePlayer); } /** * This renders the player model in standard inventory position; * copied straight from vanilla code but with renamed method parameters */ public static void drawPlayerModel(int x, int y, int scale, float yaw, float pitch, EntityLivingBase entity) { GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glPushMatrix(); GL11.glTranslatef(x, y, 50.0F); GL11.glScalef(-scale, scale, scale); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); float f2 = entity.renderYawOffset; float f3 = entity.rotationYaw; float f4 = entity.rotationPitch; float f5 = entity.prevRotationYawHead; float f6 = entity.rotationYawHead; GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-((float) Math.atan(pitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F); entity.renderYawOffset = (float) Math.atan(yaw / 40.0F) * 20.0F; entity.rotationYaw = (float) Math.atan(yaw / 40.0F) * 40.0F; entity.rotationPitch = -((float) Math.atan(pitch / 40.0F)) * 20.0F; entity.rotationYawHead = entity.rotationYaw; entity.prevRotationYawHead = entity.rotationYaw; GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); RenderManager.instance.playerViewY = 180.0F; RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); entity.renderYawOffset = f2; entity.rotationYaw = f3; entity.rotationPitch = f4; entity.prevRotationYawHead = f5; entity.rotationYawHead = f6; GL11.glPopMatrix(); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glDisable(GL11.GL_TEXTURE_2D); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); } } Here is my InventoryCustomPlayer package com.phantasyrealms.inventory; import com.phantasyrealms.item.PhantasyRealmsItems; import com.phantasyrealms.item.Saber; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; public class InventoryCustomPlayer implements IInventory { /** The name your custom inventory will display in the GUI, possibly just "Inventory" */ private final String name = "Custom Inventory"; /** The key used to store and retrieve the inventory from NBT */ private final String tagName = "CustomInvTag"; /** Define the inventory size here for easy reference */ // This is also the place to define which slot is which if you have different types, // for example SLOT_SHIELD = 0, SLOT_AMULET = 1; public static final int INV_SIZE = 2; /** Inventory's size must be same as number of slots you add to the Container class */ private ItemStack[] inventory = new ItemStack[iNV_SIZE]; public InventoryCustomPlayer() { // don't need anything here! } @Override public int getSizeInventory() { return inventory.length; } @Override public ItemStack getStackInSlot(int slot) { return inventory[slot]; } @Override public ItemStack decrStackSize(int slot, int amount) { ItemStack stack = getStackInSlot(slot); if (stack != null) { if (stack.stackSize > amount) { stack = stack.splitStack(amount); this.markDirty(); } else { setInventorySlotContents(slot, null); } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int slot) { ItemStack stack = getStackInSlot(slot); setInventorySlotContents(slot, null); return stack; } @Override public void setInventorySlotContents(int slot, ItemStack itemstack) { this.inventory[slot] = itemstack; if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) { itemstack.stackSize = this.getInventoryStackLimit(); } this.markDirty(); } @Override public String getInventoryName() { return name; } @Override public boolean hasCustomInventoryName() { return name.length() > 0; } /** * Our custom slots are similar to armor - only one item per slot */ @Override public int getInventoryStackLimit() { return 1; } @Override public void markDirty() { for (int i = 0; i < getSizeInventory(); ++i) { if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) { inventory[i] = null; } } } @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return true; } @Override public void openInventory() {} @Override public void closeInventory() {} /** * This method doesn't seem to do what it claims to do, as * items can still be left-clicked and placed in the inventory * even when this returns false */ @Override public boolean isItemValidForSlot(int slot, ItemStack itemstack) { // If you have different kinds of slots, then check them here: // if (slot == SLOT_SHIELD && itemstack.getItem() instanceof ItemShield) return true; // For now, only ItemUseMana items can be stored in these slots return itemstack.getItem() instanceof Saber; } public void writeToNBT(NBTTagCompound compound) { NBTTagList items = new NBTTagList(); for (int i = 0; i < getSizeInventory(); ++i) { if (getStackInSlot(i) != null) { NBTTagCompound item = new NBTTagCompound(); item.setByte("Slot", (byte) i); getStackInSlot(i).writeToNBT(item); items.appendTag(item); } } // We're storing our items in a custom tag list using our 'tagName' from above // to prevent potential conflicts compound.setTag(tagName, items); } public void readFromNBT(NBTTagCompound compound) { // now you must include the NBTBase type ID when getting the list; NBTTagCompound's ID is 10 NBTTagList items = compound.getTagList(tagName, compound.getId()); for (int i = 0; i < items.tagCount(); ++i) { // tagAt(int) has changed to getCompoundTagAt(int) NBTTagCompound item = items.getCompoundTagAt(i); byte slot = item.getByte("Slot"); if (slot >= 0 && slot < getSizeInventory()) { inventory[slot] = ItemStack.loadItemStackFromNBT(item); } } } } Here is my KeyHandler package com.phantasyrealms.inventory; import org.lwjgl.input.Keyboard; import com.phantasyrealms.main.MainRegistry; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent; import net.minecraft.client.gui.GuiChat; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.EntityPlayer; public class KeyHandler { /** Key index for easy handling */ public static final int CUSTOM_INV = 0; /** Key descriptions; use a language file to localize the description later */ private static final String[] desc = {"Mag"}; /** Default key values these can be changed using the in-game menu */ private static final int[] keyValues = {Keyboard.KEY_P}; private final KeyBinding[] keys; public KeyHandler() { // the advantage of doing it with the above static arrays is now we can just loop through // creating and registering all of our keybindings automatically keys = new KeyBinding[desc.length]; for (int i = 0; i < desc.length; ++i) { // create the new KeyBinding: keys[i] = new KeyBinding(desc[i], keyValues[i], "Mag"); // and be sure to register it to the ClientRegistry: ClientRegistry.registerKeyBinding(keys[i]); } } // rather than the old KeyHandler class doing it for us // now we must subscribe to the KeyInputEvent ourselves @SubscribeEvent public void onKeyInput(KeyInputEvent event) { // first check that the player is not using the chat menu // you can use this method from before: // if (FMLClientHandler.instance().getClient().inGameHasFocus) { // or you can use this new one that is available, doesn't really matter if (!FMLClientHandler.instance().isGUIOpen(GuiChat.class)) { // you can get the key code of the key pressed using the Keyboard class: int kb = Keyboard.getEventKey(); // similarly, you can get the key state, but this will always be true when the event is fired: boolean isDown = Keyboard.getEventKeyState(); // same as before, chain if-else if statements to find which of your custom keys // was pressed and act accordingly: if (kb == keys[CUSTOM_INV].getKeyCode()) { EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; // if (player.openContainer instanceof ContainerCustomPlayer) { // before you could close the screen from here, but that no longer seems to be // possible instead, you need to do so from within the GUI itself // so we will just send a packet to open the GUI: } } } public static void init() { // TODO Auto-generated method stub } } Here is my CustomSlot package com.phantasyrealms.inventory; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; public class SlotMag extends Slot { /** The armor type that can be placed on that slot, it uses the same values of armorType field on ItemArmor. */ final int armorType; /** The parent class of this slot, ContainerPlayer, SlotArmor is a Anon inner class. */ final EntityPlayer player; public SlotMag(EntityPlayer player, IInventory inventory, int slotIndex, int x, int y, int armorType) { super(inventory, slotIndex, x, y); this.player = player; this.armorType = armorType; } /** * Returns the maximum stack size for a given slot (usually the same as getInventoryStackLimit(), but 1 in the case * of armor slots) */ public int getSlotStackLimit() { return 1; } /** * Check if the stack is a valid item for this slot. Always true beside for the armor slots. */ public boolean isItemValid(ItemStack itemstack) { Item item = (itemstack == null ? null : itemstack.getItem()); return item != null && item.isValidArmor(itemstack, armorType, player); } /** * Returns the icon index on items.png that is used as background image of the slot. */ @SideOnly(Side.CLIENT) public IIcon getBackgroundIconIndex() { return ItemArmor.func_94602_b(this.armorType); } } Now what all do I need to make this work?
-
InventorySlot/PacketHandler
I have an Inventory made as I followed CoolAlias's Custom Inventory tutorial, however the trouble I run into is again, the Packethandler, his is for 1.6 and his tut for updating it is too vague and confusing to follow, and when trying to link his own version of a packet handler to the custom inventory tut I also get confused. I want one extra armor slot. As for putting my main class, I thought it would help as a reference to what to put.
-
InventorySlot/PacketHandler
So I am creating a mod, and I want an extra armor slot, however the tutorials out there are good until they get to packet handling, and its not just confusing for me but for others too. So I come here today to see if anyone would help write this for me. Anything to do with just adding one extra armor slot. PM for more info if you are truly interested because I understand that this is a lot to ask for, I am just done with trying to figure this out. Here is my main mod file package com.phantasyrealms.main; import sun.net.NetworkServer; import net.minecraftforge.common.MinecraftForge; import com.phantasyrealms.entity.EntityBoomaMob; import com.phantasyrealms.entity.PhantasyRealmsEntity; import com.phantasyrealms.eventhandler.PhantasyEventHandler; import com.phantasyrealms.item.PhantasyRealmsItems; import com.phantasyrealms.lib.Strings; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; @Mod(modid = Strings.MODID, name = Strings.name, version = Strings.version) public class MainRegistry { @SidedProxy(clientSide = "com.phantasyrealms.main.ClientProxy", serverSide = "com.phantasyrealms.main.ServerProxy") public static ServerProxy proxy; @Instance(Strings.MODID) public static MainRegistry modInstance; public static Object instance; public class RegisterKeyBindings { } /** * Loads before * @param PostEvent */ @EventHandler public static void PreLoad(FMLPreInitializationEvent PreEvent){ PhantasyRealmsEntity.mainRegistry(); proxy.registerRenderThings(); PhantasyRealmsItems.mainRegistry(); CraftingManager.mainRegistry(); } /** * Loads during * @param event */ @EventHandler public static void load(FMLInitializationEvent event){ } /** * Loads after * @param PostEvent */ @EventHandler public static void PostLoad(FMLPostInitializationEvent PostEvent){ } }
-
[HELP]Increase Random Mob Drops
Thanks, I know it may seem basic to you guys but I learn by trial and error and by actually testing with things not just reading about them, and I appreciate you helping me out. Thank you
-
[HELP]Increase Random Mob Drops
No sorry, I read your comment wrong, there are 10 possible Items a mob can drop, each time a mob is killed 1 out of those 10 items is dropped.
IPS spam blocked by CleanTalk.