Jump to content

Thornack

Members
  • Posts

    629
  • Joined

  • Last visited

Everything posted by Thornack

  1. I have figured out my throwable entity problem where upon hitting a living entity it drops itself as an item (but I think I used a workaround where it despawns itself and spawns a new item (im not sure if thats exactly what is going on but I do suspect that it is)) All that was required to solve this was entityDropItem(new ItemStack(CommonProxy.itemBall), 0.0F); to be added to the onImpact method. I have also added functionality where if you miss the entity then the entity is set to dead and sends a coloured chat message to the thrower. I wish to animate this item after the Entity drops it. My model is constructed to have two halves and is a sphere made of over 150 cubes. I want the halves to rotate in different directions to simulate the ball "popping". I have been trying to figure out minecrafts animations and so far i only understand a little, I have been reading a bunch of stuff on this but havent had any luck. My model class is really really long so I have just posted in the rotation functions (to keep this post readable) where all of my models boxes are accounted for in these functions and the sphere renders properly midflight, on the ground, in inventory, in first and third person. The rotation functions in my Model Class 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); B1.render(f5); B2.render(f5); B3.render(f5); B4.render(f5); B5.render(f5); B6.render(f5); B7.render(f5); B8.render(f5); B9.render(f5); B10.render(f5); B11.render(f5); B12.render(f5); B13.render(f5); B14.render(f5); B15.render(f5); B16.render(f5); B17.render(f5); B18.render(f5); B19.render(f5); B20.render(f5); B21.render(f5); B22.render(f5); B23.render(f5); B24.render(f5); B25.render(f5); B26.render(f5); B27.render(f5); B28.render(f5); B29.render(f5); B30.render(f5); B31.render(f5); B32.render(f5); B33.render(f5); B34.render(f5); B35.render(f5); B36.render(f5); B37.render(f5); B38.render(f5); B39.render(f5); B40.render(f5); B41.render(f5); B42.render(f5); B43.render(f5); B44.render(f5); B45.render(f5); B46.render(f5); B47.render(f5); B48.render(f5); B49.render(f5); B50.render(f5); B51.render(f5); B52.render(f5); B53.render(f5); B54.render(f5); B55.render(f5); B56.render(f5); B57.render(f5); B58.render(f5); B59.render(f5); B60.render(f5); B61.render(f5); B62.render(f5); B63.render(f5); B64.render(f5); B65.render(f5); B66.render(f5); B67.render(f5); B68.render(f5); B69.render(f5); B70.render(f5); B71.render(f5); B72.render(f5); B73.render(f5); B74.render(f5); T1.render(f5); T2.render(f5); T3.render(f5); T4.render(f5); T5.render(f5); T6.render(f5); T7.render(f5); T8.render(f5); T9.render(f5); T10.render(f5); T11.render(f5); T12.render(f5); T13.render(f5); T14.render(f5); T15.render(f5); T16.render(f5); T17.render(f5); T18.render(f5); T19.render(f5); T20.render(f5); T21.render(f5); T22.render(f5); T23.render(f5); T24.render(f5); T25.render(f5); T26.render(f5); T27.render(f5); T28.render(f5); T29.render(f5); T30.render(f5); T31.render(f5); T32.render(f5); T33.render(f5); T34.render(f5); T35.render(f5); T36.render(f5); T37.render(f5); T38.render(f5); T39.render(f5); T40.render(f5); T41.render(f5); T42.render(f5); T43.render(f5); T44.render(f5); T45.render(f5); T46.render(f5); T47.render(f5); T48.render(f5); T49.render(f5); T50.render(f5); T51.render(f5); T52.render(f5); T53.render(f5); T54.render(f5); T55.render(f5); T56.render(f5); T57.render(f5); T58.render(f5); T59.render(f5); T60.render(f5); T61.render(f5); T62.render(f5); T63.render(f5); T64.render(f5); T65.render(f5); T66.render(f5); T67.render(f5); T68.render(f5); T69.render(f5); T70.render(f5); T71.render(f5); T72.render(f5); T73.render(f5); T74.render(f5); } private void setRotation(ModifiedModelRenderer 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) { float topRotateX = MathHelper.cos(f * 2F) * f1; RotationSet top = new RotationSet(Arrays.asList(this.T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45, T46, T47, T48, T49, T50, T51, T52, T53, T54, T55, T56, T57, T58, T59, T60, T61, T62, T63, T64, T65, T66, T67, T68, T69, T70, T71, T72, T73)); top.doRotation(0,topRotateX, 0); float bottomRotateX = MathHelper.cos(f * -1F) * f1; new RotationSet(Arrays.asList(this.B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, B14, B15, B16, B17, B18, B19, B20, B21, B22, B23, B24, B25, B26, B27, B28, B29, B30, B31, B32, B33, B34, B35, B36, B37, B38, B39, B40, B41, B42, B43, B44, B45, B46, B47, B48, B49, B50, B51, B52, B53, B54, B55, B56, B57, B58, B59, B60, B61, B62, B63, B64, B65, B66, B67, B68, B69, B70, B71, B72, B73)); top.doRotation(0,bottomRotateX, 0); } Entity Class package soccer.entity; import java.util.Iterator; import java.util.List; import java.util.Random; import soccer.CommonProxy; import soccer.calculations.CalcCapture; import soccer.model.ItemModelBall; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.command.ICommandSender; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityBlaze; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.client.C01PacketChatMessage; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.ChatComponentText; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.event.entity.player.PlayerEvent; public class EntityBall extends EntityThrowable { public EntityBall(World world) { super(world); this.setSize(0.5F, 0.5F); // hit-box size? } public EntityBall(World world, EntityLivingBase par2EntityLivingBase) { super(world, par2EntityLivingBase); this.motionX *= 0.75f; this.motionZ *= 0.75f; this.motionY *= 1f; } public EntityBall(World world, double x, double y, double z) { super(world, x, y, z); } public EntityBall(World world, EntityLiving entityLiving) { super(world, entityLiving); } /** * Called when this EntityThrowable hits a block or entity. */ @Override protected void onImpact(MovingObjectPosition movingItemPosition) { int BallMissed = 0; if (movingItemPosition.entityHit != null) { float thrownItemDamage = 0; captureCalcStarted = 1; movingItemPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), thrownItemDamage); entityDropItem(new ItemStack(CommonProxy.itemBall), 0.0F);//the float valuer makes the item bounce up (the higher the number the higher the bounce on impact) setDead(); } for (int i = 0; i < 8; ++i) { this.worldObj.spawnParticle("crit", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } // this if statement is required or it will keep updating forever and you'll end up with lots of leftover entities in the world if (!this.worldObj.isRemote) { ballMissed = 1; this.setDead(); } if (ballMissed ==1){ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You Missed The Player")); } } protected void entityInit() { }} I think I have to call setRotationAngles in my Entity Class but I am not sure how. I tried making an object of my model class and then calling the method but that didnt work. Any help will be greatly appreciated. ItemModelBall ball = new ItemModelBall(); ball.setRotationAngles(1f, 1f, 1f, 1f, 1f, 0f);
  2. My ultimate goal is to get the ball to have an animation for a movement and upon hitting an entity to engage the animation and land on the ground as an entity but I am figuring things out in steps.
  3. I Have a 3D ball and I want to get it to land on the ground when it hits an entity, so far I have figured out that inside the onImpact method there is the if statement if (movingItemPosition.entityHit != null) {} and if I call a method inside it then it is only executed if the bounding box of my throwable ball comes into contact with the bounding box of the entity. I wish to use this to cause the thrown ball to land on the ground, whereas if the entity is missed and the ball hits the ground then it is set to dead. (this part I have down where the if statement if (!this.worldObj.isRemote) { this.setDead();} takes care of that part. However I am not sure how to get the same thrown ball to land on the ground when it hits an entity. Here is my full onImpact Method. Any Ideas on how to achieve this?
  4. @TheGreyGhost I am not sure how to add the breakpoint where you suggested as that would involve editing minecraft base classes wouldnt it? Im not sure how to go about doing that I know that you can find the class files in Referenced Libraries then forgeSrc-1.7.2-10.12.1.1060.jar and I have found the BlockFire.class file in package net.minecraft.block and the method you mentioned but I cannot edit it for some reason. When I try to put my System.out.println("UP"); into the method I simply cannot type anything or paste anything in. My Campfire block class looks like this
  5. When I replace my .isFireSource method in public class BlockCampfire extends BlockContainer { public BlockCampfire(Material material) { super(material); this.setHardness(3.0f); this.setResistance(5.0f); this.setStepSound(soundTypeGrass); this.setBlockBounds(0F, 0F, 0F,1F,0.1F,1F); this.setCreativeTab(CommonProxy.custommodTab); this.setLightLevel(10F); } public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving) { int l = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 2.5D) & 3; world.setBlockMetadataWithNotify(i, j, k, l, 2); System.out.println(l); } @Override public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) { if (this == CommonProxy.blockCampfire && side == UP) { return true; } return true;} public boolean isOpaqueCube(){ return false; } public boolean renderAsNormalBlock(){ return false; } @Override public int getRenderType(){ int id; id = RenderingRegistry.getNextAvailableRenderId(); return id; } @Override public TileEntity createNewTileEntity(World world, int var2) { return new TileEntityCampfire(); } @Override public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack itemStack) { int facingDirection = MathHelper.floor_double((double) ((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3; int newFacing = 0; if (facingDirection == 0) { newFacing = 2; } if (facingDirection == 1) { newFacing = 5; } if (facingDirection == 2) { newFacing = 3; } if (facingDirection == 3) { newFacing = 4; } TileEntity tileEntity = world.getTileEntity(i, j, k); if (tileEntity != null && tileEntity instanceof TileEntityCampfire) { TileEntityCampfire tileEntityCampfire = (TileEntityCampfire) tileEntity; tileEntityCampfire.setFacingDirection(newFacing); world.markBlockForUpdate(i, j, k); } } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(CustomMod.modid + ":" + this.getUnlocalizedName().substring(5)); } } with the code you suggested and then I try to light the flint nothing happens, and when I added System.out.println("UP"); to the method you suggested (above the return statement) nothing is displayed in the console suggesting that the method isnt being called
  6. Yes I seem to have run into the same problem, I want to try and find a method that doesn't edit Minecraft base classes. So far no luck still. I have been looking at all of the methods you mentioned and haven't found out much yet, its still an unsolved problem.
  7. I am stumped by this, if anyone has any examples or is willing to help I will be continuing to try to figure this out
  8. I created that method in my block class and I am overriding it. public class BlockCampfire extends BlockContainer { public BlockCampfire(Material material) { super(material); this.setHardness(3.0f); this.setResistance(5.0f); this.setStepSound(soundTypeGrass); this.setBlockBounds(0F, 0F, 0F,1F,0.1F,1F); this.setCreativeTab(CommonProxy.custommodTab); this.setLightLevel(10F); } public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving entityliving) { int l = MathHelper.floor_double((double)((entityliving.rotationYaw * 4F) / 360F) + 2.5D) & 3; world.setBlockMetadataWithNotify(i, j, k, l, 2); System.out.println(l); } @Override public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) { if (this == CommonProxy.blockCampfire && side == UP) { return true; } return true;} public boolean isOpaqueCube(){ return false; } public boolean renderAsNormalBlock(){ return false; } @Override public int getRenderType(){ int id; id = RenderingRegistry.getNextAvailableRenderId(); return id; } @Override public TileEntity createNewTileEntity(World world, int var2) { return new TileEntityCampfire(); } @Override public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack itemStack) { int facingDirection = MathHelper.floor_double((double) ((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3; int newFacing = 0; if (facingDirection == 0) { newFacing = 2; } if (facingDirection == 1) { newFacing = 5; } if (facingDirection == 2) { newFacing = 3; } if (facingDirection == 3) { newFacing = 4; } TileEntity tileEntity = world.getTileEntity(i, j, k); if (tileEntity != null && tileEntity instanceof TileEntityCampfire) { TileEntityCampfire tileEntityCampfire = (TileEntityCampfire) tileEntity; tileEntityCampfire.setFacingDirection(newFacing); world.markBlockForUpdate(i, j, k); } } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon(CustomMod.modid + ":" + this.getUnlocalizedName().substring(5)); } } But it looks as if it isn't being called
  9. I have found the method you pointed me to but I am unsure as to how to add it to my block @Override public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) { if (this == Blocks.netherrack && side == UP) { return true; } if ((world.provider instanceof WorldProviderEnd) && this == Blocks.bedrock && side == UP) { return true; } return false; } When I add this.isFireSource(world, x, y, z, UP); to my constructor I get errors that tell me the variables are undefined
  10. I have added a 3D Custom Rendered Block that has a custom model called BlockCampfire. I have been trying to make it flammable and havent found any way to do so. Does anyone know how I could achieve this functionality. My block is directionally placeable and It shows up in game properly with the appropriate hitbox. I have been trying to make this block ignitable like netherrack is so that it burns until it is put out. But the netherrack class doesnt implement anything to do with fire. I havent been able to dig up any documentation on how the infinite burning works for netherrack and am confused as to how to implement flammability to a block so that it may be ignited in game by the flint and steel. Here are my classes that render the Block
  11. I fixed it, thank you for pointing out my error
  12. I wish to add a direction to my block based off of which way the Player is facing (like the furnace). My block is a BlockPC and I have it rendering fine with custom model and upon being placed it is placed to face the player. However upon placing a new block of the same type while facing a different direction, all other blocks of this type that were previously placed in the world rotate to face the new direction rather than remaining in their originally placed positions. I am not sure how to fix this. Here is my code:
  13. I have used the snowball code to base my item off of it and thats how I got it to throw but it doesnt do it properly and Im not sure hwy
  14. I have made a custom 3D ball and wish to render it in my inventory. It is an item that throws like the snowball but in the ItemRenderBall.java class the following switch statement wants to return an entity but when I replace null with (Entity) data[1] I get an out of bounds error. problem code switch (type) { case INVENTORY: GL11.glPushMatrix(); // rotates the item and translates the item GL11.glRotatef(0, 0, 0, 1); GL11.glRotatef(0, 0, 1, 0); GL11.glRotatef(180, 1, 0, 0); GL11.glTranslatef(0f, 0f, 0f); GL11.glScalef(0.5F, 0.5F, 0.5F); Minecraft.getMinecraft().renderEngine.bindTexture(this.itemBallTexture); // renders the item modelBall.render(null, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0225f); GL11.glPopMatrix(); default: break; } related mod classes pertaining to this item
  15. I added EntityRegistry.registerModEntity(EntityBall.class, "Ball", 49, this, 80, 3, true); to the main mod class and now it renders while thrown but its really weird. When I go to 0,0,0 it throws normally but when I move away from that location ( when I move up the balls trajectory is towards the sky in an arc. If I move the character left the balls trajectory is towards the right and if I move right the balls trajectory is left. and If I turn the character the trajectory its all weird.
  16. I have made a few changes to the code, and am now trying to get it to render in the inventory before I tackle the in flight rendering again since I couldnt get it to work and need a break, it isnt rendering while being thrown and I have no idea why because when I replaced everything with the egg it worked fine. This is the updated renderer that handles case ENTITY, case EQUIPPED_FIRST_PERSON, and now case INVENTORY
  17. I tried your suggestion and it didnt work even when I went to 0,0,0 nothing shows up the ball doesnt seem to throw nor render
  18. Part 1 is [solved] But it doesnt seem to be thrown and doesnt render in flight I replaced this line private static final ResourceLocation itemBallTexture = new ResourceLocation(Soccer.modid+"/assets/soccer/textures/items/Ball3D.png"); with this line private static final ResourceLocation itemBallTexture = new ResourceLocation("soccer","textures/items/ball3D.png"); in the ItemRenderBall renderer. working code
  19. Yes I have "assets.soccer.textures.items" and inside there I have "Ball3D.png" and these are located in the "src/main/resources" folder where the rest of my mod is located in the "src/main/java folder"
  20. I havent had any luck yet with this so any ideas/suggestions are very much appreciated I will post all the working code once this is solved and might write a tutorial after on how to add 3D throwable items
  21. I ran gradlew setupDecompWorkspace in command prompt and gradlew eclipse and I can see the Referenced Libraries but they are all obfuscated is there a way to change this with the new forge
  22. my textures are organized as follows in my modding folder I have a forge folder and inside that folder the path is src/soccer/assets/soccer/textures/items/Ball3D.png I have tried inputting and I still get the purple.
  23. I added the changes you suggester and now the ball renders but with a purple colour and doesn't render during flight at all (when before it rendered weird with a bunch of textures overlayed on it where some parts were clear and others weren't and didn't render during flight either).
  24. I have now upgraded my code to 1.7.2 and alot of stuff broke. The renderers included. I am not sure how to get the textures for my ball in 1.7.2. It renders in my hand in 3D and as a dropped item but the texture is missing and it does not render when thrown. I have managed to get rid of all of the errors by commenting out
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.