-
Posts
867 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JimiIT92
-
[1.8] Spawning entities on server cause crash
JimiIT92 replied to JimiIT92's topic in Modder Support
So it turns out that the problem was that i registered the rendering in the preInit method instead of the init Thanks to all who tried to help me -
[1.8] Spawning entities on server cause crash
JimiIT92 replied to JimiIT92's topic in Modder Support
Removed that functions, still crash My class now looks like this package hl.entities.renderer; import org.lwjgl.opengl.GL11; import hl.entities.EntityBee; import hl.models.ModelBee; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class RenderBee extends RenderLiving { private float scale; public RenderBee(RenderManager mgr, ModelBee par1ModelBase, float par2, float d) { super(mgr, par1ModelBase, par2); this.scale = d; } protected void preRenderScale(EntityBee par1EntityBee, float par2) { GL11.glScalef(this.scale, this.scale, this.scale); } protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) { this.preRenderScale((EntityBee)par1EntityLivingBase, par2); } @Override protected ResourceLocation getEntityTexture(Entity entity) { return new ResourceLocation("hl:textures/mobs/bee.png"); } } -
[1.8] Spawning entities on server cause crash
JimiIT92 replied to JimiIT92's topic in Modder Support
Maybe not I had that functions just because is a port from 1.7.10, and i'm not really expert with rendering in general So i'll try removing them and see if it works -
[1.8] Spawning entities on server cause crash
JimiIT92 replied to JimiIT92's topic in Modder Support
It crashes also without the core mod So basically i should register the rendering only client side? And in that case how? EDIT: it crashes also client side. The line 45 and 55 refers to the doRender and renderBee functions in the rendering class -
[1.8] Spawning entities on server cause crash
JimiIT92 replied to JimiIT92's topic in Modder Support
I don't know In the client everything works fine. By the way here is the model and the entity class, just in case is needed Model class package hl.models; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; public class ModelBee extends ModelBase { ModelRenderer head; ModelRenderer rightantenna; ModelRenderer leftantenna; ModelRenderer mouth; ModelRenderer body; ModelRenderer butt; ModelRenderer stinger; ModelRenderer legs; ModelRenderer leftwing; ModelRenderer rightwing; public ModelBee() { textureWidth = 64; textureHeight = 32; head = new ModelRenderer(this, 0, 0); head.addBox(-2.5F, -9F, -4F, 5, 5, 4); head.setRotationPoint(0F, 0F, -2F); head.setTextureSize(64, 32); head.mirror = true; setRotation(head, 0F, 0F, 0F); rightantenna = new ModelRenderer(this, 0, 0); rightantenna.addBox(-1F, -11F, -2F, 1, 2, 1); rightantenna.setRotationPoint(0F, 0F, -2F); rightantenna.setTextureSize(64, 32); setRotation(rightantenna, 0F, 0.7853982F, 0F); rightantenna.mirror = false; leftantenna = new ModelRenderer(this, 0, 9); leftantenna.addBox(1F, -11F, 0F, 1, 2, 1); leftantenna.setRotationPoint(0F, 0F, -2F); leftantenna.setTextureSize(64, 32); leftantenna.mirror = true; setRotation(leftantenna, 0F, 0.7853982F, 0F); mouth = new ModelRenderer(this, 18, 0); mouth.addBox(-0.5F, -5F, -5F, 1, 1, 1); mouth.setRotationPoint(0F, 0F, -2F); mouth.setTextureSize(64, 32); mouth.mirror = false; setRotation(mouth, 0F, 0F, 0F); body = new ModelRenderer(this, 0, 12); body.addBox(-2.5F, -7.5F, 0F, 5, 5, 5); body.setRotationPoint(0F, -2F, -2F); body.setTextureSize(64, 32); body.mirror = true; setRotation(body, 0F, 0F, 0F); butt = new ModelRenderer(this, 24, 20); butt.addBox(-2.5F, -3F, 0F, 5, 5, 7); butt.setRotationPoint(0F, -6.5F, 3F); butt.setTextureSize(64, 32); butt.mirror = false; setRotation(butt, -0.2617994F, 0F, 0F); stinger = new ModelRenderer(this, 18, 6); stinger.addBox(-0.5F, -0F, 7F, 1, 1, 2); stinger.setRotationPoint(0F, -6.5F, 3F); stinger.setTextureSize(64, 32); stinger.mirror = false; setRotation(stinger, -0.2617994F, 0F, 0F); legs = new ModelRenderer(this, 0, 22); legs.addBox(-2.5F, -3F, 0F, 5, 3, 7); legs.setRotationPoint(0F, -2F, -2F); legs.setTextureSize(64, 32); legs.mirror = false; setRotation(legs, 0F, 0F, 0F); leftwing = new ModelRenderer(this, 34, 0); leftwing.addBox(0F, -6F, -2F, 0, 5, 4); leftwing.setRotationPoint(1.5F, -8.5F, 0F); leftwing.setTextureSize(64, 32); setRotation(leftwing, 0F, 3.141593F, 0F); leftwing.mirror = true; rightwing = new ModelRenderer(this, 26, 0); rightwing.addBox(0F, -6F, -2F, 0, 5, 4); rightwing.setRotationPoint(-1F, -8.5F, 0F); rightwing.setTextureSize(64, 32); rightwing.mirror = true; setRotation(rightwing, 0F, 0F, 0F); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); head.render(f5); rightantenna.render(f5); leftantenna.render(f5); mouth.render(f5); body.render(f5); butt.render(f5); stinger.render(f5); legs.render(f5); leftwing.render(f5); rightwing.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { //super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.head.rotateAngleX = f5 / (180F / (float)Math.PI); this.head.rotateAngleY = f4 / (180F / (float)Math.PI); this.head.rotateAngleZ = 0.0F; this.mouth.rotateAngleX = this.head.rotateAngleX; this.mouth.rotateAngleY = this.head.rotateAngleY; this.mouth.rotateAngleZ = this.head.rotateAngleZ; this.leftantenna.rotateAngleX = this.head.rotateAngleX; this.leftantenna.rotateAngleY = this.head.rotateAngleY + 0.7853982F; this.leftantenna.rotateAngleZ = this.head.rotateAngleZ; this.rightantenna.rotateAngleX = this.head.rotateAngleX; this.rightantenna.rotateAngleY = this.head.rotateAngleY + 0.7853982F; this.rightantenna.rotateAngleZ = this.head.rotateAngleZ; this.rightwing.rotateAngleZ = (0.3F * MathHelper.sin(f2 * 1.3F) + 0.4F) - 45F; this.leftwing.rotateAngleZ = -this.rightwing.rotateAngleZ; } } Entity class package hl.entities; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAILeapAtTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.pathfinding.PathEntity; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.BlockPos; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; public class EntityBee extends EntityMob { /** Coordinates of where the bat spawned. */ private BlockPos spawnPosition; private int allySummonCooldown; private float heightOffset = 2; public float field_70889_i = 1.0F; public EntityBee(World par1World) { super(par1World); this.setSize(0.5F, 0.9F); this.setIsBeeHanging(false); this.tasks.addTask(0, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false)); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, new EntityAIWander(this, 1.0D)); this.tasks.addTask(3, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true)); this.tasks.addTask(4, new EntityAILeapAtTarget(this, 0.38F)); } protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(16, new Byte((byte)0)); } /** * Returns true if this entity should push and be pushed by other entities when colliding. */ public boolean canBePushed() { return false; } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(6.0D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(1.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.6D); } public boolean getIsBeeHanging() { return false; } public void setIsBeeHanging(boolean par1) { byte b0 = this.dataWatcher.getWatchableObjectByte(16); if (par1) { this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1))); } else { this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2))); } } protected int getExperiencePoints(EntityPlayer par1EntityPlayer) { this.experienceValue = (int)((float)this.experienceValue * 0.5F); return super.getExperiencePoints(par1EntityPlayer); } /** * Returns true if the newer Entity AI code should be run */ protected boolean isAIEnabled() { return true; } @Override public void onLivingUpdate() { super.onLivingUpdate(); this.field_70889_i = (float)((double)this.field_70889_i * 0.9D); if (!this.onGround && this.motionY < 0.0D) { this.motionY *= 0.6D; } } @Override public void writeEntityToNBT(NBTTagCompound par1NGTTagCompound) { super.writeEntityToNBT(par1NGTTagCompound); } @Override public void readEntityFromNBT(NBTTagCompound par1NGTTagCompound) { super.readEntityFromNBT(par1NGTTagCompound); } @Override protected boolean canDespawn() { return false; } /** * Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); if (!this.worldObj.isRemote) { this.setBesideClimbableBlock(this.isCollidedHorizontally); } } public void setBesideClimbableBlock(boolean par1) { byte b0 = this.dataWatcher.getWatchableObjectByte(16); if (par1) { b0 = (byte)(b0 | 1); } else { b0 &= -2; } this.dataWatcher.updateObject(16, Byte.valueOf(b0)); } @Override protected String getLivingSound() { return "hl:bee_idle"; } @Override protected String getHurtSound() { return "hl:bee_hurt"; } @Override protected String getDeathSound() { return "hl:bee_hurt"; } /** * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to * prevent them from trampling crops */ protected boolean canTriggerWalking() { return false; } /** * Called when the mob is falling. Calculates and applies fall damage. */ protected void fall(float par1) {} /** * Takes in the distance the entity has fallen this tick and whether its on the ground to update the fall distance * and deal fall damage if landing on the ground. Args: distanceFallenThisTick, onGround */ protected void updateFallState(double par1, boolean par3) {} /** * Return whether this entity should NOT trigger a pressure plate or a tripwire. */ public boolean doesEntityNotTriggerPressurePlate() { return true; } /** * Called when the entity is attacked. */ public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { if (this.isEntityInvulnerable(par1DamageSource)) { return false; } else { if (!this.worldObj.isRemote && this.getIsBeeHanging()) { this.setIsBeeHanging(false); } return super.attackEntityFrom(par1DamageSource, par2); } } /** * Finds the closest player within 16 blocks to attack, or null if this Entity isn't interested in attacking * (Animals, Spiders at day, peaceful PigZombies). */ protected Entity findPlayerToAttack() { double d0 = 8.0D; return this.worldObj.getClosestPlayerToEntity(this, d0); } public boolean attackEntityAsMob(Entity par1Entity) { if (super.attackEntityAsMob(par1Entity)) { if (par1Entity instanceof EntityLivingBase) { byte b0 = 0; if (this.worldObj.getDifficulty() == EnumDifficulty.NORMAL) { b0 = 7; } else if (this.worldObj.getDifficulty() == EnumDifficulty.HARD) { b0 = 15; } if (b0 > 7) { ((EntityLivingBase)par1Entity).addPotionEffect(new PotionEffect(Potion.poison.id, b0 * 10, 0)); } this.setHealth(0); } return true; } else { return false; } } public boolean getCanSpawnHere() { BlockPos blockpos = new BlockPos(this.posX, this.getEntityBoundingBox().minY, this.posZ); return this.worldObj.getLight(blockpos) > 7; } } -
As by title, if i spawn an entity in a server world the game crash This is the crash report ---- Minecraft Crash Report ---- WARNING: coremods are present: NowWithRendering (hopperducts-mc1.8-1.4.5.jar) Contact their authors BEFORE contacting forge // Ouch. That hurt Time: 12/22/15 12:41 PM Description: Rendering entity in world java.lang.NullPointerException: Rendering entity in world at net.minecraft.client.renderer.entity.RendererLivingEntity.func_110813_b(RendererLivingEntity.java:563) at net.minecraft.client.renderer.entity.RenderLiving.func_110813_b(SourceFile:22) at net.minecraft.client.renderer.entity.RenderLiving.func_110813_b(SourceFile:15) at net.minecraft.client.renderer.entity.RendererLivingEntity.func_77033_b(RendererLivingEntity.java:481) at net.minecraft.client.renderer.entity.RendererLivingEntity.func_177067_a(RendererLivingEntity.java:578) at net.minecraft.client.renderer.entity.Render.func_76986_a(SourceFile:39) at net.minecraft.client.renderer.entity.RendererLivingEntity.func_76986_a(RendererLivingEntity.java:198) at net.minecraft.client.renderer.entity.RenderLiving.func_76986_a(SourceFile:40) at hl.entities.renderer.RenderBee.renderBee(RenderBee.java:55) at hl.entities.renderer.RenderBee.func_76986_a(RenderBee.java:45) at net.minecraft.client.renderer.entity.RenderManager.func_147939_a(RenderManager.java:370) at net.minecraft.client.renderer.entity.RenderManager.func_147936_a(RenderManager.java:327) at net.minecraft.client.renderer.entity.RenderManager.func_147937_a(RenderManager.java:294) at net.minecraft.client.renderer.RenderGlobal.func_180446_a(RenderGlobal.java:786) at net.minecraft.client.renderer.EntityRenderer.func_175068_a(EntityRenderer.java:1570) at net.minecraft.client.renderer.EntityRenderer.func_78471_a(EntityRenderer.java:1458) at net.minecraft.client.renderer.EntityRenderer.func_78480_b(EntityRenderer.java:1242) at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1055) at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:345) at net.minecraft.client.main.Main.main(SourceFile:120) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) 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 net.minecraft.client.renderer.entity.RendererLivingEntity.func_110813_b(RendererLivingEntity.java:563) at net.minecraft.client.renderer.entity.RenderLiving.func_110813_b(SourceFile:22) at net.minecraft.client.renderer.entity.RenderLiving.func_110813_b(SourceFile:15) at net.minecraft.client.renderer.entity.RendererLivingEntity.func_77033_b(RendererLivingEntity.java:481) at net.minecraft.client.renderer.entity.RendererLivingEntity.func_177067_a(RendererLivingEntity.java:578) at net.minecraft.client.renderer.entity.Render.func_76986_a(SourceFile:39) at net.minecraft.client.renderer.entity.RendererLivingEntity.func_76986_a(RendererLivingEntity.java:198) at net.minecraft.client.renderer.entity.RenderLiving.func_76986_a(SourceFile:40) at hl.entities.renderer.RenderBee.renderBee(RenderBee.java:55) at hl.entities.renderer.RenderBee.func_76986_a(RenderBee.java:45) -- Entity being rendered -- Details: Entity Type: GiantBee (hl.entities.EntityBee) Entity ID: 98772 Entity Name: Giant Bee Entity's Exact location: 954.59, 68.00, 517.44 Entity's Block location: 954.00,68.00,517.00 - World: (954,68,517), Chunk: (at 10,4,5 in 59,32; contains blocks 944,0,512 to 959,255,527), Region: (1,1; contains chunks 32,32 to 63,63, blocks 512,0,512 to 1023,255,1023) Entity's Momentum: 0.00, 0.00, 0.00 Entity's Rider: ~~ERROR~~ NullPointerException: null Entity's Vehicle: ~~ERROR~~ NullPointerException: null -- Renderer details -- Details: Assigned renderer: hl.entities.renderer.RenderBee@5d53dc7a Location: 2.78,-1.00,-17.23 - World: (2,-1,-18), Chunk: (at 2,-1,14 in 0,-2; contains blocks 0,0,-32 to 15,255,-17), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1) Rotation: -60.46875 Delta: 0.17472082 Stacktrace: at net.minecraft.client.renderer.entity.RenderManager.func_147939_a(RenderManager.java:370) at net.minecraft.client.renderer.entity.RenderManager.func_147936_a(RenderManager.java:327) at net.minecraft.client.renderer.entity.RenderManager.func_147937_a(RenderManager.java:294) at net.minecraft.client.renderer.RenderGlobal.func_180446_a(RenderGlobal.java:786) at net.minecraft.client.renderer.EntityRenderer.func_175068_a(EntityRenderer.java:1570) at net.minecraft.client.renderer.EntityRenderer.func_78471_a(EntityRenderer.java:1458) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['kenkune'/96278, l='MpServer', x=951.79, y=69.00, z=534.65]] Chunk stats: MultiplayerChunkCache: 400, 400 Level seed: 0 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: Level spawn location: -216.00,64.00,256.00 - World: (-216,64,256), Chunk: (at 8,4,0 in -14,16; contains blocks -224,0,256 to -209,255,271), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 6757393 game time, 35350 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: true), thunder time: 0 (now: false) Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false Forced entities: 81 total; [EntityZombie['Zombie'/96516, l='MpServer', x=948.50, y=59.00, z=556.50], EntityWolf['Wolf'/96527, l='MpServer', x=1001.50, y=64.00, z=546.50], EntityZombie['Zombie'/96529, l='MpServer', x=884.53, y=38.00, z=572.94], EntityCreeper['Creeper'/96530, l='MpServer', x=908.84, y=10.00, z=581.75], EntityPig['Pig'/96533, l='MpServer', x=897.50, y=70.00, z=569.50], EntityPig['Pig'/96532, l='MpServer', x=901.50, y=69.00, z=570.50], EntityZombie['Zombie'/98584, l='MpServer', x=893.22, y=42.00, z=563.78], EntityPig['Pig'/96541, l='MpServer', x=921.16, y=68.00, z=548.50], EntityPig['Pig'/96540, l='MpServer', x=932.94, y=67.00, z=536.00], EntityWolf['Wolf'/96543, l='MpServer', x=1014.50, y=70.00, z=544.75], EntityPig['Pig'/96542, l='MpServer', x=916.94, y=68.00, z=539.06], EntityZombie['Zombie'/98593, l='MpServer', x=907.97, y=18.00, z=462.50], EntityZombie['Zombie'/98592, l='MpServer', x=911.50, y=20.00, z=462.50], EntityZombie['Zombie'/96555, l='MpServer', x=886.50, y=38.00, z=574.50], EntitySkeleton['Skeleton'/96554, l='MpServer', x=885.50, y=38.00, z=569.50], EntityCreeper['Creeper'/97325, l='MpServer', x=887.41, y=44.00, z=585.94], EntitySkeleton['Skeleton'/96556, l='MpServer', x=891.63, y=42.00, z=563.31], EntityPig['Pig'/96561, l='MpServer', x=894.50, y=77.00, z=571.50], EntityPig['Pig'/96560, l='MpServer', x=894.50, y=71.00, z=568.50], EntitySpider['Spider'/96573, l='MpServer', x=875.69, y=44.09, z=588.69], EntityPig['Pig'/96575, l='MpServer', x=1033.50, y=65.00, z=555.50], EntityPig['Pig'/96577, l='MpServer', x=1033.50, y=65.00, z=553.50], EntityPig['Pig'/96576, l='MpServer', x=1032.50, y=67.00, z=553.50], EntityPig['Pig'/96578, l='MpServer', x=1034.50, y=64.00, z=553.50], EntityWolf['Wolf'/96581, l='MpServer', x=1005.50, y=64.00, z=543.50], EntityWolf['Wolf'/96582, l='MpServer', x=1006.50, y=64.00, z=543.50], EntityPig['Pig'/96589, l='MpServer', x=926.38, y=67.00, z=539.97], EntityPig['Pig'/96591, l='MpServer', x=1023.09, y=64.00, z=533.03], EntityPig['Pig'/96590, l='MpServer', x=1027.22, y=64.00, z=533.81], EntityPig['Pig'/96593, l='MpServer', x=962.19, y=69.00, z=515.13], EntityPig['Pig'/96853, l='MpServer', x=962.50, y=69.00, z=463.50], EntityPig['Pig'/96852, l='MpServer', x=962.50, y=69.00, z=463.50], EntityPig['Pig'/96854, l='MpServer', x=961.28, y=75.00, z=471.47], EntityPig['Pig'/96601, l='MpServer', x=957.16, y=63.00, z=524.50], EntityPig['Pig'/96603, l='MpServer', x=956.81, y=64.00, z=521.16], EntityPig['Pig'/96602, l='MpServer', x=955.19, y=64.00, z=522.78], EntityPig['Pig'/96605, l='MpServer', x=1030.66, y=65.00, z=527.53], EntityPig['Pig'/96604, l='MpServer', x=1025.63, y=64.00, z=534.38], EntityPig['Pig'/96871, l='MpServer', x=997.50, y=67.00, z=464.50], EntityPig['Pig'/96870, l='MpServer', x=994.50, y=67.00, z=464.50], EntityPig['Pig'/96873, l='MpServer', x=997.50, y=67.00, z=464.50], EntityPig['Pig'/96872, l='MpServer', x=998.50, y=67.00, z=461.50], EntitySheep['Sheep'/96912, l='MpServer', x=918.84, y=73.00, z=459.16], EntitySkeleton['Skeleton'/98201, l='MpServer', x=920.69, y=12.00, z=605.28], EntitySkeleton['Skeleton'/98200, l='MpServer', x=918.22, y=12.00, z=605.28], EntityPig['Pig'/96667, l='MpServer', x=887.50, y=72.00, z=494.16], EntitySkeleton['Skeleton'/96410, l='MpServer', x=982.25, y=27.47, z=593.69], EntityPig['Pig'/96666, l='MpServer', x=887.50, y=72.00, z=495.78], EntitySpider['Spider'/98202, l='MpServer', x=919.50, y=12.00, z=607.16], EntityPig['Pig'/96668, l='MpServer', x=887.50, y=71.00, z=492.50], EntityMinecartChest['container.minecart'/96421, l='MpServer', x=926.50, y=36.06, z=616.50], EntityPig['Pig'/96679, l='MpServer', x=909.50, y=71.00, z=515.50], EntityBat['Bat'/96422, l='MpServer', x=1017.50, y=39.97, z=611.47], EntityPig['Pig'/96678, l='MpServer', x=910.50, y=71.00, z=513.50], EntityBat['Bat'/96427, l='MpServer', x=963.77, y=27.98, z=587.20], EntityPig['Pig'/96443, l='MpServer', x=949.44, y=67.16, z=576.50], EntityBat['Bat'/96442, l='MpServer', x=959.75, y=30.10, z=588.88], EntityPig['Pig'/96444, l='MpServer', x=951.72, y=68.00, z=579.78], EntityPig['Pig'/96703, l='MpServer', x=919.78, y=69.00, z=516.28], EntityItem['item.tile.torch'/96448, l='MpServer', x=927.44, y=35.00, z=596.53], EntityPig['Pig'/96704, l='MpServer', x=912.81, y=69.00, z=521.84], EntityPig['Pig'/96453, l='MpServer', x=936.31, y=67.00, z=588.44], EntityZombie['Zombie'/98508, l='MpServer', x=880.50, y=26.00, z=457.50], EntityZombie['Zombie'/98510, l='MpServer', x=878.50, y=26.00, z=459.50], EntityPig['Pig'/96465, l='MpServer', x=900.44, y=70.00, z=603.38], EntityPig['Pig'/96467, l='MpServer', x=906.91, y=66.00, z=611.13], EntityPig['Pig'/96466, l='MpServer', x=898.16, y=70.00, z=604.50], EntityBee['Giant Bee'/98773, l='MpServer', x=954.81, y=68.00, z=520.16], EntitySkeleton['Skeleton'/96468, l='MpServer', x=917.50, y=13.00, z=583.50], EntityBee['Giant Bee'/98772, l='MpServer', x=954.59, y=68.00, z=517.44], EntityCreeper['Creeper'/96481, l='MpServer', x=943.00, y=60.00, z=573.44], EntityPig['Pig'/96480, l='MpServer', x=956.03, y=63.00, z=575.59], EntityPig['Pig'/96482, l='MpServer', x=956.81, y=68.00, z=574.81], EntityPlayerSP['kenkune'/96278, l='MpServer', x=951.79, y=69.00, z=534.65], EntityBat['Bat'/96495, l='MpServer', x=892.63, y=18.10, z=615.36], EntityCreeper['Creeper'/96501, l='MpServer', x=880.50, y=38.00, z=606.50], EntityBat['Bat'/96500, l='MpServer', x=887.25, y=12.56, z=599.24], EntityPig['Pig'/96503, l='MpServer', x=895.50, y=70.00, z=601.50], EntityZombie['Zombie'/96502, l='MpServer', x=892.59, y=38.00, z=600.41], EntityCreeper['Creeper'/96505, l='MpServer', x=915.28, y=17.00, z=567.28], EntityCreeper['Creeper'/96504, l='MpServer', x=914.97, y=15.00, z=569.63]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Non-integrated multiplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.func_72914_a(WorldClient.java:407) at net.minecraft.client.Minecraft.func_71396_d(Minecraft.java:2502) at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:367) at net.minecraft.client.main.Main.main(SourceFile:120) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) -- System Details -- Details: Minecraft Version: 1.8 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.8.0_25, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 267632296 bytes (255 MB) / 666447872 bytes (635 MB) up to 1060372480 bytes (1011 MB) JVM Flags: 6 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M IntCache: cache: 7, tcache: 87, allocated: 13, tallocated: 95 FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.3.1450 Optifine OptiFine_1.8_HD_U_D5 7 mods loaded, 7 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJA mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHIJA FML{8.0.99.99} [Forge Mod Loader] (forge-1.8-11.14.3.1450.jar) UCHIJA Forge{11.14.3.1450} [Minecraft Forge] (forge-1.8-11.14.3.1450.jar) UCHIJA Backpack{2.0.1} [backpack] (backpack-2.0.1-1.8.x.jar) UCHIJA DeathChest{1.8} [Death Chest] (DeathChest-1.0.2.jar) UCHIJA hl{1.0} [Half-Life 3 Mod] (HL3-1.1.1.jar) UCHIJA hopperducts{1.4.5} [Hopper Ducts] (hopperducts-mc1.8-1.4.5.jar) Loaded coremods (and transformers): NowWithRendering (hopperducts-mc1.8-1.4.5.jar) net.fybertech.nwr.NowWithRendering GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13399 Compatibility Profile Context 15.200.1062.1004' Renderer: 'AMD Radeon R9 200 Series' Launched Version: 1.8-Forge11.14.3.1450 LWJGL: 2.9.1 OpenGL: AMD Radeon R9 200 Series GL version 4.5.13399 Compatibility Profile Context 15.200.1062.1004, ATI Technologies Inc. GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: No 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) It looks like something related to render, so this is the rendering class package hl.entities.renderer; import org.lwjgl.opengl.GL11; import hl.entities.EntityBee; import hl.models.ModelBee; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class RenderBee extends RenderLiving { protected ModelBee model; public static final ResourceLocation beeTexture = new ResourceLocation("hl:textures/mobs/bee.png"); private float scale; public RenderBee(RenderManager mgr, ModelBee par1ModelBase, float par2, float d) { super(mgr, par1ModelBase, par2); model=((ModelBee)mainModel); this.scale = d; } protected void preRenderScale(EntityBee par1EntityBee, float par2) { GL11.glScalef(this.scale, this.scale, this.scale); } protected void preRenderCallback(EntityLivingBase par1EntityLivingBase, float par2) { this.preRenderScale((EntityBee)par1EntityLivingBase, par2); } @Override protected ResourceLocation getEntityTexture(Entity entity) { return beeTexture; } @Override public void doRender(Entity entity, double d0, double d1, double d2, float f, float f1) { renderBee((EntityBee)entity, d0, d1, d2, f, f1); } public void doRenderLiving(Entity par1EntityLiving, double par2, double par4, double par6, float par8, float par9) { renderBee((EntityBee)par1EntityLiving, par2, par4, par6, par8, par9); } private void renderBee(EntityBee entity, double par2, double par4, double par6, float par8, float par9) { super.doRender(entity, par2, par4, par6, par8, par9); } } The entity is registered in the preInit method by doing this EntityHandler.registerMonsters(EntityBee.class, "GiantBee", 0xDDAB22, 0x000000F); In EntityHandler i do this int entityId = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerGlobalEntityID(entityClass, name, entityId); EntityRegistry.addSpawn(entityClass, 15, 2, 4, EnumCreatureType.AMBIENT); EntityList.entityEggs.put(Integer.valueOf(entityId), new EntityList.EntityEggInfo(entityId, mainColor, subColor)); And then in ClientProxy i do this RenderingRegistry.registerEntityRenderingHandler(EntityBee.class, new RenderBee(Minecraft.getMinecraft().getRenderManager(), new ModelBee(), 0.3F, 0.5F)); wich is called from the init method So why it crashes on spawn?
-
[1.8] Giving an item to the player after a delay
JimiIT92 replied to JimiIT92's topic in Modder Support
Cool, i didn't know that method -
[1.8] Giving an item to the player after a delay
JimiIT92 replied to JimiIT92's topic in Modder Support
Thanks, that solved the flickering -
[1.8] Giving an item to the player after a delay
JimiIT92 replied to JimiIT92's topic in Modder Support
I've figured it out by doing this in the empty gun class package com.konnor; import java.util.List; import java.util.Random; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; public class ItemEmptyGun extends ItemMod { private String support; private String cane; private boolean ready = false; private boolean reload = false; public ItemEmptyGun(String par1, String par2) { super(); this.support = "material." + par1; this.cane = "material." + par2; this.setMaxStackSize(1); this.setCreativeTab((CreativeTabs)null); } public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if(player.inventory.hasItem(ModItems.bullet) || player.capabilities.isCreativeMode) { reload = true; } return stack; } @Override public void onUpdate(ItemStack stack, World worldIn, net.minecraft.entity.Entity entityIn, int itemSlot, boolean isSelected) { if(stack.getTagCompound() != null && reload) { BlockPos pos = ((EntityPlayer)entityIn).getPosition(); Random rand = new Random(); int current_delay = stack.getTagCompound().getInteger("delay")-1; if(current_delay == 0) { worldIn.playSound((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), "connorkpt:reload", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false); Item gun = null; if(this == ModItems.empty_oak_iron_hand_gun) gun = ModItems.oak_iron_hand_gun; else if(this == ModItems.empty_oak_gold_hand_gun) gun = ModItems.oak_gold_hand_gun; else if(this == ModItems.empty_oak_silver_hand_gun) gun = ModItems.oak_silver_hand_gun; else if(this == ModItems.empty_birch_iron_hand_gun) gun = ModItems.birch_iron_hand_gun; else if(this == ModItems.empty_birch_gold_hand_gun) gun = ModItems.birch_gold_hand_gun; else if(this == ModItems.empty_birch_silver_hand_gun) gun = ModItems.birch_silver_hand_gun; else if(this == ModItems.empty_dark_oak_iron_hand_gun) gun = ModItems.dark_oak_iron_hand_gun; else if(this == ModItems.empty_dark_oak_gold_hand_gun) gun = ModItems.dark_oak_gold_hand_gun; else if(this == ModItems.empty_dark_oak_silver_hand_gun) gun = ModItems.dark_oak_silver_hand_gun; else if(this == ModItems.empty_oak_iron_gun) gun = ModItems.oak_iron_gun; else if(this == ModItems.empty_oak_gold_gun) gun = ModItems.oak_gold_gun; else if(this == ModItems.empty_oak_silver_gun) gun = ModItems.oak_silver_gun; else if(this == ModItems.empty_birch_iron_gun) gun = ModItems.birch_iron_gun; else if(this == ModItems.empty_birch_gold_gun) gun = ModItems.birch_gold_gun; else if(this == ModItems.empty_birch_silver_gun) gun = ModItems.birch_silver_gun; else if(this == ModItems.empty_dark_oak_iron_gun) gun = ModItems.dark_oak_iron_gun; else if(this == ModItems.empty_dark_oak_gold_gun) gun = ModItems.dark_oak_gold_gun; else if(this == ModItems.empty_dark_oak_silver_gun) gun = ModItems.dark_oak_silver_gun; else if(this == ModItems.empty_oak_iron_musket) gun = ModItems.oak_iron_musket; else if(this == ModItems.empty_oak_gold_musket) gun = ModItems.oak_gold_musket; else if(this == ModItems.empty_oak_silver_musket) gun = ModItems.oak_silver_musket; else if(this == ModItems.empty_birch_iron_musket) gun = ModItems.birch_iron_musket; else if(this == ModItems.empty_birch_gold_musket) gun = ModItems.birch_gold_musket; else if(this == ModItems.empty_birch_silver_musket) gun = ModItems.birch_silver_musket; else if(this == ModItems.empty_dark_oak_iron_musket) gun = ModItems.dark_oak_iron_musket; else if(this == ModItems.empty_dark_oak_gold_musket) gun = ModItems.dark_oak_gold_musket; else if(this == ModItems.empty_dark_oak_silver_musket) gun = ModItems.dark_oak_silver_musket; else if(this == ModItems.empty_rapier_gun) gun = ModItems.rapier_gun; else if(this == ModItems.empty_rifle_axe) gun = ModItems.rifle_axe; ((EntityPlayer)entityIn).setCurrentItemOrArmor(0, new ItemStack(gun)); reload = false; } else stack.getTagCompound().setInteger("delay", current_delay); } }; @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean Adva) { EnumChatFormatting chat; EnumChatFormatting chat2; if(this.support.equals("material.oak")) chat = EnumChatFormatting.YELLOW; else if(this.support.equals("material.birch")) chat = EnumChatFormatting.WHITE; else chat = EnumChatFormatting.GRAY; if(this.cane.equals("material.gold")) chat2 = EnumChatFormatting.YELLOW; else if(this.cane.equals("material.silver")) chat2 = EnumChatFormatting.WHITE; else chat2 = EnumChatFormatting.GRAY; if(this != ModItems.empty_rapier_gun && this != ModItems.empty_rifle_axe) { list.add(StatCollector.translateToLocal("support.name") + ": " + chat + StatCollector.translateToLocal(support)); list.add(StatCollector.translateToLocal("material.name") + ": " + chat2 + StatCollector.translateToLocal(cane)); } } } And this in the filled gun class package com.konnor; import java.util.List; import java.util.Random; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; public class ItemGun extends ItemMod { private String support; private String cane; public ItemGun(String par1, String par2) { super(); this.support = "material." + par1; this.cane = "material." + par2; this.setMaxStackSize(1); } public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { BlockPos pos = player.getPosition(); Random rand = new Random(); if(player.inventory.hasItem(ModItems.bullet) || player.capabilities.isCreativeMode) { if(!player.capabilities.isCreativeMode) player.inventory.consumeInventoryItem(ModItems.bullet); if (!world.isRemote) { world.spawnEntityInWorld(new EntityBullet(world, player)); } world.playSound((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), "connorkpt:gun", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false); Item gun = null; if(this == ModItems.oak_iron_hand_gun) gun = ModItems.empty_oak_iron_hand_gun; else if(this == ModItems.oak_gold_hand_gun) gun = ModItems.empty_oak_gold_hand_gun; else if(this == ModItems.oak_silver_hand_gun) gun = ModItems.empty_oak_silver_hand_gun; else if(this == ModItems.birch_iron_hand_gun) gun = ModItems.empty_birch_iron_hand_gun; else if(this == ModItems.birch_gold_hand_gun) gun = ModItems.empty_birch_gold_hand_gun; else if(this == ModItems.birch_silver_hand_gun) gun = ModItems.empty_birch_silver_hand_gun; else if(this == ModItems.dark_oak_iron_hand_gun) gun = ModItems.empty_dark_oak_iron_hand_gun; else if(this == ModItems.dark_oak_gold_hand_gun) gun = ModItems.empty_dark_oak_gold_hand_gun; else if(this == ModItems.dark_oak_silver_hand_gun) gun = ModItems.empty_dark_oak_silver_hand_gun; else if(this == ModItems.oak_iron_gun) gun = ModItems.empty_oak_iron_gun; else if(this == ModItems.oak_gold_gun) gun = ModItems.empty_oak_gold_gun; else if(this == ModItems.oak_silver_gun) gun = ModItems.empty_oak_silver_gun; else if(this == ModItems.birch_iron_gun) gun = ModItems.empty_birch_iron_gun; else if(this == ModItems.birch_gold_gun) gun = ModItems.empty_birch_gold_gun; else if(this == ModItems.birch_silver_gun) gun = ModItems.empty_birch_silver_gun; else if(this == ModItems.dark_oak_iron_gun) gun = ModItems.empty_dark_oak_iron_gun; else if(this == ModItems.dark_oak_gold_gun) gun = ModItems.empty_dark_oak_gold_gun; else if(this == ModItems.dark_oak_silver_gun) gun = ModItems.empty_dark_oak_silver_gun; else if(this == ModItems.oak_iron_musket) gun = ModItems.empty_oak_iron_musket; else if(this == ModItems.oak_gold_musket) gun = ModItems.empty_oak_gold_musket; else if(this == ModItems.oak_silver_musket) gun = ModItems.empty_oak_silver_musket; else if(this == ModItems.birch_iron_musket) gun = ModItems.empty_birch_iron_musket; else if(this == ModItems.birch_gold_musket) gun = ModItems.empty_birch_gold_musket; else if(this == ModItems.birch_silver_musket) gun = ModItems.empty_birch_silver_musket; else if(this == ModItems.dark_oak_iron_musket) gun = ModItems.empty_dark_oak_iron_musket; else if(this == ModItems.dark_oak_gold_musket) gun = ModItems.empty_dark_oak_gold_musket; else if(this == ModItems.dark_oak_silver_musket) gun = ModItems.empty_dark_oak_silver_musket; else if(this == ModItems.rapier_gun) gun = ModItems.empty_rapier_gun; else if(this == ModItems.rifle_axe) gun = ModItems.empty_rifle_axe; ItemStack item = new ItemStack(gun); NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setInteger("delay", 50); item.setTagCompound(nbttagcompound); player.setCurrentItemOrArmor(0, item); } return stack; } @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean Adva) { EnumChatFormatting chat; EnumChatFormatting chat2; if(this.support.equals("material.oak")) chat = EnumChatFormatting.YELLOW; else if(this.support.equals("material.birch")) chat = EnumChatFormatting.WHITE; else chat = EnumChatFormatting.GRAY; if(this.cane.equals("material.gold")) chat2 = EnumChatFormatting.YELLOW; else if(this.cane.equals("material.silver")) chat2 = EnumChatFormatting.WHITE; else chat2 = EnumChatFormatting.GRAY; if(this != ModItems.rapier_gun && this != ModItems.rifle_axe) { list.add(StatCollector.translateToLocal("support.name") + ": " + chat + StatCollector.translateToLocal(support)); list.add(StatCollector.translateToLocal("material.name") + ": " + chat2 + StatCollector.translateToLocal(cane)); } } } But now i got 2 problems: 1. How to avoid the item flickering in hand while reloading? 2. Sometimes i need to shoot 2 times before the gun it really shot Here's how it works now, if i wait some ticks before shoot everything works fine, but if i shoot as soon as it reloads then the "2 shots problem" comes out https://www.youtube.com/watch?v=McNFEBEDjz8&feature=youtu.be -
[1.8] Giving an item to the player after a delay
JimiIT92 replied to JimiIT92's topic in Modder Support
I've tried but that way the reload mechanic always activates after the shot. What i want to do is that the player has to right click the item to reload, and so then the delay should start -
Currently i want to make a reloadable gun. So when the player right click the empty gun it should be reloaded and then he can shoot again. For this mechanic there's no problem, except that i want the recharg not to be instant. So, for instance, i want that when the player right click the empty gun to reload it after 5 seconds he have the "filled" gun, so there is a delay of 5 seconds between a shot and another How can i do that? If needs, this is the empty gun class package com.konnor; import java.util.List; import java.util.Random; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; public class ItemEmptyGun extends ItemMod { private String support; private String cane; public ItemEmptyGun(String par1, String par2) { super(); this.support = "material." + par1; this.cane = "material." + par2; this.setMaxStackSize(1); this.setCreativeTab((CreativeTabs)null); } public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { BlockPos pos = player.getPosition(); Random rand = new Random(); world.playSound((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), "connorkpt:reload", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false); Item gun = null; if(this == ModItems.empty_oak_iron_hand_gun) gun = ModItems.oak_iron_hand_gun; else if(this == ModItems.empty_oak_gold_hand_gun) gun = ModItems.oak_gold_hand_gun; else if(this == ModItems.empty_oak_silver_hand_gun) gun = ModItems.oak_silver_hand_gun; else if(this == ModItems.empty_birch_iron_hand_gun) gun = ModItems.birch_iron_hand_gun; else if(this == ModItems.empty_birch_gold_hand_gun) gun = ModItems.birch_gold_hand_gun; else if(this == ModItems.empty_birch_silver_hand_gun) gun = ModItems.birch_silver_hand_gun; else if(this == ModItems.empty_dark_oak_iron_hand_gun) gun = ModItems.dark_oak_iron_hand_gun; else if(this == ModItems.empty_dark_oak_gold_hand_gun) gun = ModItems.dark_oak_gold_hand_gun; else if(this == ModItems.empty_dark_oak_silver_hand_gun) gun = ModItems.dark_oak_silver_hand_gun; else if(this == ModItems.empty_oak_iron_gun) gun = ModItems.oak_iron_gun; else if(this == ModItems.empty_oak_gold_gun) gun = ModItems.oak_gold_gun; else if(this == ModItems.empty_oak_silver_gun) gun = ModItems.oak_silver_gun; else if(this == ModItems.empty_birch_iron_gun) gun = ModItems.birch_iron_gun; else if(this == ModItems.empty_birch_gold_gun) gun = ModItems.birch_gold_gun; else if(this == ModItems.empty_birch_silver_gun) gun = ModItems.birch_silver_gun; else if(this == ModItems.empty_dark_oak_iron_gun) gun = ModItems.dark_oak_iron_gun; else if(this == ModItems.empty_dark_oak_gold_gun) gun = ModItems.dark_oak_gold_gun; else if(this == ModItems.empty_dark_oak_silver_gun) gun = ModItems.dark_oak_silver_gun; else if(this == ModItems.empty_oak_iron_musket) gun = ModItems.oak_iron_musket; else if(this == ModItems.empty_oak_gold_musket) gun = ModItems.oak_gold_musket; else if(this == ModItems.empty_oak_silver_musket) gun = ModItems.oak_silver_musket; else if(this == ModItems.empty_birch_iron_musket) gun = ModItems.birch_iron_musket; else if(this == ModItems.empty_birch_gold_musket) gun = ModItems.birch_gold_musket; else if(this == ModItems.empty_birch_silver_musket) gun = ModItems.birch_silver_musket; else if(this == ModItems.empty_dark_oak_iron_musket) gun = ModItems.dark_oak_iron_musket; else if(this == ModItems.empty_dark_oak_gold_musket) gun = ModItems.dark_oak_gold_musket; else if(this == ModItems.empty_dark_oak_silver_musket) gun = ModItems.dark_oak_silver_musket; else if(this == ModItems.empty_rapier_gun) gun = ModItems.rapier_gun; else if(this == ModItems.empty_rifle_axe) gun = ModItems.rifle_axe; if(player.inventory.hasItem(ModItems.bullet) || player.capabilities.isCreativeMode) { player.setCurrentItemOrArmor(0, new ItemStack(gun)); } return stack; } @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean Adva) { EnumChatFormatting chat; EnumChatFormatting chat2; if(this.support.equals("material.oak")) chat = EnumChatFormatting.YELLOW; else if(this.support.equals("material.birch")) chat = EnumChatFormatting.WHITE; else chat = EnumChatFormatting.GRAY; if(this.cane.equals("material.gold")) chat2 = EnumChatFormatting.YELLOW; else if(this.cane.equals("material.silver")) chat2 = EnumChatFormatting.WHITE; else chat2 = EnumChatFormatting.GRAY; if(this != ModItems.empty_rapier_gun && this != ModItems.empty_rifle_axe) { list.add(StatCollector.translateToLocal("support.name") + ": " + chat + StatCollector.translateToLocal(support)); list.add(StatCollector.translateToLocal("material.name") + ": " + chat2 + StatCollector.translateToLocal(cane)); } } }
-
Thanks Doing that has fixed the problem
-
I've tried but if do this package hl.core; import hl.proxy.CommonProxy; import net.minecraft.client.Minecraft; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.EntityRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; @Mod(modid = HL.MODID, version = HL.VERSION) public class HL { @SidedProxy(clientSide = "hl.proxy.ClientProxy", serverSide = "hl.proxy.CommonProxy") public static CommonProxy proxy; public static final String MODID = "hl"; public static final String VERSION = "1.0"; @Instance("hl") public static HL instance; @EventHandler public void preInit(FMLPreInitializationEvent event) { HLTabs.createTabs(); HLMaterials.addMaterials(); HLBlocks.addBlocks(); HLStairs.addBlocks(); HLSlabs.addBlocks(); HLFlowers.addBlocks(); HLDoors.addBlocks(); HLItems.addItems(); HLTools.addTools(); HLDyes.addItems(); HLEntities.addEntities(); HLSummons.addSummons(); HLColoredBlocks.addBlocks(); HLColoredSlabs.createSlabs(); HLColoredStairs.createStairs(); HLLetters.addLetters(); HLLettersItems.addLetters(); HLWorld.addComponents(); HLVillage.createVillager(); HLBlocks.registerBlocks(Minecraft.getMinecraft().getRenderItem()); HLStairs.registerBlocks(Minecraft.getMinecraft().getRenderItem()); HLSlabs.registerBlocks(Minecraft.getMinecraft().getRenderItem()); HLFlowers.registerBlocks(Minecraft.getMinecraft().getRenderItem()); HLDoors.registerBlocks(Minecraft.getMinecraft().getRenderItem()); HLItems.registerItems(Minecraft.getMinecraft().getRenderItem()); HLTools.registerTools(Minecraft.getMinecraft().getRenderItem()); HLDyes.registerItems(Minecraft.getMinecraft().getRenderItem()); HLSummons.registerSummon(Minecraft.getMinecraft().getRenderItem()); HLColoredBlocks.registerBlocks(Minecraft.getMinecraft().getRenderItem()); HLColoredSlabs.registerSlabs(Minecraft.getMinecraft().getRenderItem()); HLColoredStairs.registerStairs(Minecraft.getMinecraft().getRenderItem()); HLLetters.registerLetters(Minecraft.getMinecraft().getRenderItem()); HLLettersItems.registerLetters(Minecraft.getMinecraft().getRenderItem()); HLEntities.registerEntities(EntityRegistry.findGlobalUniqueEntityId()); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRenderThings(); HLCraftings.addCraftings(); HLWorld.registerComponents(); GameRegistry.registerFuelHandler(new FuelHandler()); HLVillage.addVillage(); } } i get this [21:57:55] [server thread/ERROR] [FML]: Fatal errors were detected during the transition from PREINITIALIZATION to INITIALIZATION. Loading cannot continue [21:57:55] [server thread/ERROR] [FML]: States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCH mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCH FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.4.1577.jar) UCH Forge{11.14.4.1577} [Minecraft Forge] (forgeSrc-1.8-11.14.4.1577.jar) UCE hl{1.0} [Half-Life 3 Mod] (bin) [21:57:55] [server thread/ERROR] [FML]: The following problems were captured during this phase [21:57:55] [server thread/ERROR] [FML]: Caught exception from hl java.lang.NoClassDefFoundError: net/minecraft/client/Minecraft at hl.core.HL.preInit(HL.java:51) ~[bin/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:553) ~[forgeSrc-1.8-11.14.4.1577.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] 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 net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[forgeSrc-1.8-11.14.4.1577.jar:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[forgeSrc-1.8-11.14.4.1577.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] 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 net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:?] at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:550) [Loader.class:?] at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:88) [FMLServerHandler.class:?] at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:355) [FMLCommonHandler.class:?] at net.minecraft.server.dedicated.DedicatedServer.startServer(DedicatedServer.java:120) [DedicatedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:500) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_65] Caused by: java.lang.ClassNotFoundException: net.minecraft.client.Minecraft at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_65] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_65] ... 33 more Caused by: net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerException: Exception in class transformer net.minecraftforge.fml.common.asm.transformers.SideTransformer@4fc5e095 from coremod FMLCorePlugin at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:234) ~[forgeSrc-1.8-11.14.4.1577.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_65] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_65] ... 33 more Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/Minecraft for invalid side SERVER at net.minecraftforge.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:49) ~[forgeSrc-1.8-11.14.4.1577.jar:?] at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:230) ~[forgeSrc-1.8-11.14.4.1577.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_65] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_65] ... 33 more [21:57:55] [server thread/ERROR]: Encountered an unexpected exception net.minecraftforge.fml.common.LoaderException: java.lang.NoClassDefFoundError: net/minecraft/client/Minecraft at net.minecraftforge.fml.common.LoadController.transition(LoadController.java:163) ~[LoadController.class:?] at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:553) ~[Loader.class:?] at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:88) ~[FMLServerHandler.class:?] at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:355) ~[FMLCommonHandler.class:?] at net.minecraft.server.dedicated.DedicatedServer.startServer(DedicatedServer.java:120) ~[DedicatedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:500) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_65] Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/Minecraft at hl.core.HL.preInit(HL.java:51) ~[bin/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:553) ~[forgeSrc-1.8-11.14.4.1577.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] 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 net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[LoadController.class:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[LoadController.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] 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 net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) ~[LoadController.class:?] at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:550) ~[Loader.class:?] ... 5 more Caused by: java.lang.ClassNotFoundException: net.minecraft.client.Minecraft at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_65] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_65] at hl.core.HL.preInit(HL.java:51) ~[bin/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:553) ~[forgeSrc-1.8-11.14.4.1577.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] 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 net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[LoadController.class:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[LoadController.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] 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 net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) ~[LoadController.class:?] at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:550) ~[Loader.class:?] ... 5 more Caused by: net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerException: Exception in class transformer net.minecraftforge.fml.common.asm.transformers.SideTransformer@4fc5e095 from coremod FMLCorePlugin at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:234) ~[forgeSrc-1.8-11.14.4.1577.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_65] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_65] at hl.core.HL.preInit(HL.java:51) ~[bin/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:553) ~[forgeSrc-1.8-11.14.4.1577.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] 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 net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[LoadController.class:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[LoadController.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] 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 net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) ~[LoadController.class:?] at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:550) ~[Loader.class:?] ... 5 more Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/Minecraft for invalid side SERVER at net.minecraftforge.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:49) ~[forgeSrc-1.8-11.14.4.1577.jar:?] at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:230) ~[forgeSrc-1.8-11.14.4.1577.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.12.jar:?] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_65] at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_65] at hl.core.HL.preInit(HL.java:51) ~[bin/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:553) ~[forgeSrc-1.8-11.14.4.1577.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] 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 net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[LoadController.class:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[LoadController.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65] 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 net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) ~[LoadController.class:?] at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:550) ~[Loader.class:?] ... 5 more
-
As by title, the mod is working client side but when on server it looks like is not loaded Only the creative tabs are, with icons correctly loaded, but no blocks/items at all So in the main mod file i have this package hl.core; import hl.proxy.CommonProxy; import net.minecraft.client.Minecraft; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.EntityRegistry; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; @Mod(modid = HL.MODID, version = HL.VERSION) public class HL { @SidedProxy(clientSide = "hl.proxy.ClientProxy", serverSide = "hl.proxy.CommonProxy") public static CommonProxy proxy; public static final String MODID = "hl"; public static final String VERSION = "1.0"; @Instance("hl") public static HL instance; @EventHandler public void preInit(FMLPreInitializationEvent event) { HLTabs.createTabs(); HLMaterials.addMaterials(); HLBlocks.addBlocks(); HLStairs.addBlocks(); HLSlabs.addBlocks(); HLFlowers.addBlocks(); HLDoors.addBlocks(); HLItems.addItems(); HLTools.addTools(); HLDyes.addItems(); HLEntities.addEntities(); HLSummons.addSummons(); HLColoredBlocks.addBlocks(); HLColoredSlabs.createSlabs(); HLColoredStairs.createStairs(); HLLetters.addLetters(); HLLettersItems.addLetters(); HLWorld.addComponents(); HLVillage.createVillager(); } @EventHandler public void init(FMLInitializationEvent event) { proxy.registerRenderThings(); HLEntities.registerEntities(EntityRegistry.findGlobalUniqueEntityId()); HLWorld.registerComponents(); GameRegistry.registerFuelHandler(new FuelHandler()); HLVillage.addVillage(); } } And then in the ClientProxy i got this package hl.proxy; import hl.core.HLBlocks; import hl.core.HLColoredBlocks; import hl.core.HLColoredSlabs; import hl.core.HLColoredStairs; import hl.core.HLCraftings; import hl.core.HLDoors; import hl.core.HLDyes; import hl.core.HLFlowers; import hl.core.HLItems; import hl.core.HLLetters; import hl.core.HLLettersItems; import hl.core.HLSlabs; import hl.core.HLStairs; import hl.core.HLSummons; import hl.core.HLTools; import hl.core.ModLivingDropEvent; import hl.entities.EntityBee; import hl.entities.EntityFenrir; import hl.entities.EntitySandworm; import hl.entities.renderer.RenderBee; import hl.entities.renderer.RenderFenrir; import hl.entities.renderer.RenderSandworm; import hl.entities.renderer.RenderVase; import hl.models.ModelBee; import hl.models.ModelFenrir; import hl.models.ModelSandworm; import hl.tileentity.TileEntityVase; import hl.world.placeForgetMeNots; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.RenderingRegistry; public class ClientProxy extends CommonProxy { public void registerRenderThings(){ HLBlocks.registerBlocks(Minecraft.getMinecraft().getRenderItem()); HLStairs.registerBlocks(Minecraft.getMinecraft().getRenderItem()); HLSlabs.registerBlocks(Minecraft.getMinecraft().getRenderItem()); HLFlowers.registerBlocks(Minecraft.getMinecraft().getRenderItem()); HLDoors.registerBlocks(Minecraft.getMinecraft().getRenderItem()); HLItems.registerItems(Minecraft.getMinecraft().getRenderItem()); HLTools.registerTools(Minecraft.getMinecraft().getRenderItem()); HLDyes.registerItems(Minecraft.getMinecraft().getRenderItem()); HLSummons.registerSummon(Minecraft.getMinecraft().getRenderItem()); HLColoredBlocks.registerBlocks(Minecraft.getMinecraft().getRenderItem()); HLColoredSlabs.registerSlabs(Minecraft.getMinecraft().getRenderItem()); HLColoredStairs.registerStairs(Minecraft.getMinecraft().getRenderItem()); HLLetters.registerLetters(Minecraft.getMinecraft().getRenderItem()); HLLettersItems.registerLetters(Minecraft.getMinecraft().getRenderItem()); HLCraftings.addCraftings(); MinecraftForge.EVENT_BUS.register(new FOVManipulator()); RenderingRegistry.registerEntityRenderingHandler(EntityFenrir.class, new RenderFenrir(Minecraft.getMinecraft().getRenderManager(), new ModelFenrir(), 0.3F, 3)); RenderingRegistry.registerEntityRenderingHandler(EntitySandworm.class, new RenderSandworm(Minecraft.getMinecraft().getRenderManager(), new ModelSandworm(), 0.3F, 3)); RenderingRegistry.registerEntityRenderingHandler(EntityBee.class, new RenderBee(Minecraft.getMinecraft().getRenderManager(), new ModelBee(), 0.3F, 0.5F)); MinecraftForge.EVENT_BUS.register(new ModLivingDropEvent()); MinecraftForge.EVENT_BUS.register(new placeForgetMeNots()); TileEntitySpecialRenderer renderVase = new RenderVase(); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVase.class, renderVase); } public int addArmor(String armorname) { return 0; } } Now, for instance, the method called from here from HLItems is this public static void registerItems(RenderItem renderItem) { Field[] fields = HLItems.class.getFields(); for(Field element:fields) try { if(element.get(HLItems.class) != null) { addItem(renderItem, (Item)element.get(HLItems.class), element.getName()); } } catch (IllegalArgumentException e) { System.err.println("Illegal argument passed as Block to register"); e.printStackTrace(); } catch (IllegalAccessException e) { System.err.println("Illegal access while registering a Block"); e.printStackTrace(); } ChestGenHooks.getInfo(ChestGenHooks.VILLAGE_BLACKSMITH).addItem(new WeightedRandomChestContent(moonshine, 0, 1, 4, ); ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(moonshine, 0, 1, 4, ); ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR).addItem(new WeightedRandomChestContent(moonshine, 0, 1, 4, ); ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_CORRIDOR).addItem(new WeightedRandomChestContent(moonshine, 0, 1, 4, ); ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_CROSSING).addItem(new WeightedRandomChestContent(moonshine, 0, 1, 4, ); ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_LIBRARY).addItem(new WeightedRandomChestContent(moonshine, 0, 1, 4, ); } public static void addItem(RenderItem renderItem, Item item, String name) { item.setUnlocalizedName(name); GameRegistry.registerItem(item, name); renderItem.getItemModelMesher().register(item, 0, new ModelResourceLocation(HL.MODID + ":" + name, "inventory")); } As i said, client side there are no problems but server side it seems that nothing is loaded
-
Yes, the order i already know, infact in my mod the tabs and blocks are the first two things registered
-
I understand, maybe it has an impact on mod performance in general?
-
i was trying doing that to avoid using metadata and sub-items But i'll do it. So every time i click i should change the item in hand of player, right? Also why the item registration should be done in the preInit? I always do that in the init and it never gives me a problem
-
The for cycle only decrease the first stack of bullets that encount, i've already tested it The player.posX/Y/Z thing is used when the sound should be played. The items are registered as usual, in the init method of the main mod file, using GameRegistry.registerItem(item, name);
-
So far i was trying to make a gun that after each shot it has to be reload. So the scenario is: shoot-reload-shoot-reload an so on. However adding a reload state makes the gun do weird things wich you can see here https://www.youtube.com/watch?v=dU6lfGEXyx0&feature=youtu.be This is the item class that i use for each gun in the mod. ItemMod is just a class that extends Item and do nothing special (just setting the creative tab and unlocalized name) package com.konnor; import java.util.List; import java.util.Random; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; import net.minecraft.world.World; public class ItemGun extends ItemMod { private String support; private String cane; private boolean reload = false; public ItemGun(String par1, String par2) { super(); this.support = "material." + par1; this.cane = "material." + par2; this.setMaxStackSize(1); } public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { BlockPos pos = player.getPosition(); Random rand = new Random(); if(reload) { world.playSound((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), "connorkpt:reload", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false); reload = false; } else if((player.inventory.hasItem(ModItems.bullet) || player.capabilities.isCreativeMode)) { IInventory inv = player.inventory; for(int i=0; i < inv.getSizeInventory(); i++) { if(inv.getStackInSlot(i) != null) { ItemStack j = inv.getStackInSlot(i); if(j.getItem() != null && j.getItem() == ModItems.bullet) { inv.decrStackSize(i, 1); i = inv.getSizeInventory(); } } } if (!world.isRemote) { world.spawnEntityInWorld(new EntityBullet(world, player)); } world.playSound((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), "connorkpt:gun", 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false); reload = true; } return stack; } @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean Adva) { EnumChatFormatting chat; EnumChatFormatting chat2; if(this.support.equals("material.oak")) chat = EnumChatFormatting.YELLOW; else if(this.support.equals("material.birch")) chat = EnumChatFormatting.WHITE; else chat = EnumChatFormatting.GRAY; if(this.cane.equals("material.gold")) chat2 = EnumChatFormatting.YELLOW; else if(this.cane.equals("material.silver")) chat2 = EnumChatFormatting.WHITE; else chat2 = EnumChatFormatting.GRAY; if(this != ModItems.rapier_gun && this != ModItems.rifle_axe) { list.add(StatCollector.translateToLocal("support.name") + ": " + chat + StatCollector.translateToLocal(support)); list.add(StatCollector.translateToLocal("material.name") + ": " + chat2 + StatCollector.translateToLocal(cane)); } } }
-
[SOLVED] [1.8] Crafting chests with items inside
JimiIT92 replied to JimiIT92's topic in Modder Support
Mmm, thinking again i was wrong everything In fact right now i have a simple block with a tile entity that stores one single item stack and when this block is break then the stack stored in the tile entity comes out EDIT: if any is interested, this is the code i use Block class package mw.blocks; import mw.core.MWTabs; import mw.entities.tileentity.TileEntityGift; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryHelper; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; public class BlockGift extends BlockContainer { public BlockGift() { super(Material.cloth); this.setCreativeTab(MWTabs.tabDecorations); this.setUnlocalizedName("gift"); GameRegistry.registerBlock(this, "gift"); } @Override public boolean hasTileEntity() { return true; } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityGift(); } public int getRenderType() { return 3; } public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof IInventory) { InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileentity); worldIn.updateComparatorOutputLevel(pos, this); } super.breakBlock(worldIn, pos, state); } } TileEntity class package mw.entities.tileentity; import java.util.Iterator; import java.util.List; import mw.blocks.BlockGift; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryLargeChest; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.server.gui.IUpdatePlayerListBox; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityLockable; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class TileEntityGift extends TileEntityLockable { private ItemStack content; @Override public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { return null; } @Override public String getGuiID() { return null; } @Override public String getName() { return null; } @Override public boolean hasCustomName() { return false; } @Override public int getSizeInventory() { return 1; } @Override public ItemStack getStackInSlot(int index) { return this.content; } @Override public ItemStack decrStackSize(int index, int count) { return null; } @Override public ItemStack getStackInSlotOnClosing(int index) { return null; } @Override public void setInventorySlotContents(int index, ItemStack stack) { } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return false; } @Override public void openInventory(EntityPlayer player) { } @Override public void closeInventory(EntityPlayer player) { } @Override public boolean isItemValidForSlot(int index, ItemStack stack) { return false; } @Override public int getField(int id) { return 0; } @Override public void setField(int id, int value) { } @Override public int getFieldCount() { return 0; } @Override public void clear() { } public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList nbttaglist = compound.getTagList("Items", 10); this.content = null; for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); int j = nbttagcompound1.getByte("Gift") & 255; if (j == 0) { this.content = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } } public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); NBTTagList nbttaglist = new NBTTagList(); NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Gift", (byte)0); if(this.content != null) this.content.writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); compound.setTag("Items", nbttaglist); } } -
[SOLVED] [1.8] Crafting chests with items inside
JimiIT92 replied to JimiIT92's topic in Modder Support
In fact i do not want the player to open it. The only way to get it's content is to broken the chest. But for now i have commented the "onBlockActivated" function because it is inherited from the superclass BlockChest -
[SOLVED] [1.8] Crafting chests with items inside
JimiIT92 replied to JimiIT92's topic in Modder Support
doing some debug what the game does is -apply normal nbt tags -copy stack nbt tags to the standard one -apply the tile entity to the block going step-by-step appearently there is no problem since the stack nbt tags are readed and applied correctly to the tile entity, the chest content is updated as well, so i really don't understand why if the chest content is correctly modified the chest is empty (and it only happens with the custom chest since with a vanilla chest it has no problem) -
[SOLVED] [1.8] Crafting chests with items inside
JimiIT92 replied to JimiIT92's topic in Modder Support
I placed a breakpoint in the read and write to nbt functions in the tile entity class and they are called. Also the block is correctly linked to the tile entity (infact there are no problem if it works like a normal chest). Anyway if needs this is also the block class package mw.blocks; import java.util.Iterator; import java.util.List; import java.util.Random; import mw.core.utils.Utils; import mw.entities.tileentity.TileEntityGift; import net.minecraft.block.Block; import net.minecraft.block.BlockChest; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.passive.EntityOcelot; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.InventoryLargeChest; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumFacing; import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; import net.minecraft.world.IBlockAccess; import net.minecraft.world.ILockableContainer; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; public class BlockGift extends BlockChest { public BlockGift() { super(0); this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); Utils.setChestBlockInfo(this, "gift", 0.2F, Block.soundTypeCloth); GameRegistry.registerBlock(this, "gift"); } /*public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { return true; }*/ public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { EnumFacing enumfacing = EnumFacing.getHorizontal(MathHelper.floor_double((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3).getOpposite(); state = state.withProperty(FACING, enumfacing); BlockPos blockpos1 = pos.north(); BlockPos blockpos2 = pos.south(); BlockPos blockpos3 = pos.west(); BlockPos blockpos4 = pos.east(); boolean flag = this == worldIn.getBlockState(blockpos1).getBlock(); boolean flag1 = this == worldIn.getBlockState(blockpos2).getBlock(); boolean flag2 = this == worldIn.getBlockState(blockpos3).getBlock(); boolean flag3 = this == worldIn.getBlockState(blockpos4).getBlock(); if (!flag && !flag1 && !flag2 && !flag3) { worldIn.setBlockState(pos, state, 3); } else if (enumfacing.getAxis() == EnumFacing.Axis.X && (flag || flag1)) { if (flag) { worldIn.setBlockState(blockpos1, state, 3); } else { worldIn.setBlockState(blockpos2, state, 3); } worldIn.setBlockState(pos, state, 3); } else if (enumfacing.getAxis() == EnumFacing.Axis.Z && (flag2 || flag3)) { if (flag2) { worldIn.setBlockState(blockpos3, state, 3); } else { worldIn.setBlockState(blockpos4, state, 3); } worldIn.setBlockState(pos, state, 3); } TileEntity tileentity = worldIn.getTileEntity(pos); if (stack.hasDisplayName()) { if (tileentity instanceof TileEntityGift) { ((TileEntityGift)tileentity).setCustomName(stack.getDisplayName()); } } } @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return null; } public ILockableContainer getLockableContainer(World worldIn, BlockPos pos) { TileEntity tileentity = worldIn.getTileEntity(pos); if (!(tileentity instanceof TileEntityGift)) { return null; } else { Object object = (TileEntityGift)tileentity; if (this.isBlocked(worldIn, pos)) { return null; } else { Iterator iterator = EnumFacing.Plane.HORIZONTAL.iterator(); while (iterator.hasNext()) { EnumFacing enumfacing = (EnumFacing)iterator.next(); BlockPos blockpos1 = pos.offset(enumfacing); Block block = worldIn.getBlockState(blockpos1).getBlock(); if (block == this) { if (this.isBlocked(worldIn, blockpos1)) { return null; } TileEntity tileentity1 = worldIn.getTileEntity(blockpos1); if (tileentity1 instanceof TileEntityGift) { if (enumfacing != EnumFacing.WEST && enumfacing != EnumFacing.NORTH) { object = new InventoryLargeChest("container.gift", (ILockableContainer)object, (TileEntityGift)tileentity1); } else { object = new InventoryLargeChest("container.gift", (TileEntityGift)tileentity1, (ILockableContainer)object); } } } } return (ILockableContainer)object; } } } /** * Returns a new instance of a block's tile entity class. Called on placing the block. */ public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityGift(); } private boolean isBlocked(World worldIn, BlockPos pos) { return this.isBelowSolidBlock(worldIn, pos) || this.isOcelotSittingOnChest(worldIn, pos); } private boolean isBelowSolidBlock(World worldIn, BlockPos pos) { return worldIn.isSideSolid(pos.up(), EnumFacing.DOWN, false); } private boolean isOcelotSittingOnChest(World worldIn, BlockPos pos) { Iterator iterator = worldIn.getEntitiesWithinAABB(EntityOcelot.class, new AxisAlignedBB((double)pos.getX(), (double)(pos.getY() + 1), (double)pos.getZ(), (double)(pos.getX() + 1), (double)(pos.getY() + 2), (double)(pos.getZ() + 1))).iterator(); EntityOcelot entityocelot; do { if (!iterator.hasNext()) { return false; } Entity entity = (Entity)iterator.next(); entityocelot = (EntityOcelot)entity; } while (!entityocelot.isSitting()); return true; } /*@Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean Adva){ list.add(EnumChatFormatting.YELLOW + StatCollector.translateToLocal( "tooltip.open_chests") + " " + chest + " " + StatCollector.translateToLocal( "tooltip.chests")); } */ } -
[SOLVED] [1.8] Crafting chests with items inside
JimiIT92 replied to JimiIT92's topic in Modder Support
Any idea? Doing some debug i see that the nbt is correctly assigned -
[SOLVED] [1.8] Crafting chests with items inside
JimiIT92 replied to JimiIT92's topic in Modder Support
Strange thing: the code works for normal chest but not for my custom chest This is the code used for the craftings package mw.craftings; import java.util.List; import com.google.common.collect.ImmutableList; import mw.core.MWBlocks; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentFireAspect; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.RecipesBanners; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntityBanner; import net.minecraft.world.World; public class CraftingGifts { public CraftingGifts(CraftingManager manager) { manager.addRecipe(new CraftingGifts.RecipeAddItem(null)); } public static class RecipeAddItem implements IRecipe { private RecipeAddItem() {} /** * Used to check if a recipe matches current crafting inventory */ public boolean matches(InventoryCrafting craftingInv, World worldIn) { boolean flag = false; int num = 0; for (int i = 0; i < craftingInv.getSizeInventory(); ++i) { ItemStack itemstack = craftingInv.getStackInSlot(i); if (itemstack != null && itemstack.getItem() == Item.getItemFromBlock(Blocks.wool) && i != 4) { if (num == 7) { flag = true; num = 0; break; } num++; } } return flag; } /** * Returns an Item that is the result of this recipe */ public ItemStack getCraftingResult(InventoryCrafting crafting) { ItemStack itemstack = null; ItemStack chestitem = null; int num = 0; for (int i = 0; i < crafting.getSizeInventory(); ++i) { ItemStack itemstack1 = crafting.getStackInSlot(i); if (itemstack1 != null && itemstack1.getItem() == Item.getItemFromBlock(Blocks.wool) && i != 4) { if (num == 7) { itemstack = new ItemStack(MWBlocks.gift); itemstack.stackSize = 1; num = 0; chestitem = crafting.getStackInSlot(4); break; } num++; } } if(chestitem != null) { NBTTagCompound nbttagcompound1 = itemstack.getSubCompound("BlockEntityTag", true); NBTTagList nbttaglist; nbttaglist = new NBTTagList(); nbttagcompound1.setTag("Items", nbttaglist); NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setByte("Slot", (byte)0); chestitem.writeToNBT(nbttagcompound); nbttaglist.appendTag(nbttagcompound); } return itemstack; } /** * Returns the size of the recipe area */ public int getRecipeSize() { return 10; } public ItemStack getRecipeOutput() { return null; } public ItemStack[] getRemainingItems(InventoryCrafting crafting) { ItemStack[] aitemstack = new ItemStack[crafting.getSizeInventory()]; for (int i = 0; i < aitemstack.length; ++i) { ItemStack itemstack = crafting.getStackInSlot(i); aitemstack[i] = net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack); } crafting.setInventorySlotContents(4, null); return aitemstack; } RecipeAddItem(Object par1) { this(); } } } and if instead of MWBlocks.gift i place Blocks.chest everything works fine, the stack in the middle slot of the crafting table are correctly placed in the chest. So maybe it could be a problem with the tile entity? This is its class package mw.entities.tileentity; import java.util.Iterator; import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.BlockChest; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryLargeChest; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.server.gui.IUpdatePlayerListBox; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityLockable; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class TileEntityGift extends TileEntityLockable implements IUpdatePlayerListBox, IInventory { private ItemStack[] chestContents = new ItemStack[9]; /** Determines if the check for adjacent chests has taken place. */ public boolean adjacentChestChecked; /** Contains the chest tile located adjacent to this one (if any) */ public TileEntityGift adjacentChestZNeg; /** Contains the chest tile located adjacent to this one (if any) */ public TileEntityGift adjacentChestXPos; /** Contains the chest tile located adjacent to this one (if any) */ public TileEntityGift adjacentChestXNeg; /** Contains the chest tile located adjacent to this one (if any) */ public TileEntityGift adjacentChestZPos; /** The current angle of the lid (between 0 and 1) */ public float lidAngle; /** The angle of the lid last tick */ public float prevLidAngle; /** The number of players currently using this chest */ public int numPlayersUsing; /** Server sync counter (once per 20 ticks) */ private int ticksSinceSync; private int cachedChestType; private String customName; public TileEntityGift() { this.cachedChestType = -1; } @SideOnly(Side.CLIENT) public TileEntityGift(int chestType) { this.cachedChestType = chestType; } /** * Returns the number of slots in the inventory. */ public int getSizeInventory() { return 9; } /** * Returns the stack in slot i */ public ItemStack getStackInSlot(int index) { return this.chestContents[index]; } /** * Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a * new stack. */ public ItemStack decrStackSize(int index, int count) { if (this.chestContents[index] != null) { ItemStack itemstack; if (this.chestContents[index].stackSize <= count) { itemstack = this.chestContents[index]; this.chestContents[index] = null; this.markDirty(); return itemstack; } else { itemstack = this.chestContents[index].splitStack(count); if (this.chestContents[index].stackSize == 0) { this.chestContents[index] = null; } this.markDirty(); return itemstack; } } else { return null; } } /** * When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem - * like when you close a workbench GUI. */ public ItemStack getStackInSlotOnClosing(int index) { if (this.chestContents[index] != null) { ItemStack itemstack = this.chestContents[index]; this.chestContents[index] = null; return itemstack; } else { return null; } } /** * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). */ public void setInventorySlotContents(int index, ItemStack stack) { this.chestContents[index] = stack; if (stack != null && stack.stackSize > this.getInventoryStackLimit()) { stack.stackSize = this.getInventoryStackLimit(); } this.markDirty(); } /** * Gets the name of this command sender (usually username, but possibly "Rcon") */ public String getName() { return this.hasCustomName() ? this.customName : "container.gift"; } /** * Returns true if this thing is named */ public boolean hasCustomName() { return this.customName != null && this.customName.length() > 0; } public void setCustomName(String name) { this.customName = name; } public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList nbttaglist = compound.getTagList("Items", 10); this.chestContents = new ItemStack[this.getSizeInventory()]; if (compound.hasKey("CustomName", ) { this.customName = compound.getString("CustomName"); } for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); int j = nbttagcompound1.getByte("Slot") & 255; if (j >= 0 && j < this.chestContents.length) { this.chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } } public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.chestContents.length; ++i) { if (this.chestContents[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); this.chestContents[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } compound.setTag("Items", nbttaglist); if (this.hasCustomName()) { compound.setString("CustomName", this.customName); } } /** * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't * this more of a set than a get?* */ public int getInventoryStackLimit() { return 64; } /** * Do not make give this method the name canInteractWith because it clashes with Container */ public boolean isUseableByPlayer(EntityPlayer player) { return this.worldObj.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D; } public void updateContainingBlockInfo() { super.updateContainingBlockInfo(); this.adjacentChestChecked = false; } private void func_174910_a(TileEntityGift entity, EnumFacing side) { if (entity.isInvalid()) { this.adjacentChestChecked = false; } else if (this.adjacentChestChecked) { switch (TileEntityGift.SwitchEnumFacing.field_177366_a[side.ordinal()]) { case 1: if (this.adjacentChestZNeg != entity) { this.adjacentChestChecked = false; } break; case 2: if (this.adjacentChestZPos != entity) { this.adjacentChestChecked = false; } break; case 3: if (this.adjacentChestXPos != entity) { this.adjacentChestChecked = false; } break; case 4: if (this.adjacentChestXNeg != entity) { this.adjacentChestChecked = false; } } } } /** * Performs the check for adjacent chests to determine if this chest is double or not. */ public void checkForAdjacentChests() { if (!this.adjacentChestChecked) { this.adjacentChestChecked = true; this.adjacentChestXNeg = this.func_174911_a(EnumFacing.WEST); this.adjacentChestXPos = this.func_174911_a(EnumFacing.EAST); this.adjacentChestZNeg = this.func_174911_a(EnumFacing.NORTH); this.adjacentChestZPos = this.func_174911_a(EnumFacing.SOUTH); } } protected TileEntityGift func_174911_a(EnumFacing side) { BlockPos blockpos = this.pos.offset(side); if (this.func_174912_b(blockpos)) { TileEntity tileentity = this.worldObj.getTileEntity(blockpos); if (tileentity instanceof TileEntityGift) { TileEntityGift tileentitychest = (TileEntityGift)tileentity; tileentitychest.func_174910_a(this, side.getOpposite()); return tileentitychest; } } return null; } private boolean func_174912_b(BlockPos pos) { if (this.worldObj == null) { return false; } else { Block block = this.worldObj.getBlockState(pos).getBlock(); return block instanceof BlockChest && ((BlockChest)block).chestType == this.getChestType(); } } /** * Updates the JList with a new model. */ public void update() { this.checkForAdjacentChests(); int i = this.pos.getX(); int j = this.pos.getY(); int k = this.pos.getZ(); ++this.ticksSinceSync; float f; if (!this.worldObj.isRemote && this.numPlayersUsing != 0 && (this.ticksSinceSync + i + j + k) % 200 == 0) { this.numPlayersUsing = 0; f = 5.0F; List list = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB((double)((float)i - f), (double)((float)j - f), (double)((float)k - f), (double)((float)(i + 1) + f), (double)((float)(j + 1) + f), (double)((float)(k + 1) + f))); Iterator iterator = list.iterator(); while (iterator.hasNext()) { EntityPlayer entityplayer = (EntityPlayer)iterator.next(); if (entityplayer.openContainer instanceof ContainerChest) { IInventory iinventory = ((ContainerChest)entityplayer.openContainer).getLowerChestInventory(); if (iinventory == this || iinventory instanceof InventoryLargeChest && ((InventoryLargeChest)iinventory).isPartOfLargeChest(this)) { ++this.numPlayersUsing; } } } } this.prevLidAngle = this.lidAngle; f = 0.1F; double d2; if (this.numPlayersUsing > 0 && this.lidAngle == 0.0F && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) { double d1 = (double)i + 0.5D; d2 = (double)k + 0.5D; if (this.adjacentChestZPos != null) { d2 += 0.5D; } if (this.adjacentChestXPos != null) { d1 += 0.5D; } this.worldObj.playSoundEffect(d1, (double)j + 0.5D, d2, "random.chestopen", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); } if (this.numPlayersUsing == 0 && this.lidAngle > 0.0F || this.numPlayersUsing > 0 && this.lidAngle < 1.0F) { float f1 = this.lidAngle; if (this.numPlayersUsing > 0) { this.lidAngle += f; } else { this.lidAngle -= f; } if (this.lidAngle > 1.0F) { this.lidAngle = 1.0F; } float f2 = 0.5F; if (this.lidAngle < f2 && f1 >= f2 && this.adjacentChestZNeg == null && this.adjacentChestXNeg == null) { d2 = (double)i + 0.5D; double d0 = (double)k + 0.5D; if (this.adjacentChestZPos != null) { d0 += 0.5D; } if (this.adjacentChestXPos != null) { d2 += 0.5D; } this.worldObj.playSoundEffect(d2, (double)j + 0.5D, d0, "random.chestclosed", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); } if (this.lidAngle < 0.0F) { this.lidAngle = 0.0F; } } } public boolean receiveClientEvent(int id, int type) { if (id == 1) { this.numPlayersUsing = type; return true; } else { return super.receiveClientEvent(id, type); } } public void openInventory(EntityPlayer player) { if (!player.isSpectator()) { if (this.numPlayersUsing < 0) { this.numPlayersUsing = 0; } ++this.numPlayersUsing; this.worldObj.addBlockEvent(this.pos, this.getBlockType(), 1, this.numPlayersUsing); this.worldObj.notifyNeighborsOfStateChange(this.pos, this.getBlockType()); this.worldObj.notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType()); } } public void closeInventory(EntityPlayer player) { if (!player.isSpectator() && this.getBlockType() instanceof BlockChest) { --this.numPlayersUsing; this.worldObj.addBlockEvent(this.pos, this.getBlockType(), 1, this.numPlayersUsing); this.worldObj.notifyNeighborsOfStateChange(this.pos, this.getBlockType()); this.worldObj.notifyNeighborsOfStateChange(this.pos.down(), this.getBlockType()); } } /** * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. */ public boolean isItemValidForSlot(int index, ItemStack stack) { return true; } /** * invalidates a tile entity */ public void invalidate() { super.invalidate(); this.updateContainingBlockInfo(); this.checkForAdjacentChests(); } public int getChestType() { if (this.cachedChestType == -1) { if (this.worldObj == null || !(this.getBlockType() instanceof BlockChest)) { return 0; } this.cachedChestType = ((BlockChest)this.getBlockType()).chestType; } return this.cachedChestType; } public String getGuiID() { return "minecraft:chest"; } public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { return new ContainerChest(playerInventory, this, playerIn); } 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 < this.chestContents.length; ++i) { this.chestContents[i] = null; } } static final class SwitchEnumFacing { static final int[] field_177366_a = new int[EnumFacing.values().length]; static { try { field_177366_a[EnumFacing.NORTH.ordinal()] = 1; } catch (NoSuchFieldError var4) { ; } try { field_177366_a[EnumFacing.SOUTH.ordinal()] = 2; } catch (NoSuchFieldError var3) { ; } try { field_177366_a[EnumFacing.EAST.ordinal()] = 3; } catch (NoSuchFieldError var2) { ; } try { field_177366_a[EnumFacing.WEST.ordinal()] = 4; } catch (NoSuchFieldError var1) { ; } } } } wich is a barley copy/paste of the TileEntityChest class but with an inventory reduced to 9 slots The tile entity is registered in the init method by doing this GameRegistry.registerTileEntity(TileEntityGift.class, "tileEntityGift"); EDIT: i confirm, is a problem with the tile entity, because giving the block the vanilla TileEntityChest cause no problem