Skip to content

Commit

Permalink
Fix render desync with flowerpots
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMiner committed Jul 28, 2019
1 parent 15bbf66 commit 07403ac
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
Expand Up @@ -26,6 +26,9 @@ public void setup() {

// milk cooldown
registerPacketClient(MilkablePacket.class);

// generic block update
registerPacketClient(RenderBlockUpdatePacket.class);
}

public static void sendToAll(AbstractPacket packet) {
Expand Down
@@ -0,0 +1,39 @@
package knightminer.inspirations.common.network;

import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.util.math.BlockPos;
import slimeknights.mantle.network.AbstractPacketThreadsafe;

public class RenderBlockUpdatePacket extends AbstractPacketThreadsafe {
public BlockPos pos;

public RenderBlockUpdatePacket() {}

public RenderBlockUpdatePacket(BlockPos pos) {
this.pos = pos;
}

@Override
public void handleClientSafe(NetHandlerPlayClient netHandler) {
Minecraft.getMinecraft().renderGlobal.notifyBlockUpdate(null, pos, null, null, 0);
}

@Override
public void handleServerSafe(NetHandlerPlayServer netHandler) {
// only send to clients
throw new UnsupportedOperationException("Clientside only");
}

@Override
public void fromBytes(ByteBuf buf) {
this.pos = readPos(buf);
}

@Override
public void toBytes(ByteBuf buf) {
writePos(pos, buf);
}
}
@@ -1,8 +1,8 @@
package knightminer.inspirations.tweaks.block;

import javax.annotation.Nonnull;

import knightminer.inspirations.common.Config;
import knightminer.inspirations.common.network.InspirationsNetwork;
import knightminer.inspirations.common.network.RenderBlockUpdatePacket;
import knightminer.inspirations.library.InspirationsRegistry;
import knightminer.inspirations.library.util.TextureBlockUtil;
import net.minecraft.block.Block;
Expand All @@ -29,6 +29,8 @@
import slimeknights.mantle.client.ModelHelper;
import slimeknights.mantle.property.PropertyString;

import javax.annotation.Nonnull;

public class BlockBetterFlowerPot extends BlockFlowerPot {

public static final PropertyBool EXTRA = PropertyBool.create("extra");
Expand Down Expand Up @@ -83,6 +85,7 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En

flowerPot.markDirty();
world.notifyBlockUpdate(pos, state, state, 3);
InspirationsNetwork.sendToClients(world, pos, new RenderBlockUpdatePacket(pos));
return true;
}

Expand Down

0 comments on commit 07403ac

Please sign in to comment.