Jump to content

Recommended Posts

Posted

I can't seem to find any tutorials or threads on how I should use attributes to add traits to players, so how would I do it? The only things on EntityPlayer related to attributes seem to be getters. I gather I should probably be using AttributeModifier somehow, but at the same time there is a whole list of IAtributes in SharedMonsterAttributes. My end goal is to use these to change the players attack speed, max health, and movement speed.

So is there any good resources I can use to figure out what I need to do?

My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.

Posted

If you want to modify the values of existing attributes on entities that aren't your own, use attribute modifiers. The wiki has an explanation of attributes and modifiers here.

 

If you want to store custom data on entities that aren't your own, use capabilities.

 

I have a capability that manages an attribute modifier for

SharedMonsterAttributes.MAX_HEALTH

here: API, implementation.

 

It's also used by the following classes:

  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/command/CommandMaxHealthBase.java]CommandMaxHealthBase[/url]


  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/command/CommandMaxHealthAdd.java]CommandMaxHealthAdd[/url]


  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/command/CommandMaxHealthGet.java]CommandMaxHealthGet[/url]


  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/command/CommandMaxHealthSet.java]CommandMaxHealthSet[/url]


  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/block/BlockMaxHealthGetter.java]BlockMaxHealthGetter[/url]


  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/block/BlockMaxHealthSetter.java]BlockMaxHealthSetter[/url]


  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/item/ItemMaxHealthGetter.java]ItemMaxHealthGetter[/url]


  • [url=https://github.com/Choonster/TestMod3/blob/f2476600a276d8a95280078e61049b709ba90466/src/main/java/choonster/testmod3/item/ItemMaxHealthSetter.java]ItemMaxHealthSetter[/url]

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

If you want to add information to a player, use a capability, you can read up on it here: http://mcforge.readthedocs.io/en/latest/datastorage/capabilities/

Yes I have already used capabilities on players to do a different function in my mod, but I'm asking how to actually change the max health or whatever else of a player.

If you want to modify the values of existing attributes on entities that aren't your own, use attribute modifiers. The wiki has an explanation of attributes and modifiers here.

 

If you want to store custom data on entities that aren't your own, use capabilities.

 

I have a capability that manages an attribute modifier for

SharedMonsterAttributes.MAX_HEALTH

here: API, implementation.

 

It's also used by the following classes:

Wow thank you so much for the examples, that's awesome you have a whole mod just for helping people on these forums.

Also I had seen that wiki page that you linked, because I actually found a different thread where you had linked that same page before and I went to it. Although it does explain what attributes are, it doesn't really say how to use them for my purposes.

edit: Jesus the more I read through this the less I feel like I know. I'm slowing catching on though... Slowly.

My IGN is TheUnderTaker11, but when I tried to sign up for this site it would not send the email... So yea now I have to use this account.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • You would have better results asking a more specific question. What have you done? What exactly do you need help with? Please also read the FAQ regarding posting logs.
    • Hi, this is my second post with the same content as no one answered this and it's been a long time since I made the last post, I want to make a client-only mod, everything is ok, but when I use shaders, none of the textures rendered in RenderLevelStageEvent nor the crow entity model are rendered, I want them to be visible, because it's a horror themed mod I've already tried it with different shaders, but it didn't work with any of them and I really want to add support for shaders Here is how i render the crow model in the CrowEntityRenderer<CrowEntity>, by the time i use this method, i know is not the right method but i don't think this is the cause of the problem, the renderType i'm using is entityCutout @Override public void render(CrowEntity p_entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { super.render(p_entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); ClientEventHandler.getClient().crow.renderToBuffer(poseStack, bufferSource.getBuffer(ClientEventHandler.getClient().crow .renderType(TEXTURE)), packedLight, OverlayTexture.NO_OVERLAY, Utils.rgb(255, 255, 255)); } Here renderLevelStage @Override public void renderWorld(RenderLevelStageEvent e) { horrorEvents.draw(e); } Here is how i render every event public void draw(RenderLevelStageEvent e) { for (HorrorEvent event : currentHorrorEvents) { event.tick(e.getPartialTick()); event.draw(e); } } Here is how i render the crow model on the event @Override public void draw(RenderLevelStageEvent e) { if(e.getStage() == RenderLevelStageEvent.Stage.AFTER_ENTITIES) { float arcProgress = getArcProgress(0.25f); int alpha = (int) Mth.lerp(arcProgress, 0, 255); int packedLight = LevelRenderer.getLightColor(Minecraft.getInstance().level, blockPos); VertexConsumer builder = ClientEventHandler.bufferSource.getBuffer(crow); Crow<CreepyBirdHorrorEvent> model = ClientEventHandler .getClient().crow; model.setupAnim(this); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, packedLight, OverlayTexture.NO_OVERLAY, alpha); builder = ClientEventHandler.bufferSource.getBuffer(eyes); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, 15728880, OverlayTexture.NO_OVERLAY, alpha); } } How i render the model public static void renderModelInWorld(Model model, Vector3f pos, Vector3f offset, Camera camera, PoseStack matrix, VertexConsumer builder, int light, int overlay, int alpha) { matrix.pushPose(); Vec3 cameraPos = camera.getPosition(); double finalX = pos.x - cameraPos.x + offset.x; double finalY = pos.y - cameraPos.y + offset.y; double finalZ = pos.z - cameraPos.z + offset.z; matrix.pushPose(); matrix.translate(finalX, finalY, finalZ); matrix.mulPose(Axis.XP.rotationDegrees(180f)); model.renderToBuffer(matrix, builder, light, overlay, Utils .rgba(255, 255, 255, alpha)); matrix.popPose(); matrix.popPose(); } Thanks in advance
    • Same issue - I have no idea
    • I am trying to develop a modpack for me and my friends to use on our server. Does anyone know how to develop a modpack for a server or could they help take a look at my modpack to potentially help at all?
    • un server de armas realista.  
  • Topics

×
×
  • Create New...

Important Information

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