
big_red_frog
Members-
Posts
26 -
Joined
-
Last visited
Everything posted by big_red_frog
-
[1.8] Just wondering something about DataWatcher
big_red_frog replied to HappyKiller1O1's topic in Modder Support
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. -
[1.8] setAlwaysRenderNameTag, always and other questions
big_red_frog replied to big_red_frog's topic in Modder Support
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(); } -
[1.8] setAlwaysRenderNameTag, always and other questions
big_red_frog replied to big_red_frog's topic in Modder Support
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. -
[1.8] setAlwaysRenderNameTag, always and other questions
big_red_frog replied to big_red_frog's topic in Modder Support
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 :-( -
[1.8] setAlwaysRenderNameTag, always and other questions
big_red_frog replied to big_red_frog's topic in Modder Support
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... -
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.
-
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.
-
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...
-
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...
-
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 ))
-
[1.8] Run code on final exit before world save
big_red_frog replied to big_red_frog's topic in Modder Support
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. -
[1.8] Force player look from server side
big_red_frog replied to big_red_frog's topic in Modder Support
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. -
[1.8] Run code on final exit before world save
big_red_frog replied to big_red_frog's topic in Modder Support
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. -
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?
-
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();
-
[1.8] Force player look from server side
big_red_frog replied to big_red_frog's topic in Modder Support
So I have this working by doing some ugly things. I am using the OnServerTick to ensure I get a decent 20 per second tick rate. I pull the first player out of the server player list for my purposes. Then I am still using the following call to force an update of the player back to the client when I have otherwise set the rotationPitch and rotationYaw player.setPositionAndUpdate(...) Its ugly and makes no sense, but proves it is possible to get player pitch/yaw updated from the server to client without implementing my own packets ( which I have yet to learn ) I still for the life of me cannot see how the setPositionAndUpdate(...) function call achieves it... -
[1.8] Force player look from server side
big_red_frog replied to big_red_frog's topic in Modder Support
another oddity of note. If I do the following where all details are in my LookVec class then the update is forced to the client side from the server, and everything is looking in the right direction. The problem is this forces me to update the player position as well, and locks the player view in place, which is not my intent, I want to be forcing the look, but still allowing movement. So something in the function setPositionAndUpdate causes an update of the player data to the client, but I can't see any such code, when I chain through the call tree, and of course I want to trigger this without the Position bit... event.player.rotationYaw = lookVec.yaw; event.player.rotationPitch = lookVec.pitch; event.player.setPositionAndUpdate( lookVec.fromPos.getX(), lookVec.fromPos.getY(), lookVec.fromPos.getZ()); -
[1.8] Force player look from server side
big_red_frog replied to big_red_frog's topic in Modder Support
I appreciate the response, but that thread isn't particularly definitive. Now I have gone through the pain of upgrading to the latest forge, I had to tear everything down and back up, to be on the updated gradlew, along with a change in behaviour for the way shading was behaving, I feel I should try and work out what has actually been added for camera control. Something I have never really understood is where is the definitive reference for what is in forge. We have the change notes referencing the improved camera control, but I have no idea where to go, to start reading about the details. I also have to get into the server / client packet mechanism. Any recommendation on where to start reading for that? -
[1.8] Force player look from server side
big_red_frog replied to big_red_frog's topic in Modder Support
I note this recent update references new hooks for player camera. I will keep digging. http://www.minecraftforge.net/forum/index.php/topic,34955.msg184321.html#msg184321 -
[1.8] Force player look from server side
big_red_frog replied to big_red_frog's topic in Modder Support
I just thought, I know there must be real player data in the event, as when I move the player, I can see the yaw and pitch calculations changing correctly, however, setting the yaw and pitch makes no difference, that remains my issue. Assuming now it is because I am on server side, so looking to understand how I can force the update across to the client, or better yet, have an independent view port. -
Hi All, Firstly, huge thanks to this forum, my few questions have found a way forward quickly with the support from the community. So now my next one... What I actually want it to build a view manager that moves the rendered view to preprogrammed positions, fixed and also related to entities, so could be looking from a tower to the ground, could be tracking an entity, or could be attached to an entity and tracking another. It is not clear to me if view ports independent of the player can actually be achieved, so I attempted to manage the player data to get my end effect. If there is a methodology for player independent views, then PLEASE point me in the general direction and all the following becomes mute. I have all my vector math in place, and can calculate yaw and pitch between two arbitrary BlockPos values, one the player, the other something to track. However, my mod effectively runs on the server, so when I call inside my tick handler event.player.rotationYaw = (float)yaw; event.player.rotationPitch = (float)pitch; Nothing happens. I suspect this could be for two reasons. 1) the tick event is only being cast to a PlayerTickEvent and doesn't actually know who the payer is ( I will continue to scratch at this ) or 2) changing these values on the server for a player has no impact on the client. As always any help greatly appreciated...
-
[Help] Prevent player from falling off mount
big_red_frog replied to big_red_frog's topic in Modder Support
Thanks all will overridevthat function! -
[Help] Prevent player from falling off mount
big_red_frog replied to big_red_frog's topic in Modder Support
Thanks for any and all help. It is great to know that there are a limited number of scenarios to knock a player off, this gives me a clue. When this has occured, there is no player at keyboard so can't be that. Its a derived pig class with removed AI, so it is not the minecart scenario. Its not an untamed horse. The pig is a super pig and invulnerable. No other mods. I have been digging around, is there another scenario that could cause this, due to the ridden pig moving through standing water? By standing water, I mean a pool of water left on a level surface as the whole area that previously supported the water has been removed and it falls down and forms an active pool. -
Hi all, For various reasons I want to prevent a player from being knocked off a pig by random mobs. Is there a simple way to do this? I am always running in creative mode for my purposes, but random interactions spoil my intent... ( At least I think that is the problem, I have not as yet caught the condition that causes the player to be off the pig )
-
[Solved] Problem running final mod due to lib dependancies
big_red_frog replied to big_red_frog's topic in ForgeGradle
Huge thanks, once I had realized that shading was a built in behavior rather than a plugin, and managed to interpret the instructions ( and get them at the end of my gradlew.build file ) then everything just works. I had been down many dead ends before this. My head thanks you! It was getting bruised with all the wall banging it had been doing!