Jump to content

Recommended Posts

Posted

Hey me and some others are working on a mod that gives armor weight! We are currently having a problem or two and was wondering if someone could point us in the right direction!

 

Here's the source codes:

 

This ticks with the player and checks if the player is wearing armor:

 

  Reveal hidden contents

 

 

This is wear we check armor and assign values and such. It's really rough as we are just trying to get it to work before optimizing and prettying it up, sorry.

 

  Reveal hidden contents

 

 

Here's the error, lol:

 

  Reveal hidden contents

 

Posted
  On 3/10/2015 at 1:24 AM, Alex_Richard said:

Hey me and some others are working on a mod that gives armor weight! We are currently having a problem or two and was wondering if someone could point us in the right direction!

 

Here's the source codes:

 

This ticks with the player and checks if the player is wearing armor:

http://pastebin.com/5t6iZ6Tr

 

This is wear we check armor and assign values and such. It's really rough as we are just trying to get it to work before optimizing and prettying it up, sorry.

http://pastebin.com/iXNMyYex

 

Here's the error, lol:

http://pastebin.com/KsHNXfHS

The hell? Don't use reflection. Use player.capabilities...

Maker of the Craft++ mod.

Posted

Hmm, I was told that could cause problems down the road when handling server side and such.

 

EDIT: Ok well that seems to have solved that error, any idea on why we're getting an error on ticking the player?

 

EDIT2: appears to be saying player is null, but i cant figure out why...

 

A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at MinecraftRPGOverhaul.events.ModEventHandler.onEntityUpdate(ModEventHandler.java:17)
at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_ModEventHandler_onEntityUpdate_PlayerTickEvent.invoke(.dynamic)
at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)
at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138)
at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:345)
at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:259)

-- Player being ticked --
Details:
Entity Type: null (net.minecraft.entity.player.EntityPlayerMP)
Entity ID: 193
Entity Name: Player163
Entity's Exact location: -118.09, 72.00, 251.67
Entity's Block location: World: (-119,72,251), Chunk: (at 9,4,11 in -8,15; contains blocks -128,0,240 to -113,255,255), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)
Entity's Momentum: 0.00, -0.08, 0.00
Stacktrace:
at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:330)
at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:329)
at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37)
at net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook.processPacket(C03PacketPlayer.java:271)
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241)

-- Ticking connection --
Details:
Connection: net.minecraft.network.NetworkManager@5cb42fdf
Stacktrace:
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)

Posted

BAD:

private EntityPlayer player;

 

GOOD:

event.player / event.entity

 

EDIT: Also you design is kinda "static". I'd suggest making weigh values in NBT. Always keep in mind that items and block are singletons and there is only one instance per game (client/server).

 

EDIT 2

For speed look at potion and AttributeModifier. I'd stay with base value of speed and if you are wearing something heavy add slowing Modifier with value of x in every beggining of a tick for one tick. Many ways to do that actually. You could just add PotionEffect ;p

  Quote

1.7.10 is no longer supported by forge, you are on your own.

Posted

Hey, I've done a little looking around on AttributeModifier, and i don't quite understand how to use it. I'm commonly seeing these three lines pop up in descriptions:

 

AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
                attributeinstance.func_111124_b(attributemodifier);
                attributeinstance.func_111121_a(new AttributeModifier(attributemodifier.func_111167_a(), this.getName() + " " + par3, this.func_111183_a(par3, attributemodifier), attributemodifier.func_111169_c()));

 

Also what are all the func_#####? I know what they /are/ but not what specific ones are, or where to find out what they all are, it always takes me forever to dig around enough to figure it out.  Also bonus points if you can explain why the hell functions are called numbers and not by a name that told people what they do, like what is the advantage to that????

Posted

Methods/Functions are called by numbers because when minecraft is compiled it also gets obfuscated, people then find out what these functions do and put it into the MCP Bot to help make it readable. I'm not sure if there's a benefit to the code being obfuscated other than preventing people from easily reading it.

 

func_111124_b -> removeModifier

func_111121_a -> applyModifier

func_111167_a -> getID

func_111183_a -> getAttributeModifierAmount

func_111169_c -> getOperation

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



×
×
  • Create New...

Important Information

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