Jump to content

HappyKiller1O1

Members
  • Posts

    581
  • Joined

  • Last visited

Everything posted by HappyKiller1O1

  1. Most of my update has been in LivingUpdate, will switch over here soon. My only problem is creating a timer within an update event. Seems the timer will always be reset, which is not what someone wants at all. Even though this is basic java, could you give an example on how I would start with a timer in a tick event?
  2. Thank you both, I realized I was on peaceful when testing, so the hunger bar wouldn't deplete. I do have a question about the implementation though: I use it in the #LivingUpdateEvent, and was wondering how I could do this with my weight variable. Should I create a timer that is affected by the player's current weight? Or do some math in order to determine how much exhaustion to add with the weight?
  3. I understand the base of how to acquire the player's FoodStats, but I would like to know how it works. Does FoodStats#addExaustion() affect it's drain speed? Or is there a better way of doing this? I simple example would be very helpful.
  4. Could you please show your full block, and TileEntity class.
  5. Alright, would they put that annotation over their Item or Block class? (I created the weight limit mod , so they have to implement my interface in order to provide items with weight).
  6. One more question though, what if someone implements my API classes, and someone using that mod does not have my mod loaded? Wouldn't that crash the game?
  7. Silly me, just had to create the file outside of eclipse. Thanks!
  8. I tried creating that, but it says you can't use a dash in your class name.
  9. Are you sure it's a .info file? Wouldn't you need to do a .java to use the @API annotation?
  10. So, I understand that an API is just some classes for other mods to interact with mine. But, do I simply create a package for my API classes, compile my mod with it, and have people use the source of my mod for the API? Do I have to compile an API separately? Do I have to define a class or package as an API? I just want to make sure people won't have errors when attempting to interact with my mod.
  11. I've looked through quite a few classes, and I can't seem to find a way to get the amplifier of the potion active on a player. I thought Potion#getEffectivness would be it, but it always returns one (for strength at least). Is there some way to get the amplifier of the active potion on a player?
  12. Very weird error, and it never happened during my compiling a few days ago. It failed with this log: C:\Users\Happy Pappy\Desktop\Mod Directory\Minecraft\Weight Limit 1.8.8>gradlew build This set of MCP mappings was designed for MC 1.8. Use at your own peril. ################################################# ForgeGradle 2.1-SNAPSHOT-8267717 https://github.com/MinecraftForge/ForgeGradle ################################################# Powered by MCP unknown http://modcoderpack.com by: Searge, ProfMobius, Fesh0r, R4wk, ZeuX, IngisKahn, bspkrs ################################################# :deobfCompileDummyTask :deobfProvidedDummyTask :sourceApiJava UP-TO-DATE :compileApiJava UP-TO-DATE :processApiResources UP-TO-DATE :apiClasses UP-TO-DATE :sourceMainJava :compileJava FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compileJava'. > Could not find tools.jar * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 11.172 secs C:\Users\Happy Pappy\Desktop\Mod Directory\Minecraft\Weight Limit 1.8.8> Any ideas?
  13. So, my model that I am rendering on the player's back works quite fine. But, my only problem is that when the player sneaks, my model doesn't rotate. Here's an example: Standing with model: Sneaking with model: Here's my model code: package com.happykiller.weightlimit.render.models; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelSmallBackpack extends ModelBiped { ModelRenderer BackpackBase; ModelRenderer BackpackSecondary; ModelRenderer MainButton; ModelRenderer PocketLeft; ModelRenderer PocketRight; ModelRenderer PocketFront; ModelRenderer FrontButton; public ModelSmallBackpack(float scale) { super(scale, 0.0F, 64, 32); BackpackBase = new ModelRenderer(this, 0, 0); BackpackBase.addBox(-3F, 1F, 2F, 6, 8, 2); BackpackBase.setRotationPoint(0F, 0F, 0F); BackpackBase.setTextureSize(64, 32); BackpackBase.mirror = true; setRotation(BackpackBase, 0F, 0F, 0F); BackpackSecondary = new ModelRenderer(this, 16, 0); BackpackSecondary.addBox(-2F, 3F, 3.5F, 4, 6, 1); BackpackSecondary.setRotationPoint(0F, 0F, 0F); BackpackSecondary.setTextureSize(64, 32); BackpackSecondary.mirror = true; setRotation(BackpackSecondary, 0F, 0F, 0F); MainButton = new ModelRenderer(this, 0, 10); MainButton.addBox(-1F, 1.5F, 3.2F, 2, 1, 1); MainButton.setRotationPoint(0F, 0F, 0F); MainButton.setTextureSize(64, 32); MainButton.mirror = true; setRotation(MainButton, 0F, 0F, 0F); PocketLeft = new ModelRenderer(this, 0, 12); PocketLeft.addBox(2.5F, 6F, 1.8F, 1, 2, 2); PocketLeft.setRotationPoint(0F, 0F, 0F); PocketLeft.setTextureSize(64, 32); PocketLeft.mirror = true; setRotation(PocketLeft, 0F, 0F, 0F); PocketRight = new ModelRenderer(this, 6, 12); PocketRight.addBox(-3.533333F, 6F, 1.8F, 1, 2, 2); PocketRight.setRotationPoint(0F, 0F, 0F); PocketRight.setTextureSize(64, 32); PocketRight.mirror = true; setRotation(PocketRight, 0F, 0F, 0F); PocketFront = new ModelRenderer(this, 0, 16); PocketFront.addBox(-1F, 6F, 4F, 2, 2, 1); PocketFront.setRotationPoint(0F, 0F, 0F); PocketFront.setTextureSize(64, 32); PocketFront.mirror = true; setRotation(PocketFront, 0F, 0F, 0F); FrontButton = new ModelRenderer(this, 0, 10); FrontButton.addBox(-1F, 5F, 3.8F, 2, 1, 1); FrontButton.setRotationPoint(0F, 0F, 0F); FrontButton.setTextureSize(64, 32); FrontButton.mirror = true; setRotation(FrontButton, 0F, 0F, 0F); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { setRotationAngles(f, f1, f2, f3, f4, f5, entity); BackpackBase.render(f5); BackpackSecondary.render(f5); MainButton.render(f5); PocketLeft.render(f5); PocketRight.render(f5); PocketFront.render(f5); FrontButton.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); //Is this the problem? copyModelAngles(this.bipedBody, BackpackBase); copyModelAngles(this.bipedBody, BackpackSecondary); copyModelAngles(this.bipedBody, MainButton); copyModelAngles(this.bipedBody, PocketLeft); copyModelAngles(this.bipedBody, PocketRight); copyModelAngles(this.bipedBody, PocketFront); copyModelAngles(this.bipedBody, FrontButton); } } I thought #copyModelAngles() would do it, but it doesn't help. Am I calling it incorrectly?
  14. This is very simple with SharedMonsterAttributes. One of the things you MUST understand is that nothing is impossible in programming. No matter what, there is always a way to accomplish anything you want. Here is my way of modifying the player speed. You can replace the things you'd need to, in order to update the player health. @SubscribeEvent public void onLivingUpdate(LivingUpdateEvent event) { if(event.entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)event.entity; ExtendedPlayer props = ExtendedPlayer.get(player); if(WLConfig.slowPlayerWhenOverEncumbered) { if(props != null) { final UUID speedModifierUUID = UUID.fromString("db1f6a32-af5e-11e5-bf7f-feff819cdc9f"); AttributeModifier speedModifier = (new AttributeModifier(speedModifierUUID, "weightSpeedModifier", -0.4, 2)).setSaved(false); IAttributeInstance iai = player.getEntityAttribute(SharedMonsterAttributes.movementSpeed); if(props.isOverEncumbered() && !player.capabilities.isCreativeMode && !player.isSpectator()) { if(iai.getModifier(speedModifierUUID) == null) { iai.applyModifier(speedModifier); } player.setSprinting(false); if(player.worldObj.isRemote) { Minecraft mc = Minecraft.getMinecraft(); KeyBinding.setKeyBindState(mc.gameSettings.keyBindSprint.getKeyCode(), false); } }else { if(iai.getModifier(speedModifierUUID) != null) { iai.removeModifier(speedModifier); } } } } } The UUID is required, I use the random UUID generator here. I don't have time as of now to explain all the workings, so I hope you can figure out some of this on your own. The onLivingUpdate goes in your event handler, and you must subscribe to it.
  15. That's the one. If it doesn't work, look up how to use the #getFields() in the ISidedInventory.
  16. The new model system is quite tricky at first. Take a look at this video , it should help you a bit. For blocks, check out this one .
  17. I believe, from looking at the furnace, you need to use the #getFields() and #setFields() for easy client to server sync. I haven't tried it, but it seems the furnace TileEntity uses it.
  18. I had this same problem. Simply call the super for #writeToNBT, and #readFromNBT in your TileEntity class.
  19. After having some trial and error, I discovered the Enchantment Table uses a TileEntitySpecialRenderer to render it's model on the block. I've switched to this, and it works nearly flawlessly. Thanks for the help!
  20. It seems that was the case. I extended Entity, and followed some render options used in the RenderEnderCrystal to get it working. My only problem now seems to be that the hit box is WAY below the actual entity: If I can figure out how to fix this, I think I'll be good. Here are the new classes: Rendering (I think the problem lies here, but I'm unsure): package com.happykiller.weightlimit.client.renderer; import com.happykiller.weightlimit.entites.EntityUpgradeCore; import com.happykiller.weightlimit.main.ModReference; import com.happykiller.weightlimit.render.models.ModelUpgradeCore; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelEnderCrystal; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderEntity; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.item.EntityEnderCrystal; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderEntityUCore extends Render<EntityUpgradeCore> { private static final ResourceLocation rl = new ResourceLocation(ModReference.MOD_RL + "textures/entity/entity_upgrade_core.png"); private ModelBase model = new ModelUpgradeCore(); public RenderEntityUCore(RenderManager renderManagerIn) { super(renderManagerIn); this.shadowSize = 0.5F; } public void doRender(EntityUpgradeCore entity, double x, double y, double z, float entityYaw, float partialTicks) { float f = (float)entity.innerRotation + partialTicks; GlStateManager.pushMatrix(); GlStateManager.translate((float)x, (float)y, (float)z); this.bindTexture(rl); float f1 = MathHelper.sin(f * 0.2F) / 2.0F + 0.5F; f1 = f1 * f1 + f1; this.model.render(entity, 0.0F, f * 3.0F, f1 * 0.2F, 0.0F, 0.0F, 0.0625F); GlStateManager.popMatrix(); super.doRender(entity, x, y, z, entityYaw, partialTicks); } protected ResourceLocation getEntityTexture(EntityUpgradeCore entity) { return rl; } } Entity: package com.happykiller.weightlimit.entites; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntityUpgradeCore extends Entity { public int innerRotation; public EntityUpgradeCore(World world) { super(world); this.preventEntitySpawning = true; this.setSize(0.1F, 0.1F); this.innerRotation = this.rand.nextInt(100000); } @SideOnly(Side.CLIENT) //Most likely will be removed, only here because of the EntityEnderCrystal public EntityUpgradeCore(World worldIn, double posX, double posY, double posZ) { this(worldIn); this.setPosition(posX, posY, posZ); } protected boolean canTriggerWalking() { return false; } public boolean canBeCollidedWith() { return true; } public void onUpdate() { super.onUpdate(); innerRotation++; } protected void entityInit() {} protected void readEntityFromNBT(NBTTagCompound tagCompund) { } protected void writeEntityToNBT(NBTTagCompound tagCompound) { } } Spawning: public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { super.onBlockAdded(worldIn, pos, state); Entity entity = new EntityUpgradeCore(worldIn); entity.setLocationAndAngles(pos.getX(), pos.getY(), pos.getZ(), 0.0F, 0.0F); if(!worldIn.isRemote) worldIn.spawnEntityInWorld(entity); }
  21. Alright, I was simply registering my Entity wrong. My only problems now consist of it still being able to fall, and entities able to collide with it. I need it to float in the middle of my block, and this is not possible when it still can fall.
  22. I seem to get no errors now, but my entity isn't rendering. I called the super on #onUpdate, and #entityInit. I also removed the server check before spawning the entity, to see if that would fix it. Sadly, it had no affect.
  23. How would I go about fixing this? Don't have too much experience with entities.
  24. Here it is: Caused by: java.lang.NullPointerException at net.minecraft.entity.DataWatcher.updateObject(DataWatcher.java:150) ~[DataWatcher.class:?] at net.minecraft.entity.EntityLivingBase.setHealth(EntityLivingBase.java:824) ~[EntityLivingBase.class:?] at net.minecraft.entity.EntityLivingBase.<init>(EntityLivingBase.java:164) ~[EntityLivingBase.class:?] at net.minecraft.entity.EntityLiving.<init>(EntityLiving.java:74) ~[EntityLiving.class:?] at com.happykiller.weightlimit.entites.EntityUpgradeCore.<init>(EntityUpgradeCore.java:13) ~[EntityUpgradeCore.class:?] at com.happykiller.weightlimit.blocks.BlockUpgradeStation.onBlockAdded(BlockUpgradeStation.java:47) ~[blockUpgradeStation.class:?] at net.minecraft.world.chunk.Chunk.setBlockState(Chunk.java:729) ~[Chunk.class:?] at net.minecraft.world.World.setBlockState(World.java:375) ~[World.class:?] at net.minecraft.item.ItemBlock.placeBlockAt(ItemBlock.java:192) ~[itemBlock.class:?] at net.minecraft.item.ItemBlock.onItemUse(ItemBlock.java:66) ~[itemBlock.class:?] at net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(ForgeHooks.java:720) ~[ForgeHooks.class:?] at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:143) ~[itemStack.class:?] at net.minecraft.server.management.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:481) ~[itemInWorldManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:617) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:70) ~[C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:10) ~[C08PacketPlayerBlockPlacement.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_66] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_66] at net.minecraft.util.Util.func_181617_a(Util.java:22) ~[util.class:?] ... 5 more It doesn't crash the game, and line 13 is my main constructor's (the one with just a world param) super.
×
×
  • Create New...

Important Information

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