Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

big_red_frog

Members
  • Posts

    26
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    Generally Confused

big_red_frog's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I had assumed that the addObject also pushed the value to the client from the server, however, it is possible it only reserves it, in this case as a type int. Certainly you only want to do this once during initialisation. In this tutorial, it recommends you do the addObject in an event handler for Entity construction. http://www.minecraftforge.net/wiki/Datawatcher You may need to actually populate it with values and trigger an update from server to client with something like the following in the relevant points in your code where the value of weight changes. DataWatcher dw = player.getDataWatcher(); dw.updateObject( WEIGHT_WATCHER, newWeightValue ); I use this quite a lot right now, and I know it to be good for value propagation from server to client, having manually added extensive debug during shake out. Noting as others have commented to stay compatible with other mods, using this on player entities is not recommended, however, in my use case, I am using it with a custom mob entity so assuming I am safe.
  2. Ended up overriding RenderLivingLabel(...) Could of used drawSplitString(...) from FontRenderer, but I didn't want to use a fixed field width so did something slightly different as below. /** * Modified Renders an entity's name above its head */ @Override protected void renderLivingLabel(Entity entity, String nameTag, double entX, double entY, double entZ, int maxDist) { double d3 = entity.getDistanceSqToEntity(this.renderManager.livingPlayer); if (d3 <= (double)(maxDist * maxDist)) { List<String> strings = Arrays.asList(nameTag.split("\n")); Collections.reverse(strings); double offsetY = entity.height + 0.5; for ( String line : strings ) { // System.out.print( "render:" + line + ":\n"); renderText( line, entX, entY + offsetY, entZ ); offsetY += 0.3; } } } private void renderText( String text, double x, double y, double z ) { int result = 0; FontRenderer fontrenderer = this.getFontRendererFromRenderManager(); float f = 1.6F; float f1 = 0.016666668F * f; GlStateManager.pushMatrix(); GlStateManager.translate((float)x, (float)y, (float)z); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GlStateManager.scale(-f1, -f1, f1); GlStateManager.disableLighting(); GlStateManager.depthMask(false); GlStateManager.disableDepth(); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); GlStateManager.disableTexture2D(); worldrenderer.startDrawingQuads(); int j = fontrenderer.getStringWidth(text) / 2; worldrenderer.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); worldrenderer.addVertex((double)(-j - 1), -1.0, 0.0D); worldrenderer.addVertex((double)(-j - 1), 8.0, 0.0D); worldrenderer.addVertex((double)(j + 1), 8.0, 0.0D); worldrenderer.addVertex((double)(j + 1), -1.0, 0.0D); tessellator.draw(); GlStateManager.enableTexture2D(); fontrenderer.drawString(text, -fontrenderer.getStringWidth(text) / 2, 0, 553648127); GlStateManager.enableDepth(); GlStateManager.depthMask(true); fontrenderer.drawString(text, -fontrenderer.getStringWidth(text) / 2, 0, -1); GlStateManager.enableLighting(); GlStateManager.disableBlend(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.popMatrix(); }
  3. Confirmed that the nameTag follows the player entity orientation for render plane :-( So I have had to reintroduce forcing the player rotation to get reliable nameTag rendering. Worse the yaw value for the player entity is 180 degrees offset to the camera yaw. // this is for the player event.entity.rotationYaw = ( lookVec.yaw + 180 ) % 360; event.entity.rotationPitch = lookVec.pitch; // this is for the camera event.pitch = lookVec.pitch; event.yaw = lookVec.yaw; Meanwhile I have working code. If anyone knows how to get multiline text here, then please flag, though I suspect I need to work out how to override the entire render function :-( Not somewhere I have so far dug, but needs must.
  4. ugh. My cunning plan is falling apart. I use the event CameraSetup to trap when the camera is being configured and change the event yaw and pitch, so I can happily position the camera without teleporting my player viewer. This is something I see people advising against on here regularly ( teleporting to change viewpoint ). OnCameraSetupEvent( CameraSetup event) ... event.pitch = firstRobotEntity.entity.cameraVec.pitch; event.yaw = firstRobotEntity.entity.cameraVec.yaw; However, it is clear that the renderer for the nameTag uses the player pitch and yaw rather than the camera pitch and yaw to decide on render plane, so if you are actually looking behind the player you can't see the name tag due to normals, or if your player is looking off at 45 degrees, the nameTag's are very twisted :-(
  5. So in answer to some of my question, I managed to make sense of this thread. http://www.minecraftforge.net/forum/index.php/topic,28027.0.html So I had to add to my entity code @Override @SideOnly(Side.CLIENT) public boolean getAlwaysRenderNameTagForRender() { return getAlwaysRenderNameTag(); } Anyone know why this function from EntityLivingBase otherwise returns false? Seems odd not to actually use the AlwaysRender parameter as implemented. Still wondering how I can go multiline...
  6. Hi All, After digging around with dataWatcher, I found that most info I wanted was already in there, or could be leveraged for my purposes. I can leverage my new working dataWatcher usage later, but for now I am looking at the nameTag functionality. Specifically I want to render string information above my extended entities. So I can use setAlwaysRenderNameTag( true ) and setCustomNameTag( myString ) But unfortunately it only seems to trigger the text string render, when they are pointed at, how do I make the text always render ( at least from a certain range ) Secondly, I was hoping for multi line text. I couldn't get away with '\n' it renders as an inline 'lf' character. Any known ways to achieve this? Thanks for the timely help this community always offers up.
  7. I believe dotproduct and crossproduct are vector applied to vector, not scalar to vector I don't see a "multiply" is it present in your version? if so, what version are you in.
  8. While I am scratching around in here, am I going mad, or does Entity.getVectorForRotation(float pitch, float yaw) take parameters in degrees but Vec3.rotateYaw(float yaw) take parameters in radians Ouch...
  9. Wow, that was fast. Do I need to do casting into Vec3 at the end, or will forge functions take a Vector3d as a parameter transparently. Happy to stare at examples, if there are any...
  10. I continue to have fun modding in minecraft. If I have two Vec3 instances, and I want to find the midpoint between them, then I find myself doing a lot of manual math. In theory, it should be vec2 - vec1 = vecDiff midVec = vec1 + ( vecDiff * scalar_of_0.5 ) I can't see an elegant way to do this scalar multiplication on the Vec3 class, and end up with the following. Vec3 diffVec = ent2Vec.subtract( ent1Vec ); Vec3 halfVec = new Vec3( diffVec.xCoord / 2, diffVec.yCoord / 2, diffVec.zCoord / 2 ); Vec3 midPoint = ent1Vec.add( halfVec ); Am I missing the obvious? Is there a cleaner way to say something like this made up function below? halfBetween = betweenVec.scalar( 0.5 ) So I could get to Vec3 midPoint = entVec1.add( entVec2.substract( entVec1 ).scalar( 0.5 ))
  11. To flush out changes to the world blocks driven by realtime data from an external source. Worst case I could persist the undelying data and flush on reload, but that feels wrong, I dont really want to persist that data just for post load cleanup.
  12. I have now implemented based around CameraSetup event, which does the job very nicely, far smoother, and no ugly side effects. MinecraftForge.EVENT_BUS.register( new HandleCameraSetupEvent()); public class HandleCameraSetupEvent { @SubscribeEvent public void OnCameraSetupEvent( CameraSetup event) { ... event.pitch = lookVec.pitch; event.yaw = lookVec.yaw; } I have no idea how I have avoided having to make this work between server and client though, I haven't implemented any packet code, but everything is interlocked nicely !?! Will continue to dig around and understand more along the way.
  13. Actually I might be out of luck here. If the world save's pre-emptively when you go to the menu, I can't do things in that transition as I don't want to unnecessarily remove blocks when you pause. Then modifying the block content on unload, will not actually cause the result to be saved, as the world already is and the system just exits :-( So I think I will leave it for now, and maybe come back to it, when I understand the general lifecycle better.
  14. Hi All, When the server is going to shut down as the player has left, and this is a local game, I want to call a method in one of my classes to ensure that the world gets certain blocks removed / modified. They come from live external data and are added and removed in real time. So a user coming back hours later presently sees blocks that did not get removed in the normal lifecycle, but instead got saved. If I can call a method pre save, on exit, then I will be able to flush out all the blocks that I do not want to be present hours later. Where would I be able to call such a method from?
  15. I have a SuperPig that has a lobotomy so it doesn't wander off and do unwanted things, no doubt for a similar reason to yourself. To achieve this I kill the AI post creation with the following, I should really add it into the Entities constructor. // kill the entities AI entity.tasks.taskEntries.clear(); entity.targetTasks.taskEntries.clear();
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.