-
Recently Browsing
- No registered users viewing this page.
-
Posts
-
By ElTotisPro50 · Posted
It works now, thanks /*Synchronization to the client*/ @Nullable @Override public Packet<ClientGamePacketListener> getUpdatePacket() { return ClientboundBlockEntityDataPacket.create(this); } @Override public CompoundTag getUpdateTag() { return this.saveWithoutMetadata(); } @Override public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) { super.onDataPacket(net, pkt); load(pkt.getTag()); } @Override public void handleUpdateTag(CompoundTag tag) { super.handleUpdateTag(tag); } -
Please do not create a new thread, what's your issue with the debug.log.
-
By DiegoA111234 · Posted
ok, apparently the the reply option can not handle the debug log so I am going to make a new topic -
The inventory is only sent when you right click a block as part of showing the screen. If you want data to always be available you need to tell minecraft how to do this. BlockEntity already has some infrastructure for this, but its default logic does nothing - as will overriding the methods and just calling super() like you have. For reference look at something like BeaconBlockEntity which sends data to the client so it can for example draw the beam correctly. 1) getUpdatePacket() says how to create your network packet, by default this returns null so nothing happens. You need to change this to actually do something, e.g. the beacon does @Override public ClientboundBlockEntityDataPacket getUpdatePacket() { return ClientboundBlockEntityDataPacket.create(this); } 2) The above logic calls back to your getUpdateTag() to actually get the data. By default this just returns an empty CompundTag. The beacon changes it to use the same logic as the data saved to disk. @Override public CompoundTag getUpdateTag() { return this.saveWithoutMetadata(); } 3) When the data arrives on the client it will call onDataPacket() - the default behaviour for this is to call load() NOTE: After your block entity is initially loaded and sent to the client, additional packets will only be sent when the block is marked as "dirty". This is the same call that needs to be made to make sure your changed data is saved to disk. You can do this by either by calling setChanged on your BlockEntity or by calling Level.blockEntityChanged(). You can see BeaconMenu uses the second method in updateEffects().
-
Thanks mate, i found out what was wrong, i didnt put the right forge to load. Thank u!
-
-
Topics
-
Who's Online (See full list)
Recommended Posts
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.