Everything posted by FredTargaryen
-
[Solved]Problem with Event ordering[1.10] (How to properly update Capability for GUI on client)
This is completely off the top of my head but isn't there an event called something like GatherCapabilitiesEvent that fires after the AttachCapabilitiesEvents? Failing that what's wrong with EntityJoinWorldEvent? It's all right for me
-
What is the Vanilla Packet Receive event called?
Sometimes I wish there was one, but there isn't. You need to find some other workaround, maybe using your own packet.
-
[1.12][Solved] Variation in player movement speed
That works for every Entity I've tried except the player. The motion of the player seems to update on the client but not the server. I've tried sending packets with the player's motion but it's too slow for what I want
-
[1.12][Solved] Variation in player movement speed
From what I have read the most reliable way to get the player's motion on a server is to have some prevPos variables, and when the player updates obtain the motion by subtracting its position from the previous position. The code I've used for this is: protected Entity e; protected double prevPosX; protected double prevPosY; protected double prevPosZ; @SubscribeEvent(priority= EventPriority.HIGHEST) public void speedCheck(TickEvent.WorldTickEvent event) { if(event.phase == TickEvent.Phase.START) { double motionX = this.e.posX - this.prevPosX; double motionY = this.e.posY - this.prevPosY; double motionZ = this.e.posZ - this.prevPosZ; double distance = Math.sqrt(motionX * motionX + motionY * motionY + motionZ * motionZ); if (distance >= DataReference.MINIMUM_ENTITY_SPEED) { System.out.println(distance); } if (this.e.isDead) { MinecraftForge.EVENT_BUS.unregister(this); } this.prevPosX = this.e.posX; this.prevPosY = this.e.posY; this.prevPosZ = this.e.posZ; } } But the distance values that are printed out vary, even though they are printed out while the player is walking straight forward. Here's a sample: So the mode value is 0.4317180760788172 but I've seen speeds as high as 1.5 even while walking. Speeds can go lower than the above values as well. Even the value of 0.43 bothers me, because the wiki lists average walk speed as 4.3 metres per second. With 20 ticks to a second I assume the value I should be getting is 0.215. So where have I gone wrong? If I had to guess, it's because of not taking skipped ticks into account; in which case how can I get the number of ticks skipped to divide by that number? Thanks for reading.
-
[1.12.x] Change light hue, possible?
I would say make your mod require or be compatible with Albedo. The readme on that GitHub page tells you how to make it compatible.
-
[1.11.2] Using WorldSavedData
If writeToNBT is getting called then your registry will save at the right time.
-
[1.12] (How) can I process one type of packet before another?
I'm using the ClientTickEvent because I guessed that would be the earliest event fired, and I wanted to deal with MessageBreakerMovement before the server checks if the player position/motion is valid. I'm not using the server because from what I've read and tried, you can't get the player's motion reliably on the server. I'm doing the code every tick because if a tick is allowed to pass, the player will collide with the block even if the block is supposed to break before the player can collide with it. If there was a reliable way to get the motion from the server side (the way you can with entities, or a player on the client side), even just a way of handling player position packets immediately when they are received, I probably wouldn't have to send any extra packets at all...
-
[1.11.2] Using WorldSavedData
Don't remove it from all methods; just try putting it at the end of the method that updates your HashMap. Edit: Oh well if you can call markDirty on the MyWorldSavedData instance from the message handler, then I think we should see your code as it is now
-
[1.12] (How) can I process one type of packet before another?
Haha yep, but like I say I'm changing it later to take the entity movement and the server will decide which blocks to break. I appreciate even this could probably be exploited, but to a smaller extent and I don't know any better ways to accurately get players' motion values. But currently, could I get that block to break before the server processes any other packets from the client?
-
Make invisible entities appear in hitbox mode
By invisible do you mean the model has no cubes so can't be seen? In that case have you used setSize() in the constructor? That will set up a bounding box.
-
[1.11.2] Using WorldSavedData
Interesting that the MySavedWorldData constructor can take no parameters. Forge complains when I try that. What works for me is: Message sent from client -> Message received on Server -> onMessage calls a method in MySavedWorldData that updates your HashMap. markDirty(); should be placed at the end of that last method.
-
[1.12] (How) can I process one type of packet before another?
My aim was to handle the earliest event possible to have the best chance of sending MessageBreakerMovement before any player packets. Idk any events which occur earlier on the client than ClientTickEvent but I'll try. Awkwardly I need to iterate over all entities because some entities need to be able to break the blocks too. The event handler will get a rewrite without the iteration later though. Later on the packet will contain the motionX, motionY and motionZ of the player and the server will decide what blocks break from that. From what I've read I have to get those values from the client because there's no good way of getting player motion from the server side.
-
[1.12] (How) can I process one type of packet before another?
I have a custom packet that, when the player is moving towards a block, should break it before the player can collide with it. However, currently the player collides then the block breaks. In theory, when necessary I send a MessageBreakerMovement at the start of the client tick, which should break the block when received by the server, then the vanilla player packets are processed. So is there a way I can force the MessageBreakerMovement to be processed first? I'm guessing if the MessageBreakerMovement is sent first then it is processed first, so could I maybe force it to be sent first? Or am I thinking about this all totally wrong and is there a better way? Here is where I send the packet; I'm aware this is a pretty slow event handler: @SubscribeEvent(priority = EventPriority.HIGHEST) public void clientBreakCheck(TickEvent.ClientTickEvent event) { if(event.phase == TickEvent.Phase.START) { Iterator<Entity> i = this.entities.iterator(); boolean shouldBreak = false; while (!shouldBreak && i.hasNext()) { shouldBreak = this.shouldBreakNow(i.next()); } if (shouldBreak) { MessageBreakerMovement mbm = new MessageBreakerMovement(); mbm.blockx = this.pos.getX(); mbm.blocky = this.pos.getY(); mbm.blockz = this.pos.getZ(); PacketHandler.INSTANCE.sendToServer(mbm); } } } Here's the packet's onMessage: @Override public IMessage onMessage(final MessageBreakerMovement message, MessageContext ctx) { final IThreadListener serverWorld = ctx.getServerHandler().player.getServerWorld(); serverWorld.addScheduledTask(() -> { WorldServer castedServerWorld = (WorldServer)serverWorld; castedServerWorld.destroyBlock(new BlockPos(message.blockx, message.blocky, message.blockz), false); }); return null; } Thank you for reading.
-
[Stupid] Can I destroy a block before collisions are processed?
Never mind, everything's fine. Must have got confused!
-
[1.8+][Solved] Reasons for inside faces going dark when blocks are adjacent?
Well that was the reason but the JSON wasn't the problem. I'd forgotten to overwrite isOpaqueCube and isFullCube, and make both return false. Thanks!
-
[1.10.2][Solved] Entities spawning and dying rapidly when player is high up
It turns out the spawning and despawning is completely normal (looks super inefficient to me but there you go). The problem was that in my constructor I would register each object on the event bus, so so many event handlers would end up being called that the framerate would go down. So the takeaway is: only register on the event bus when you need to start listening for events, and unregister when you don't need to any more.
-
[Stupid] Can I destroy a block before collisions are processed?
I should have said movement instead of collisions. So it looks to me like when the server does one tick, it moves all the entities, then destroys all the blocks. I would like some blocks to be destroyed before the entities are moved. Is that possible without editing the source code? I tried destroying the blocks during the start phase of ServerTickEvent but that didn't seem to work. My specific example involves the player running through a glass wall. Currently they collide with the glass, stop, and then the glass breaks. I'd like the player to be able to break the glass and run through without losing any speed.
-
[Stupid] Can I destroy a block before collisions are processed?
Correct me if I'm wrong but this is what I gathered from looking at tick code. As far as I can tell, the server processes entity collisions with blocks before it removes blocks. For the purposes of my mod it would be really nice if I could have certain blocks destroyed before collisions are processed. Is it possible to make this happen without actually messing with the Minecraft source code? Thanks for reading.
-
[1.8+][Solved] Reasons for inside faces going dark when blocks are adjacent?
I thought that might be a/the reason, but the JSON for vanilla cauldrons and my custom cauldron both have ambientocclusion set to false, yet only the custom cauldron goes dark.
-
[1.8+][Solved] Reasons for inside faces going dark when blocks are adjacent?
A couple of my mods have some blocks that have faces which go very dark when opaque solid blocks like Netherrack are placed adjacent to them. For example, if I have a cauldron shaped block, and a block is placed one block to the north of it, the north-facing inside face will go dark. I also have a custom fire block where this only happens to the west-facing side! What are the reasons that the faces could be going dark like this? Thanks for reading.
-
[1.10.2][Solved] Entities spawning and dying rapidly when player is high up
I got the following bug report: I tried this out and got the same thing. I added a print statement to the entity constructor and setDead, and lots of my mobs were being created and quickly killed each second on client and server side when I flew above 180. As far as I know I haven't done anything out of the ordinary. I can show other code but here is the stuff which is probably relevant: Entity and spawn registration (EntityRocketSquid is the problem, and possibly EntityBabyRocketSquid which extends EntityRocketSquid) Config setup in PreInit EntityRocketSquid constructor If you want, you can see the code for yourself here. Where have I gone wrong? Thanks for reading. UPDATE: Rocket Squids had canDespawn returning true. The sea level is at about y=63, and y=180 is almost 128 blocks away, which is the distance required to despawn an entity if it can be despawned. So the immediate despawning is perfectly normal. So the question isn't why are they spawning and dying, but why so many of them are spawning.
-
[1.10.2] Block face too dark on one side
Haven't had any response so far; wondering if anyone here can help? Original topic: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/modification-development/2775330-one-face-of-block-is-too-dark Thanks for reading.
-
[1.9.4][Solved] Block not updating when world re-entered
I override writeToNBT and readFromNBT in the tile entity, and the data I need is definitely saved there. The issue is that updateTick isn't being called. What do you recommend instead? Just extending Block and implementing ITileEntityProvider?
-
[1.9.4][Solved] Block not updating when world re-entered
When I place my block it updates itself perfectly well, but when I leave and re-enter the world, updateTick doesn't get called any more. I'm using roughly the same code as I did in 1.7.10 when it was fine. Could anyone tell me what I've missed out please? Code if needed: EDIT: Solved by using scheduleBlockUpdate instead of scheduleUpdate. Thank you for your advice anyway!
-
Hiring a modder
Does this ever work and do modders ever make money from it?
IPS spam blocked by CleanTalk.