-
Posts
1061 -
Joined
-
Last visited
Everything posted by NovaViper
-
[1.8][SOLVED] Entity isn't making dirt into grass
NovaViper replied to NovaViper's topic in Modder Support
That didn't work, here's what I did for(int l = 0; l <= 4; ++l) //TODO { if(worldObj.rand.nextFloat() < footprint_chance) { continue; } int i = MathHelper.floor_double(this.posX + (l % 2 * 2 - 1) * 0.25F); int j = MathHelper.floor_double(this.posY) - 1 ; int k = MathHelper.floor_double(this.posZ + (l / 2 % 2 * 2 - 1) * 0.25F); if (this.worldObj.getBlockState(new BlockPos(i, j, k)) == Blocks.dirt //TODO && this.worldObj.getBlockState(new BlockPos(i, j+1, k)).getBlock().getLightValue() >= 4 && this.worldObj.getBlockState(new BlockPos(i, j, k)).getBlock().getDefaultState() == this.worldObj.getBlockState(new BlockPos(i, j, k)).getBlock().getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT) // dirt not podzol && this.worldObj.getBlockLightOpacity(new BlockPos(i, j+1, k)) <= 2){ this.worldObj.setBlockState(new BlockPos(i, j, k), footprint.getDefaultState()); } } -
I can't figure out how to make the entity get the dirt block below it to turn into grass. In the previous version, I created a getter that grabbed the block's position and metadata, but with 1.8, everything with the block position and metadata changed. How I do it now? for(int l = 0; l <= 4; ++l) //TODO { if(worldObj.rand.nextFloat() < footprint_chance) { continue; } int i = MathHelper.floor_double(this.posX + (l % 2 * 2 - 1) * 0.25F); int j = MathHelper.floor_double(this.posY) - 1 ; int k = MathHelper.floor_double(this.posZ + (l / 2 % 2 * 2 - 1) * 0.25F); if (this.worldObj.getBlockState(new BlockPos(i, j, k)) == Blocks.dirt //TODO && this.worldObj.getBlockState(new BlockPos(i, j+1, k)).getBlock().getLightValue() >= 4 && this.worldObj.getBlockState(new BlockPos(i, j, k)).getBlock() == 0// dirt not podzol && this.worldObj.getBlockLightOpacity(new BlockPos(i, j+1, k)) <= 2){ this.worldObj.setBlockState(new BlockPos(i, j, k), footprint.getDefaultState()); } } Also, here is the ORIGINAL 1.7.10 code I used and worked successfully on 1.7.10 for(int l = 0; l <= 4; ++l) //TODO { if(worldObj.rand.nextFloat() < footprint_chance) { continue; } int i = MathHelper.floor_double(this.posX + (l % 2 * 2 - 1) * 0.25F); int j = MathHelper.floor_double(this.posY) - 1 ; int k = MathHelper.floor_double(this.posZ + (l / 2 % 2 * 2 - 1) * 0.25F); if (this.worldObj.getBlock(i, j, k) == Blocks.dirt && this.worldObj.getBlockMetadata(i, j, k) == 0 // dirt not podzol && this.worldObj.getBlockLightValue(i, j+1, k) >= 4 && this.worldObj.getBlockLightOpacity(i, j+1, k) <= 2){ this.worldObj.setBlock(i, j, k, footprint); } }
-
[1.8] How to make a 3D model item <Not Solved>
NovaViper replied to many231's topic in Modder Support
Here's what I did { "__comment": "Made with MC Model Maker for Minecraft versions 14w26a+", "ambientocclusion": true, "textures": { "null": "zero_quest:blocks/nileWorktable/", "TableSide": "blocks/crafting_table_side", "TableTop": "blocks/crafting_table_top", "TableBottom": "blocks/planks_oak", "particle": "blocks/crafting_table_front" }, "elements": [ { "from": [ 0, 0, 0 ], "to": [ 16, 3, 16 ], "__comment": "base", "faces": { "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#null", "cullface": false }, "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#null", "cullface": false }, "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#null", "cullface": false }, "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#null", "cullface": false }, "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#null", "cullface": false }, "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#null", "cullface": false } } }, { "from": [ 2, 3, 2 ], "to": [ 14, 9, 14 ], "__comment": "pole", "faces": { "north": { "uv": [ 0, 0, 0, 0 ], "texture": "#null", "cullface": false }, "south": { "uv": [ 0, 0, 0, 0 ], "texture": "#null", "cullface": false }, "east": { "uv": [ 0, 0, 0, 0 ], "texture": "#null", "cullface": false }, "west": { "uv": [ 0, 0, 0, 0 ], "texture": "#null", "cullface": false }, "up": { "uv": [ 0, 0, 0, 0 ], "texture": "#null", "cullface": false }, "down": { "uv": [ 0, 0, 0, 0 ], "texture": "#null", "cullface": false } } }, { "from": [ 0, 8, 0 ], "to": [ 16, 15, 16 ], "__comment": "top", "faces": { "north": { "uv": [ 0, 0, 0, 0 ], "texture": "#null", "cullface": false }, "south": { "uv": [ 0, 0, 0, 0 ], "texture": "#null", "cullface": false }, "east": { "uv": [ 0, 0, 0, 0 ], "texture": "#null", "cullface": false }, "west": { "uv": [ 0, 0, 0, 0 ], "texture": "#null", "cullface": false }, "up": { "uv": [ 0, 0, 0, 0 ], "texture": "#null", "cullface": false }, "down": { "uv": [ 0, 0, 0, 0 ], "texture": "#null", "cullface": false } } } ] } -
[1.8] How to make a 3D model item <Not Solved>
NovaViper replied to many231's topic in Modder Support
Thats what the MC Model maker is for, take the anvil's model json and import it inside the maker and you would see how it's made (though it doesn't show a 3d preview of it since the whole thing is entirely flat) -
[1.8] How to make a 3D model item <Not Solved>
NovaViper replied to many231's topic in Modder Support
Well.. not necessarily, I studied my techne model I made (like for instance, I was making a base that was 3 pixels high, I did the same number of pixels on the maker and got the same result, even though on techne, it said 6 instead of 3) -
[1.8] How to make a 3D model item <Not Solved>
NovaViper replied to many231's topic in Modder Support
Use this: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-tools/1265906-tool-mc-model-maker-design-custom-block-models I used that to make my custom crafting table, it's a little hard to texture it but i would look at the anvil json file while creating the custom model -
[1.8] [SOLVED] How to register Blocks, items and entites?
NovaViper replied to NovaViper's topic in Modder Support
Ok so I figured out why wasn't the blocks being rendered, but I still have one problem.. all my entities I made are rendering as gray blocks now.. what am I doing wrong? my other post has the EntityZertum codes in it ----EDIT----- I fixed it.. I made a completely newb mistake.. I forgot to un-comment the proxy load methods on the main mod class. Thanks guys for your help and sorry for all the problems! -
[1.8] [SOLVED] How to register Blocks, items and entites?
NovaViper replied to NovaViper's topic in Modder Support
Sorry! I just have so many errors, mainly in the blocks and items (and dimensions.. which I will deal with later). -
[1.8] [SOLVED] How to register Blocks, items and entites?
NovaViper replied to NovaViper's topic in Modder Support
Oh yeah, I forgot to mention; all my entites are spawning as blocks, here are the code for an entity called Zertum: EntityFile public class EntityZertum extends EntityCustomTameable { private float headRotationCourse; private float headRotationCourseOld; private boolean isWet; private boolean isShaking; private float timeWolfIsShaking; private float prevTimeWolfIsShaking; public static final double maxHealth = 25; public static final double attackDamage = 6; public static final double speed = 0.30000001192092896; public static final double maxHealthTamed = 35; public static final double attackDamageTamed = 8; public static final double maxHealthBaby = 10; public static final double attackDamageBaby = 2; public EntityZertum(World worldIn) { super(worldIn); this.setSize(0.6F, 1.5F); ((PathNavigateGround)this.getNavigator()).func_179690_a(true); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, this.aiSit); this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F)); this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true)); this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F)); this.tasks.addTask(6, new EntityAIMate(this, 1.0D)); this.tasks.addTask(6, aiFetchBone); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(8, new EntityCustomZAIBeg(this, 8.0F)); this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(9, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true, new Class[0])); this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntityAnimal.class, false, new Predicate() { private static final String __OBFID = "CL_00002229"; public boolean func_180094_a(Entity p_180094_1_) { return p_180094_1_ instanceof EntitySheep || p_180094_1_ instanceof EntityRabbit; } public boolean apply(Object p_apply_1_) { return this.func_180094_a((Entity)p_apply_1_); } })); this.targetTasks.addTask(5, new EntityAINearestAttackableTarget(this, EntitySkeleton.class, false)); this.setTamed(false); this.inventory = new InventoryPack(this); } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackDamage); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(speed); if (this.isTamed()) { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealthTamed); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackDamageTamed); } else if (this.isChild()) { this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealthBaby); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackDamageBaby); } } /** * Sets the active target the Task system uses for tracking */ @Override public void setAttackTarget(EntityLivingBase p_70624_1_) { super.setAttackTarget(p_70624_1_); if (p_70624_1_ == null) { this.setAngry(false); } else if (!this.isTamed()) { this.setAngry(true); } } @Override protected void updateAITasks() { this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth())); } @Override protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, new Float(this.getHealth())); this.dataWatcher.addObject(19, new Byte((byte)0)); this.dataWatcher.addObject(20, new Byte((byte)EnumDyeColor.RED.func_176765_a())); } @Override protected void func_180429_a(BlockPos p_180429_1_, Block p_180429_2_) { this.playSound("mob.wolf.step", 0.15F, 1.0F); } @Override public void writeEntityToNBT(NBTTagCompound tagCompound) { super.writeEntityToNBT(tagCompound); tagCompound.setBoolean("Angry", this.isAngry()); tagCompound.setByte("CollarColor", (byte)this.func_175546_cu().getDyeColorDamage()); } @Override public void readEntityFromNBT(NBTTagCompound tagCompund) { super.readEntityFromNBT(tagCompund); this.setAngry(tagCompund.getBoolean("Angry")); if (tagCompund.hasKey("CollarColor", 99)) { this.func_175547_a(EnumDyeColor.func_176766_a(tagCompund.getByte("CollarColor"))); } } /** * Returns the sound this mob makes while it's alive. */ @Override protected String getLivingSound() { return this.canSeeCreeper ? "mob.wolf.growl" : this.isAngry() ? "mob.wolf.growl" : (this.rand.nextInt(3) == 0 ? (this.isTamed() && this.getHealth() <= 10.0F ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark"); } /** * Returns the sound this mob makes when it is hurt. */ @Override protected String getHurtSound() { return "mob.wolf.hurt"; } /** * Returns the sound this mob makes on death. */ @Override protected String getDeathSound() { return "mob.wolf.death"; } /** * Returns the volume for the sounds this mob makes. */ @Override protected float getSoundVolume() { return 0.5F; } /** * Get number of ticks, at least during which the living entity will be silent. */ @Override public int getTalkInterval() { if(this.canSeeCreeper){ return 40; }else if(this.getHealth() <=10){ return 20; }else{ return 200; } } /** * Returns the item ID for the item the mob drops on death. */ @Override protected void dropFewItems(boolean par1, int par2) { rare = rand.nextInt(20); { if (this.isBurning()) { this.dropItem(ModItems.zertumMeatCooked, 1); } else if (rare <= 12) { this.dropItem(ModItems.zertumMeatRaw, 1); } if(rare <= 6 && !this.isTamed()) { this.dropItem(ModItems.nileGrain, 1); } /*if(this.hasRadarCollar()) { this.dropItem(ModItems.radioCollar, 1); }*/ /*if(rare >= 17) { this.dropItem(ModItems.darkDust.itemID, 1); }*/ else { } } } /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ @Override public void onLivingUpdate() //TODO { super.onLivingUpdate(); if (isServer() && this.isWet && !this.isShaking && !this.hasPath() && this.onGround) { this.isShaking = true; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; this.worldObj.setEntityState(this, (byte); } if (isServer() && this.getAttackTarget() == null && this.isAngry()) { this.setAngry(false); } if(Constants.DEF_HEALING == true && !this.isChild() && this.getHealth() <=10 && this.isTamed()) { this.addPotionEffect(new PotionEffect(10, 200)); } if (this.getAttackTarget() == null && isTamed() && 15 > 0) { List list1 = worldObj.getEntitiesWithinAABB(EntityCreeper.class, AxisAlignedBB.fromBounds(posX, posY, posZ, posX + 1.0D, posY + 1.0D, posZ + 1.0D).expand(sniffRange(), 4D, sniffRange())); if (!list1.isEmpty() && !isSitting() && this.getHealth() > 1 && !this.isChild()) { canSeeCreeper = true; } else { canSeeCreeper = false; } } } /** * Called to update the entity's position/logic. */ @Override public void onUpdate() { super.onUpdate(); this.headRotationCourseOld = this.headRotationCourse; if (this.func_70922_bv()) { this.headRotationCourse += (1.0F - this.headRotationCourse) * 0.4F; } else { this.headRotationCourse += (0.0F - this.headRotationCourse) * 0.4F; } if (this.isWet()) { this.isWet = true; this.isShaking = false; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; } else if ((this.isWet || this.isShaking) && this.isShaking) { if (this.timeWolfIsShaking == 0.0F) { this.playSound("mob.wolf.shake", this.getSoundVolume(), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); } this.prevTimeWolfIsShaking = this.timeWolfIsShaking; this.timeWolfIsShaking += 0.05F; if (this.prevTimeWolfIsShaking >= 2.0F) { this.isWet = false; this.isShaking = false; this.prevTimeWolfIsShaking = 0.0F; this.timeWolfIsShaking = 0.0F; } if (this.timeWolfIsShaking > 0.4F) { float f = (float)this.getEntityBoundingBox().minY; int i = (int)(MathHelper.sin((this.timeWolfIsShaking - 0.4F) * (float)Math.PI) * 7.0F); for (int j = 0; j < i; ++j) { float f1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F; this.worldObj.spawnParticle(EnumParticleTypes.WATER_SPLASH, this.posX + (double)f1, (double)(f + 0.8F), this.posZ + (double)f2, this.motionX, this.motionY, this.motionZ, new int[0]); } } } if(this.isTamed()) { //TODO EntityPlayer player = (EntityPlayer)this.getOwner(); if(player != null) { float distanceToOwner = player.getDistanceToEntity(this); if (distanceToOwner <= 2F && this.hasBone()) { if(isServer()) { this.entityDropItem(new ItemStack(ModItems.toy, 1, 1), 0.0F); } this.setHasBone(false); } } } } @SideOnly(Side.CLIENT) public boolean isWolfWet() { return this.isWet; } @SideOnly(Side.CLIENT) public float getShadingWhileWet(float p_70915_1_) { return 0.75F + (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70915_1_) / 2.0F * 0.25F; } @SideOnly(Side.CLIENT) public float getShakeAngle(float p_70923_1_, float p_70923_2_) { float f2 = (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70923_1_ + p_70923_2_) / 1.8F; if (f2 < 0.0F) { f2 = 0.0F; } else if (f2 > 1.0F) { f2 = 1.0F; } return MathHelper.sin(f2 * (float)Math.PI) * MathHelper.sin(f2 * (float)Math.PI * 11.0F) * 0.15F * (float)Math.PI; } @SideOnly(Side.CLIENT) public float getInterestedAngle(float p_70917_1_) { return (this.headRotationCourseOld + (this.headRotationCourse - this.headRotationCourseOld) * p_70917_1_) * 0.15F * (float)Math.PI; } public float getEyeHeight() { return this.height * 0.8F; } public int getVerticalFaceSpeed() { return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); } /** * Called when the entity is attacked. */ @Override public boolean attackEntityFrom(DamageSource source, float amount) { if (this.func_180431_b(source)) { return false; } else { Entity entity = source.getEntity(); this.aiSit.setSitting(false); if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { amount = (amount + 1.0F) / 2.0F; } return super.attackEntityFrom(source, amount); } } public boolean attackEntityAsMob(Entity par1Entity) { float damage = (float)this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue(); int i = 0; int critChance = 5; critChance += 2; if (rand.nextInt(6) < critChance) { //TODO damage += (damage + 3) / 2; double d0 = this.rand.nextGaussian() * 0.02D; double d1 = this.rand.nextGaussian() * 0.02D; double d2 = this.rand.nextGaussian() * 0.02D; worldObj.spawnParticle(EnumParticleTypes.CRIT, this.posX + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, this.posY + 0.5D + (double)(this.rand.nextFloat() * this.height), this.posZ + (double)(this.rand.nextFloat() * this.width * 2.0F) - (double)this.width, d0, d1, d2); } boolean flag = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), damage); if (flag) { if (i > 0) { par1Entity.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)i * 0.5F)); this.motionX *= 0.6D; this.motionZ *= 0.6D; } } return flag; } /** * Called when the mob's health reaches 0. */ @Override //TODO public void onDeath(DamageSource par1DamageSource) { super.onDeath(par1DamageSource); if (par1DamageSource.getEntity() instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)par1DamageSource.getEntity(); { entityplayer.triggerAchievement(ModAchievements.ZertKill); this.dropChestItems(); } } } /** * Gets the pitch of living sounds in living entities. */ @Override protected float getPitch() { if(!this.isChild()) return super.getSoundPitch(); else{ return super.getSoundPitch() * 1; } } /** * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig. */ public boolean interact(EntityPlayer par1EntityPlayer) { ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem(); if (this.isTamed()) { if (itemstack != null) { if (itemstack.getItem() instanceof ItemFood) { ItemFood itemfood = null; if(getHealthRelative() < 1) { itemfood = (ItemFood) ItemUtils.consumeEquipped(par1EntityPlayer, Items.fish, Items.porkchop, Items.beef, Items.chicken, Items.rabbit, Items.mutton, Items.cooked_porkchop, Items.cooked_beef, Items.cooked_chicken, Items.cooked_fish, Items.cooked_rabbit, Items.cooked_mutton, ModItems.jakanMeatRaw, ModItems.jakanMeatCooked, ModItems.zertumMeatRaw, ModItems.zertumMeatCooked); if (itemfood != null) { float volume = getSoundVolume() * 1.0f; float pitch = getPitch(); worldObj.playSoundAtEntity(this, Sound.Chew, volume, pitch); this.heal((float)itemfood.getHealAmount(itemstack)); } return true; } } else if(itemstack.getItem() == Items.stick && canInteract(par1EntityPlayer)) //TODO { if(isServer()){ par1EntityPlayer.openGui(ZeroQuest.instance, CommonProxy.PetPack, this.worldObj, this.getEntityId(), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)); this.worldObj.playSoundEffect(this.posX, this.posY + 0.5D, this.posZ, "random.chestopen", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); return true; } } else if (itemstack.getItem() == Items.dye) { EnumDyeColor enumdyecolor = EnumDyeColor.func_176766_a(itemstack.getMetadata()); if (enumdyecolor != this.func_175546_cu()) { this.func_175547_a(enumdyecolor); if (!par1EntityPlayer.capabilities.isCreativeMode && --itemstack.stackSize <= 0) { par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, (ItemStack)null); } return true; } } } if (canInteract(par1EntityPlayer) && isServer() && !this.isBreedingItem(itemstack)) { this.aiSit.setSitting(!this.isSitting()); this.isJumping = false; this.navigator.clearPathEntity(); this.setAttackTarget((EntityLivingBase)null); } } else if (ItemUtils.consumeEquipped(par1EntityPlayer, ModItems.nileBone) && !this.isAngry()) { if (isServer()) { tamedFor(par1EntityPlayer, rand.nextInt(3) == 0); par1EntityPlayer.triggerAchievement(ModAchievements.ZertTame); } return true; } return super.interact(par1EntityPlayer); } @SideOnly(Side.CLIENT) public void handleHealthUpdate(byte p_70103_1_) { if (p_70103_1_ == { this.isShaking = true; this.timeWolfIsShaking = 0.0F; this.prevTimeWolfIsShaking = 0.0F; } else { super.handleHealthUpdate(p_70103_1_); } } /** * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on * the animal type) */ public boolean isBreedingItem(ItemStack itemstack) { return itemstack == null ? false : itemstack.getItem() == ModItems.dogTreat; } public int getMaxSpawnedInChunk() { return 8; } public boolean isAngry() { return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0; } public void setAngry(boolean p_70916_1_) { byte b0 = this.dataWatcher.getWatchableObjectByte(16); if (p_70916_1_) { this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 2))); } else { this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -3))); } } public EnumDyeColor func_175546_cu() { return EnumDyeColor.func_176766_a(this.dataWatcher.getWatchableObjectByte(20) & 15); } public void func_175547_a(EnumDyeColor p_175547_1_) { this.dataWatcher.updateObject(20, Byte.valueOf((byte)(p_175547_1_.getDyeColorDamage() & 15))); } /** * This function is used when two same-species animals in 'love mode' breed to generate the new baby animal. */ public EntityCustomTameable spawnBabyAnimal(EntityAgeable par1EntityAgeable) { double chance = Math.random(); if (chance < 0.5){ EntityZertum var3 = new EntityZertum(this.worldObj); var3.func_152115_b(this.func_152113_b()); var3.setTamed(true); return var3; }else if (chance < 0.7){ EntityRedZertum var4 = new EntityRedZertum(this.worldObj); var4.func_152115_b(this.func_152113_b()); var4.setTamed(true); return var4; }else{ EntityDestroZertum var2 = new EntityDestroZertum(this.worldObj); var2.func_152115_b(this.func_152113_b()); var2.setTamed(true); return var2; } } @Override public EntityAgeable createChild(EntityAgeable entityageable) { return spawnBabyAnimal(entityageable); } public void func_70918_i(boolean p_70918_1_) { if (p_70918_1_) { this.dataWatcher.updateObject(19, Byte.valueOf((byte)1)); } else { this.dataWatcher.updateObject(19, Byte.valueOf((byte)0)); } } /** * Returns true if the mob is currently able to mate with the specified mob. */ public boolean canMateWith(EntityAnimal p_70878_1_) { if (p_70878_1_ == this) { return false; } else if (!this.isTamed()) { return false; } else if (!(p_70878_1_ instanceof EntityZertum)) { return false; } else { EntityZertum entitywolf = (EntityZertum)p_70878_1_; return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.isInLove() && entitywolf.isInLove()); } } public boolean func_70922_bv() { return this.dataWatcher.getWatchableObjectByte(19) == 1; } /** * Determines if an entity can be despawned, used on idle far away entities */ protected boolean canDespawn() { return !this.isTamed() && this.ticksExisted > 2400; } public boolean allowLeashing() { return !this.isAngry() && super.allowLeashing(); } } Render File @SideOnly(Side.CLIENT) public class RenderZertum extends RenderLiving { private static final ResourceLocation zertumTextures = new ResourceLocation(ZeroQuest.modid + ":" + "textures/entity/zertum/zertum.png"); private static final ResourceLocation tamedZertumTextures = new ResourceLocation(ZeroQuest.modid + ":" + "textures/entity/zertum/zertum_tame.png"); private static final ResourceLocation angryZertumTextures = new ResourceLocation(ZeroQuest.modid + ":" + "textures/entity/zertum/zertum_angry.png"); public RenderZertum(RenderManager p_i46128_1_, ModelZertum p_i46128_2_, float p_i46128_3_){ super(p_i46128_1_, p_i46128_2_, p_i46128_3_); this.addLayer(new LayerZertumCollarDying(this)); } public void func_177135_a(EntityZertum p_177135_1_, double p_177135_2_, double p_177135_4_, double p_177135_6_, float p_177135_8_, float p_177135_9_) { if (p_177135_1_.isWolfWet()) { float f2 = p_177135_1_.getBrightness(p_177135_9_) * p_177135_1_.getShadingWhileWet(p_177135_9_); GlStateManager.color(f2, f2, f2); } super.doRender((EntityLiving)p_177135_1_, p_177135_2_, p_177135_4_, p_177135_6_, p_177135_8_, p_177135_9_); } protected ResourceLocation getEntityTexture(EntityZertum p_110775_1_) { return p_110775_1_.isTamed() ? tamedZertumTextures : (p_110775_1_.isAngry() ? angryZertumTextures : zertumTextures); } public void doRender(EntityLiving p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { this.func_177135_a((EntityZertum)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); } public void doRender(EntityLivingBase p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { this.func_177135_a((EntityZertum)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); } protected ResourceLocation getEntityTexture(Entity p_110775_1_) { return this.getEntityTexture((EntityZertum)p_110775_1_); } } Model @SideOnly(Side.CLIENT) public class ModelZertum extends ModelBase { //fields ModelRenderer Nose; ModelRenderer Ear2; ModelRenderer Ear1; ModelRenderer Head; ModelRenderer LeftHindLeg2; ModelRenderer LeftHindLeg1; ModelRenderer RightHindLeg2; ModelRenderer RightHindLeg1; ModelRenderer Mane1; ModelRenderer RightLeg; ModelRenderer LeftLeg; ModelRenderer Tail1; ModelRenderer Mane2; ModelRenderer Torso; ModelRenderer Tail2; ModelRenderer Neck; private float rightLegStartingRotation = -0.2974289F; private float lightLegStartingRotation = -0.2974289F; public ModelZertum() { textureWidth = 128; textureHeight = 64; Nose = new ModelRenderer(this, 25, 27); Nose.addBox(-1.5F, 0F, -3F, 3, 3, 4); Nose.setRotationPoint(0F, 2.5F, -15F); Nose.setTextureSize(64, 32); Nose.mirror = true; setRotation(Nose, 0F, 0F, 0F); Ear2 = new ModelRenderer(this, 40, 28); Ear2.addBox(-1F, -3F, 0F, 2, 3, 1); Ear2.setRotationPoint(2F, -0.5F, -10.5F); Ear2.setTextureSize(64, 32); Ear2.mirror = true; setRotation(Ear2, 0F, 0F, 0F); Ear1 = new ModelRenderer(this, 40, 28); Ear1.addBox(-1F, -3F, 0F, 2, 3, 1); Ear1.setRotationPoint(-2F, -0.5F, -10.5F); Ear1.setTextureSize(64, 32); Ear1.mirror = true; setRotation(Ear1, 0F, 0F, 0F); Head = new ModelRenderer(this, 25, 15); Head.addBox(-3F, -0.5F, -14F, 6, 6, 5); Head.setRotationPoint(-0.5F, 6F, -3F); Head.setTextureSize(64, 32); Head.mirror = true; setRotation(Head, 0F, 0F, 0F); LeftHindLeg1 = new ModelRenderer(this, 11, 18); LeftHindLeg1.addBox(-1F, 0F, -1F, 2, 5, 3); LeftHindLeg1.setRotationPoint(1.5F, 13F, 5F); LeftHindLeg1.setTextureSize(128, 64); LeftHindLeg1.mirror = true; setRotation(LeftHindLeg1, -0.2974289F, 0F, 0F); LeftHindLeg2 = new ModelRenderer(this, 9, 44); LeftHindLeg2.addBox(-1F, 0F, -1F, 2, 8, 2); LeftHindLeg2.setRotationPoint(0F, 3F, 0.5F); LeftHindLeg2.setTextureSize(128, 64); LeftHindLeg2.mirror = true; setRotation(LeftHindLeg2, 0.2974289F, 0F, 0F); RightHindLeg1 = new ModelRenderer(this, 11, 31); RightHindLeg1.addBox(-1F, 0F, -1F, 2, 5, 3); RightHindLeg1.setRotationPoint(-2.5F, 13F, 5F); RightHindLeg1.setTextureSize(128, 64); RightHindLeg1.mirror = true; setRotation(RightHindLeg1, -0.2974289F, 0F, 0F); RightHindLeg2 = new ModelRenderer(this, 0, 44); RightHindLeg2.addBox(-1F, 0F, -1F, 2, 8, 2); RightHindLeg2.setRotationPoint(0F, 3F, 0.5F); RightHindLeg2.setTextureSize(128, 64); RightHindLeg2.mirror = true; setRotation(RightHindLeg2, 0.2974289F, 0F, 0F); Mane1 = new ModelRenderer(this, 43, 0); Mane1.addBox(-3F, -3F, -3F, 6, 6, 7); Mane1.setRotationPoint(-0.5F, 14F, -3F); Mane1.setTextureSize(128, 64); Mane1.mirror = true; setRotation(Mane1, 1.496439F, 0F, 0F); Neck = new ModelRenderer(this, 0, 0); Neck.addBox(-2.5F, -12F, -4F, 4, 7, 4); Neck.setRotationPoint(0.5F, 0F, 0F); Neck.setTextureSize(64, 32); Neck.mirror = true; setRotation(Neck, -0.6015813F, 0F, 0F); Mane2 = new ModelRenderer(this, 18, 0); Mane2.addBox(-2.5F, -7F, -3.6F, 5, 6, 7); Mane2.setRotationPoint(0F, 0F, 0F); Mane2.setTextureSize(64, 32); Mane2.mirror = true; setRotation(Mane2, -0.34653F, 0F, 0F); RightLeg = new ModelRenderer(this, 0, 30); RightLeg.addBox(-1F, 0F, -1F, 2, 10, 2); RightLeg.setRotationPoint(-3F, 14F, -4F); RightLeg.setTextureSize(128, 64); RightLeg.mirror = true; setRotation(RightLeg, 0F, 0F, 0F); LeftLeg = new ModelRenderer(this, 0, 16); LeftLeg.addBox(-1F, 0F, -1F, 2, 10, 2); LeftLeg.setRotationPoint(2F, 14F, -4F); LeftLeg.setTextureSize(128, 64); LeftLeg.mirror = true; setRotation(LeftLeg, 0F, 0F, 0F); Tail1 = new ModelRenderer(this, 91, 0); Tail1.addBox(-1.5F, 0F, -1F, 4, 8, 4); Tail1.setRotationPoint(-1F, 14F, 5F); Tail1.setTextureSize(128, 64); Tail1.mirror = true; setRotation(Tail1, 1.315962F, 0F, 0F); Tail2 = new ModelRenderer(this, 110, 0); Tail2.addBox(-1.5F, 0F, -1F, 3, 8, 3); Tail2.setRotationPoint(0.5F, 6F, 0F); Tail2.setTextureSize(64, 32); Tail2.mirror = true; setRotation(Tail2, 0.141605F, 0F, 0F); Torso = new ModelRenderer(this, 69, 0); Torso.addBox(-2.5F, -3F, -3F, 5, 9, 5); Torso.setRotationPoint(-0.5F, 12.5F, 1F); Torso.setTextureSize(128, 64); Torso.mirror = true; setRotation(Torso, 1.496439F, 0F, 0F); Head.addChild(Nose); Head.addChild(Ear1); Head.addChild(Ear2); LeftHindLeg1.addChild(LeftHindLeg2); RightHindLeg1.addChild(RightHindLeg2); Mane1.addChild(Mane2); Mane1.addChild(Neck); Tail1.addChild(Tail2); } public void render(Entity par1Entity, float par2, float par3, float par4, float par5, float par6, float par7) { super.render(par1Entity, par2, par3, par4, par5, par6, par7); this.setRotationAngles(par2, par3, par4, par5, par6, par7, par1Entity); if (this.isChild) { float f6 = 2.0F; GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 5.0F * par7, 6.0F * par7); Head.render(par7); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(1.0F / f6, 1.0F / f6, 1.0F / f6); GL11.glTranslatef(0.0F, 24.0F * par7, 0.0F); LeftHindLeg1.render(par7); RightHindLeg1.render(par7); Mane1.render(par7); RightLeg.render(par7); LeftLeg.render(par7); Tail1.render(par7); Torso.render(par7); GL11.glPopMatrix(); } else { GL11.glPushMatrix(); GL11.glScalef(1.5F, 1.5F, 1.5F); GL11.glTranslatef(0.0F, -0.5F, 0.0F); Head.render(par7); LeftHindLeg1.render(par7); RightHindLeg1.render(par7); Mane1.render(par7); RightLeg.render(par7); LeftLeg.render(par7); Tail1.render(par7); Torso.render(par7); GL11.glPopMatrix(); } } /** * Used for easily adding entity-dependent animations. The second and third float params here are the same second * and third as in the setRotationAngles method. */ public void setLivingAnimations(EntityLivingBase par1EntityLivingBase, float par2, float par3, float par4) { EntityZertum entityzertum = (EntityZertum)par1EntityLivingBase; if (entityzertum.isAngry()) { this.Ear1.rotateAngleX = -0.5948578F; this.Ear2.rotateAngleX = -0.5948578F; }else if (entityzertum.getHealth() <=10){ this.Ear1.rotateAngleX = -0.9948578F; this.Ear2.rotateAngleX = -0.9948578F; }else{ this.Ear1.rotateAngleX = 0.0F; this.Ear2.rotateAngleX = 0.0F; } if (entityzertum.isSitting()) //TODO { LeftHindLeg1.setRotationPoint(1.5F, 18F, 5F); LeftHindLeg1.rotateAngleX = -2.082003F; LeftHindLeg2.setRotationPoint(0F, 3.7F, 0F);// LeftHindLeg2.rotateAngleX = 2.082003F; RightHindLeg1.setRotationPoint(-2.5F, 18F, 5F); RightHindLeg1.rotateAngleX = -2.082003F; RightHindLeg2.setRotationPoint(0F, 3.7F, 0F);// RightHindLeg2.rotateAngleX = 2.082003F; Torso.setRotationPoint(-0.5F, 15F, 1F); Torso.rotateAngleX = 0.9759358F; Tail1.setRotationPoint(-1F, 19.5F, 5F); Tail1.rotateAngleX = 1.055712F; } else { LeftHindLeg1.setRotationPoint(1.5F, 13F, 5F); LeftHindLeg1.rotateAngleX = -0.2974289F; LeftHindLeg2.setRotationPoint(0F, 3F, 0.5F); LeftHindLeg2.rotateAngleX = 0.2974289F; RightHindLeg1.setRotationPoint(-2.5F, 13F, 5F); RightHindLeg1.rotateAngleX = -0.2974289F; RightHindLeg2.setRotationPoint(0F, 3F, 0.5F); RightHindLeg2.rotateAngleX = 0.2974289F; Torso.setRotationPoint(-0.5F, 12.5F, 1F); Torso.rotateAngleX = 1.496439F; Tail1.setRotationPoint(-1F, 14F, 5F); Tail1.rotateAngleX = 1.315962F; this.RightHindLeg1.rotateAngleX = rightLegStartingRotation + MathHelper.cos(par2 * 0.6662F) * 1.4F * par3; this.LeftHindLeg1.rotateAngleX = lightLegStartingRotation + MathHelper.cos(par2 * 0.6662F + (float)Math.PI) * 1.4F * par3; this.RightLeg.rotateAngleX = MathHelper.cos(par2 * 0.6662F + (float)Math.PI) * 1.4F * par3; this.LeftLeg.rotateAngleX = MathHelper.cos(par2 * 0.6662F) * 1.4F * par3; } this.Head.rotateAngleZ = entityzertum.getInterestedAngle(par4) + entityzertum.getShakeAngle(par4, 0.0F); this.Mane1.rotateAngleZ = entityzertum.getShakeAngle(par4, -0.08F); this.Torso.rotateAngleZ = entityzertum.getShakeAngle(par4, -0.16F); this.Tail1.rotateAngleZ = entityzertum.getShakeAngle(par4, -0.32F); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float par1, float par2, float par3, float par4, float par5, float par6, Entity par7Entity) { super.setRotationAngles(par1, par2, par3, par4, par5, par6, par7Entity); this.Head.rotateAngleX = par5 / (280F / (float)Math.PI); this.Head.rotateAngleY = par4 / (180F / (float)Math.PI); this.Mane1.rotateAngleY = par4 / (180F / (float)Math.PI); } } Add Layer file @SideOnly(Side.CLIENT) public class LayerZertumCollarDying implements LayerRenderer { private static final ResourceLocation field_177147_a = new ResourceLocation(ZeroQuest.modid + ":" + "textures/entity/zertum/zertum_collar.png"); private static final ResourceLocation ZertumDyingTextures = new ResourceLocation(ZeroQuest.modid + ":" + "textures/entity/zertum/zertum_dying.png"); private final RenderZertum field_177146_b; private static final String __OBFID = "CL_00002405"; public LayerZertumCollarDying(RenderZertum p_177145_1_) { this.field_177146_b = p_177145_1_; } public void func_177145_a(EntityZertum p_177145_1_, float p_177145_2_, float p_177145_3_, float p_177145_4_, float p_177145_5_, float p_177145_6_, float p_177145_7_, float p_177145_8_) { if (p_177145_1_.isTamed() && !p_177145_1_.isInvisible()) { this.field_177146_b.bindTexture(field_177147_a); EnumDyeColor enumdyecolor = EnumDyeColor.func_176764_b(p_177145_1_.func_175546_cu().func_176765_a()); float[] afloat = EntitySheep.func_175513_a(enumdyecolor); GlStateManager.color(afloat[0], afloat[1], afloat[2]); this.field_177146_b.getMainModel().render(p_177145_1_, p_177145_2_, p_177145_3_, p_177145_5_, p_177145_6_, p_177145_7_, p_177145_8_); } if(p_177145_1_.isTamed() && p_177145_1_.getHealth() <=10){ this.field_177146_b.bindTexture(ZertumDyingTextures); } } public boolean shouldCombineTextures() { return true; } public void doRenderLayer(EntityLivingBase p_177141_1_, float p_177141_2_, float p_177141_3_, float p_177141_4_, float p_177141_5_, float p_177141_6_, float p_177141_7_, float p_177141_8_) { this.func_177145_a((EntityZertum)p_177141_1_, p_177141_2_, p_177141_3_, p_177141_4_, p_177141_5_, p_177141_6_, p_177141_7_, p_177141_8_); } } -
[1.8] [SOLVED] How to register Blocks, items and entites?
NovaViper replied to NovaViper's topic in Modder Support
I have one more question, I can't seem to register textures for my blocks, I used the json files but the textures are still missing, how do I fixed this? Also, Im not sure how to render my custom crafting table, here are the rendering and tile entity codes: TileEntity public class TileEntityNileTable extends TileEntity implements IInventory, ISlotChanged { private ItemStack[] inventory; public IInventory craftResult = new InventoryCraftResult(); public ItemStack[] craftMatrixInventory; public TileEntityNileTable() { super(); inventory = new ItemStack[32]; craftMatrixInventory = new ItemStack[9]; //TODO: magic number } @Override public int getSizeInventory() { return inventory.length; } @Override public ItemStack getStackInSlot(int i) { return this.inventory[i]; } @Override public void onSlotChange(Slot slot, int id, ItemStack itemStack) { System.out.println("Upgrade changed"); } @Override public ItemStack decrStackSize(int slot, int amount) { ItemStack itemStack = getStackInSlot(slot); if (itemStack != null) { if (itemStack.stackSize <= amount) { setInventorySlotContents(slot, null); } else { itemStack = itemStack.splitStack(amount); if (itemStack.stackSize == 0) { setInventorySlotContents(slot, null); } } } return itemStack; } @Override public ItemStack getStackInSlotOnClosing(int slot) { if (inventory[slot] != null) { ItemStack itemStack = inventory[slot]; inventory[slot] = null; return itemStack; } else return null; } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { inventory[i] = itemstack; if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { itemstack.stackSize = getInventoryStackLimit(); } markDirty(); } @Override public String getName() { return "Nile Table"; } @Override public boolean hasCustomName() { return false; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return entityplayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) <= 64; } @Override public void openInventory() {} @Override public void closeInventory() {} @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return true; } @Override public void readFromNBT(NBTTagCompound nbtTagCompound) { super.readFromNBT(nbtTagCompound); // Read in the ItemStacks in the inventory from NBT NBTTagList tagList = nbtTagCompound.getTagList("Items", blockMetadata); inventory = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = (NBTTagCompound) tagList.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if (slot >= 0 && slot < inventory.length) { inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } // Read in the Crafting Matrix from NBT NBTTagList craftingTag = nbtTagCompound.getTagList("CraftingMatrix", blockMetadata); craftMatrixInventory = new ItemStack[9]; //TODO: magic number for (int i = 0; i < craftingTag.tagCount(); ++i) { NBTTagCompound tagCompound = (NBTTagCompound) craftingTag.getCompoundTagAt(i); byte slot = tagCompound.getByte("Slot"); if (slot >= 0 && slot < craftMatrixInventory.length) { craftMatrixInventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound); } } // Read craftingResult from NBT NBTTagCompound tagCraftResult = nbtTagCompound.getCompoundTag("CraftingResult"); craftResult.setInventorySlotContents(0, ItemStack.loadItemStackFromNBT(tagCraftResult)); } @Override public void writeToNBT(NBTTagCompound nbtTagCompound) { super.writeToNBT(nbtTagCompound); // Write the ItemStacks in the inventory to NBT NBTTagList tagList = new NBTTagList(); for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) { if (inventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); inventory[currentIndex].writeToNBT(tagCompound); tagList.appendTag(tagCompound); } } nbtTagCompound.setTag("Items", tagList); // Write Crafting Matrix to NBT NBTTagList craftingTag = new NBTTagList(); for (int currentIndex = 0; currentIndex < craftMatrixInventory.length; ++currentIndex) { if (craftMatrixInventory[currentIndex] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) currentIndex); craftMatrixInventory[currentIndex].writeToNBT(tagCompound); craftingTag.appendTag(tagCompound); } } nbtTagCompound.setTag("CraftingMatrix", craftingTag); // Write craftingResult to NBT if (craftResult.getStackInSlot(0) != null) nbtTagCompound.setTag("CraftingResult", craftResult.getStackInSlot(0).writeToNBT(new NBTTagCompound())); } } Container public class ContainerNileTable extends Container implements ISlotChanged { private World worldObj; public TileEntityNileTable tileEntity; NileTabSlot FabSlot; private int posX; private int posY; private int posZ; /** The crafting matrix inventory (3x3). */ //container, width, length public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); private NileTabSlot fabTabSlot; public ContainerNileTable(TileEntityNileTable tileFabTable, InventoryPlayer playerInv, World world, int x, int y, int z) { worldObj = world; posX = x; posY = y; posZ = z; fabTabSlot = new NileTabSlot(playerInv.player, this.craftMatrix, tileFabTable.craftResult, 0, 124, 35); addSlotToContainer(fabTabSlot); int row; int col; tileEntity = tileFabTable; updateCraftingMatrix(); for (row = 0; row < 3; ++row) { for (col = 0; col < 3; ++col) { this.addSlotToContainer(new Slot(this.craftMatrix, col + row * 3, 30 + col * 18, 17 + row * 18)); } } for (row = 0; row < 3; ++row) { for (col = 0; col < 9; ++col) { this.addSlotToContainer(new Slot(playerInv, col + row * 9 + 9, 8 + col * 18, 84 + row * 18)); } } for (row = 0; row < 9; ++row) { this.addSlotToContainer(new Slot(playerInv, row, 8 + row * 18, 142)); } this.onCraftMatrixChanged(this.craftMatrix); } private void updateCraftingMatrix() { for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { craftMatrix.setInventorySlotContents(i, tileEntity.craftMatrixInventory[i]); } } @Override public void onContainerClosed(EntityPlayer par1EntityPlayer) { super.onContainerClosed(par1EntityPlayer); saveCraftingMatrix(); } private void saveCraftingMatrix() { for (int i = 0; i < craftMatrix.getSizeInventory(); i++) { tileEntity.craftMatrixInventory[i] = craftMatrix.getStackInSlot(i); } } @Override public void onCraftMatrixChanged(IInventory IInv) { tileEntity.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); } @Override public boolean canInteractWith(EntityPlayer entityPlayer) { return tileEntity.isUseableByPlayer(entityPlayer); } @Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int par2) { ItemStack itemstack = null; Slot slot = (Slot)this.inventorySlots.get(par2); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (par2 == 0) { if (!this.mergeItemStack(itemstack1, 10, 46, true)) { return null; } slot.onSlotChange(itemstack1, itemstack); } else if (par2 >= 10 && par2 < 37) { if (!this.mergeItemStack(itemstack1, 37, 46, false)) { return null; } } else if (par2 >= 37 && par2 < 46) { if (!this.mergeItemStack(itemstack1, 10, 37, false)) { return null; } } else if (!this.mergeItemStack(itemstack1, 10, 46, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } if (itemstack1.stackSize == itemstack.stackSize) { return null; } slot.onPickupFromSlot(entityPlayer, itemstack1); } return itemstack; } @Override public void onSlotChange(Slot slot, int id, ItemStack itemStack) { System.out.println("Plans changed"); } } Slot public class NileTabSlot extends SlotCrafting{ /** The craft matrix inventory linked to this result slot. */ private final IInventory craftMatrix; /** The player that is using the GUI where this slot resides. */ private EntityPlayer thePlayer; /** * The number of items that have been crafted so far. Gets passed to ItemStack.onCrafting before being reset. */ private int amountCrafted; public NileTabSlot(EntityPlayer par1EntityPlayer, IInventory par2IInventory, InventoryCrafting par3IInventory, int par4, int par5, int par6) { super(par1EntityPlayer, par3IInventory, par3IInventory, par4, par5, par6); this.thePlayer = par1EntityPlayer; this.craftMatrix = par2IInventory; } /** * Check if the stack is a valid item for this slot. Always true beside for the armor slots. */ @Override public boolean isItemValid(ItemStack par1ItemStack) { return false; } /** * Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new * stack. */ @Override public ItemStack decrStackSize(int par1) { if (this.getHasStack()) { this.amountCrafted += Math.min(par1, this.getStack().stackSize); } return super.decrStackSize(par1); } /** * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an * internal count then calls onCrafting(item). */ @Override protected void onCrafting(ItemStack par1ItemStack, int par2) { this.amountCrafted += par2; this.onCrafting(par1ItemStack); } /** * the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. */ @Override protected void onCrafting(ItemStack par1ItemStack) { par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.amountCrafted); this.amountCrafted = 0; if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.crafting_table)) { this.thePlayer.addStat(AchievementList.buildWorkBench, 1); } if (par1ItemStack.getItem() instanceof ItemPickaxe) { this.thePlayer.addStat(AchievementList.buildPickaxe, 1); } if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.furnace)) { this.thePlayer.addStat(AchievementList.buildFurnace, 1); } if (par1ItemStack.getItem() instanceof ItemHoe) { this.thePlayer.addStat(AchievementList.buildHoe, 1); } if (par1ItemStack.getItem() == Items.bread) { this.thePlayer.addStat(AchievementList.makeBread, 1); } if (par1ItemStack.getItem() == Items.cake) { this.thePlayer.addStat(AchievementList.bakeCake, 1); } if (par1ItemStack.getItem() instanceof ItemPickaxe && ((ItemPickaxe)par1ItemStack.getItem()).func_150913_i() != Item.ToolMaterial.WOOD) { this.thePlayer.addStat(AchievementList.buildBetterPickaxe, 1); } if (par1ItemStack.getItem() instanceof ItemSword) { this.thePlayer.addStat(AchievementList.buildSword, 1); } if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.enchanting_table)) { this.thePlayer.addStat(AchievementList.enchantments, 1); } if (par1ItemStack.getItem() == Item.getItemFromBlock(Blocks.bookshelf)) { this.thePlayer.addStat(AchievementList.bookcase, 1); } } @Override public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) { FMLCommonHandler.instance().firePlayerCraftingEvent(par1EntityPlayer, par2ItemStack, craftMatrix); this.onCrafting(par2ItemStack); for (int i = 0; i < this.craftMatrix.getSizeInventory(); ++i) { ItemStack itemstack1 = this.craftMatrix.getStackInSlot(i); if (itemstack1 != null) { this.craftMatrix.decrStackSize(i, 1); if (itemstack1.getItem().hasContainerItem(itemstack1)) { ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1); if (itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage()) { MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(thePlayer, itemstack2)); itemstack2 = null; } if (itemstack2 != null && (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1) || !this.thePlayer.inventory.addItemStackToInventory(itemstack2))) { if (this.craftMatrix.getStackInSlot(i) == null) { this.craftMatrix.setInventorySlotContents(i, itemstack2); } else { this.thePlayer.dropPlayerItemWithRandomChoice(itemstack2, false); } } } } } } } ItemRender public class ItemRendererNileTable implements IItemRenderer{ TileEntitySpecialRenderer render; private TileEntity entity; private ModelNileTable model; public ItemRendererNileTable(TileEntitySpecialRenderer render, TileEntity entity){ this.entity = entity; this.render = render; this.model = new ModelNileTable(); } @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { return true; } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { return true; } @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { this.render.renderTileEntityAt(this.entity, 0.0D, 0.0D, 0.0D, 0.0F); } } BlockRender public class RendererNileTable extends TileEntitySpecialRenderer{ private ModelNileTable model; private static final ResourceLocation texture = new ResourceLocation(ZeroQuest.modid + ":" + "textures/models/nileWorktable.png"); public RendererNileTable(){ this.model = new ModelNileTable(); } @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f, int p_180535_9_) { GL11.glPushMatrix(); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); GL11.glRotatef(0, 0F, 0F, 0F); GL11.glScalef(1.0F, -1.0F, -1.0F); this.bindTexture(texture); GL11.glPushMatrix(); model.renderModel(0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); } } Proxy TileEntitySpecialRenderer render = new RendererNileTable(); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityNileTable.class, render); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.nileWorktable), new ItemRendererNileTable(render, new TileEntityNileTable())); Im also getting errors from the TileEntity files and rendering files -
[1.8] [SOLVED] How to register Blocks, items and entites?
NovaViper replied to NovaViper's topic in Modder Support
Thanks! I hope there's a way for the bow textures -
[1.8] [SOLVED] How to register Blocks, items and entites?
NovaViper replied to NovaViper's topic in Modder Support
Hey how do I use that Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register method with blocks? it says it has to be a item. Also about the BlockPos, how do I use that in the following code below? public class CommonProxy implements IGuiHandler{ public static final int NileTable = 0; public static final int PetPack = 1; @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == NileTable) { TileEntity target = world.getTileEntity(x, y, z); if(!(target instanceof TileEntityNileTable)) return null; TileEntityNileTable tileNileTable = (TileEntityNileTable)target; ContainerNileTable tableContainer = new ContainerNileTable(tileNileTable, player.inventory, world, x, y, z); return tableContainer; } else if(ID == PetPack) { Entity target = player.worldObj.getEntityByID(x); if(!(target instanceof EntityCustomTameable)) { return null; } EntityCustomTameable entity = (EntityCustomTameable)target; ContainerPack packContainer = new ContainerPack(player.inventory, entity); return packContainer; } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if(ID == NileTable) { TileEntity target = world.getTileEntity(x, y, z); if(!(target instanceof TileEntityNileTable)) return null; TileEntityNileTable tileNileTable = (TileEntityNileTable)target; NileTableGui tableGui = new NileTableGui(player.inventory, tileNileTable, world, x, y, z); return tableGui; } else if(ID == PetPack) { Entity target = player.worldObj.getEntityByID(x); if(!(target instanceof EntityCustomTameable)) { return null; } EntityCustomTameable dog = (EntityCustomTameable)target; GuiPack packGui = new GuiPack(player.inventory, dog); return packGui; } return null; } --EDIT AFTER TESTING ITEMS-- Ok, so the items work but one problem.. the bow's textures aren't working, it doesn't display the pulling textures just like the normal bow -
[1.8] [SOLVED] How to register Blocks, items and entites?
NovaViper replied to NovaViper's topic in Modder Support
What the ItemRender for the projectile entities? It keeps asking for an ItemRenderer here is what I did so far RenderingRegistry.registerEntityRenderingHandler(EntityFlamingPoisonball.class, new RenderFPoisonball(Minecraft.getMinecraft().getRenderManager(), ModItems.FPoisonball)); RenderingRegistry.registerEntityRenderingHandler(EntityIceball.class, new RenderIceball(Minecraft.getMinecraft().getRenderManager(), Items.snowball)); RenderingRegistry.registerEntityRenderingHandler(EntityGrenade.class, new RenderGrenade(Minecraft.getMinecraft().getRenderManager(), ModItems.nileGrenade)); ---EDIT-- Nevermind, I figured it out. Thanks for the help! I'll post on here when I finish testing out the code -
[1.8] [SOLVED] How to register Blocks, items and entites?
NovaViper replied to NovaViper's topic in Modder Support
I got the json files for my items but they still appear as untextured blocks... not sure what to do. Here is my json file for the nile sword { "parent": "builtin/generated", "textures": { "layer0": "zero_quest:items/nileSword" }, "display": { "thirdperson": { "rotation": [ 0, 90, -35 ], "translation": [ 0, 1.25, -3.5 ], "scale": [ 0.85, 0.85, 0.85 ] }, "firstperson": { "rotation": [ 0, -135, 25 ], "translation": [ 0, 4, 2 ], "scale": [ 1.7, 1.7, 1.7 ] } } } And I still don't know how do to the block/item rendering (such as my custom model crafting table which I want it to be rendered as a 3D item like regular blocks). Also I can't seem to figure out how to render my entities and use my custom particles. -
[1.8] [SOLVED] How to register Blocks, items and entites?
NovaViper replied to NovaViper's topic in Modder Support
I have another question also, how do I use custom particles? I created some in the previous MC versions (mainly 1.7). I noticed that they now use EnumParticleTypes instead of just the strings. -
[1.8] [SOLVED] How to register Blocks, items and entites?
NovaViper replied to NovaViper's topic in Modder Support
How do I use the JSON files for textures? Also here is the current code for the entity rendering. public class ClientProxy extends CommonProxy{ public void registerRenderThings() { RenderingRegistry.registerEntityRenderingHandler(EntityZertum.class, new RenderZertum(new ModelZertum(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityRedZertum.class, new RenderRedZertum(new ModelRedZertum(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityDarkZertum.class, new RenderDarkZertum(new ModelDarkZertum(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityDestroZertum.class, new RenderDestroZertum(new ModelDestroZertum(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityJakan.class, new RenderJakan(new ModelJakan(), 1.0F)); RenderingRegistry.registerEntityRenderingHandler(EntityIceZertum.class, new RenderIceZertum(new ModelIceZertum(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityForisZertum.class, new RenderForisZertum(new ModelForisZertum(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityKurr.class, new RenderKurr(new ModelKurr(), 1.0F)); RenderingRegistry.registerEntityRenderingHandler(EntityKortor.class, new RenderKortor(new ModelKortor(), 1.0F)); RenderingRegistry.registerEntityRenderingHandler(EntityFlamingPoisonball.class, new RenderFPoisonball(1)); RenderingRegistry.registerEntityRenderingHandler(EntityIceball.class, new RenderIceball(Items.snowball, 1)); RenderingRegistry.registerEntityRenderingHandler(EntityGrenade.class, new RenderGrenade(ModItems.nileGrenade)); //TileEntitySpecialRenderer render = new RendererNileTable(); //ClientRegistry.bindTileEntitySpecialRenderer(TileEntityNileTable.class, render); //MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.nileWorktable), new ItemRendererNileTable(render, new TileEntityNileTable())); } } -
[1.8] [SOLVED] How to register Blocks, items and entites?
NovaViper posted a topic in Modder Support
Since everything changed with the 1.8 update, Im not sure how to register my entities' rendering files and with the blocks and items, I dont know how to give them unlocalized names (I used the setBlockName for blocks), and since the setTextureName method has changed, im not sure what to use for giving my items textures and names. Oh yeah, here is my github that it currently for 1.7. https://github.com/NViper21/ZeroQuest Also, since the IItemRenderer is now deprecated, how am I support to render my custom blocks into items just like the vanilla blocks? -
Thanks! Making the Gui open on the server side solved my problem! Not only that, now my mod doesn't take up as much memory as it used to
-
Thanks, I'll tell if everything goes well when I run the changes on the server (I had to setup eclipse again because I restored my computer to a certain point that made the files for starting up the client disappear.)
-
For instance, I have the AI classes and some variables that are to be used by all entities that extend to the class, EntityCustomTameable. Is it possible for me do to the same thing with the inventories? Such as but the drop inventory method in the EntityCustomTameable class so I don't have to place that same method into every entity file. But also but the Inventory variable inside the EntityCustomTameable class.
-
I also have a question, is it possible for me to have only one inventory class in the EntityCustomTameable main class for all of the entities extending to that class, and have those subclasses using the same Inventory class?
-
Oh, I'll remove it then since it's useless.
-
It looks like that the normal slot class does not go to the entity's inventory, the custom one does. I can see where the original developer was going with it.
-
I looked at the source code and my guess is that the SlotPack class is suppose to act the same way as the normal Slot class but it goes into the entity and finds the inventory variable instead of going into InventoryPlayer
-
I'm not exactly sure the purpose of that, but Im assuming it's for the custom number of slots. That part came from another mod calls Doggy Talents