feat: Implement Arcane Lock synchronization packet handling. Fixes #900 GeckoLib incompat
This commit is contained in:
@@ -181,6 +181,8 @@ public class CommonProxy {
|
|||||||
|
|
||||||
public void handleBombExplosionPacket(PacketBombExplosion.Message message){}
|
public void handleBombExplosionPacket(PacketBombExplosion.Message message){}
|
||||||
|
|
||||||
|
public void handleArcaneLockSyncPacket(PacketSyncArcaneLock.Message message){}
|
||||||
|
|
||||||
// SECTION Misc
|
// SECTION Misc
|
||||||
// ===============================================================================================================
|
// ===============================================================================================================
|
||||||
|
|
||||||
|
|||||||
@@ -717,6 +717,20 @@ public class ClientProxy extends CommonProxy {
|
|||||||
}else Wizardry.logger.warn("Received a PacketConquerShrine, but there was no shrine core at the position sent");
|
}else Wizardry.logger.warn("Received a PacketConquerShrine, but there was no shrine core at the position sent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleArcaneLockSyncPacket(PacketSyncArcaneLock.Message message){
|
||||||
|
if(Minecraft.getMinecraft().world != null){
|
||||||
|
TileEntity tileentity = Minecraft.getMinecraft().world.getTileEntity(message.pos);
|
||||||
|
if(tileentity != null){
|
||||||
|
if(message.locked){
|
||||||
|
tileentity.getTileData().setUniqueId(electroblob.wizardry.spell.ArcaneLock.NBT_KEY, message.owner);
|
||||||
|
}else{
|
||||||
|
electroblob.wizardry.util.NBTExtras.removeUniqueId(tileentity.getTileData(), electroblob.wizardry.spell.ArcaneLock.NBT_KEY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleBombExplosionPacket(PacketBombExplosion.Message message){
|
public void handleBombExplosionPacket(PacketBombExplosion.Message message){
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,12 @@ public class RenderArcaneLock {
|
|||||||
|
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
|
GlStateManager.enableDepth();
|
||||||
|
GlStateManager.depthMask(true);
|
||||||
|
GlStateManager.disableCull();
|
||||||
lighting = GL11.glIsEnabled(GL11.GL_LIGHTING);
|
lighting = GL11.glIsEnabled(GL11.GL_LIGHTING);
|
||||||
GlStateManager.disableLighting();
|
GlStateManager.disableLighting();
|
||||||
|
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
||||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
@@ -90,6 +94,7 @@ public class RenderArcaneLock {
|
|||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
|
GlStateManager.enableCull();
|
||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.enableTexture2D();
|
||||||
if(lighting){
|
if(lighting){
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package electroblob.wizardry.packet;
|
||||||
|
|
||||||
|
import electroblob.wizardry.Wizardry;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||||
|
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>[Server -> Client]</b> This packet is sent when a container is locked or unlocked by Arcane Lock to update clients.
|
||||||
|
*/
|
||||||
|
public class PacketSyncArcaneLock implements IMessageHandler<PacketSyncArcaneLock.Message, IMessage> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IMessage onMessage(Message message, MessageContext ctx){
|
||||||
|
|
||||||
|
if(ctx.side.isClient()){
|
||||||
|
net.minecraft.client.Minecraft.getMinecraft().addScheduledTask(() -> Wizardry.proxy.handleArcaneLockSyncPacket(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Message implements IMessage {
|
||||||
|
|
||||||
|
public BlockPos pos;
|
||||||
|
public boolean locked;
|
||||||
|
public UUID owner;
|
||||||
|
|
||||||
|
public Message(){}
|
||||||
|
|
||||||
|
public Message(BlockPos pos, boolean locked, @Nullable UUID owner){
|
||||||
|
this.pos = pos;
|
||||||
|
this.locked = locked;
|
||||||
|
this.owner = owner != null ? owner : new UUID(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fromBytes(ByteBuf buf){
|
||||||
|
this.pos = BlockPos.fromLong(buf.readLong());
|
||||||
|
this.locked = buf.readBoolean();
|
||||||
|
this.owner = new UUID(buf.readLong(), buf.readLong());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBytes(ByteBuf buf){
|
||||||
|
buf.writeLong(pos.toLong());
|
||||||
|
buf.writeBoolean(locked);
|
||||||
|
buf.writeLong(owner.getMostSignificantBits());
|
||||||
|
buf.writeLong(owner.getLeastSignificantBits());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,6 +36,7 @@ public class WizardryPacketHandler {
|
|||||||
registerMessage(PacketRequestDonationPerks.class, PacketRequestDonationPerks.Message.class);
|
registerMessage(PacketRequestDonationPerks.class, PacketRequestDonationPerks.Message.class);
|
||||||
registerMessage(PacketSyncDonationPerks.class, PacketSyncDonationPerks.Message.class);
|
registerMessage(PacketSyncDonationPerks.class, PacketSyncDonationPerks.Message.class);
|
||||||
registerMessage(PacketBombExplosion.class, PacketBombExplosion.Message.class);
|
registerMessage(PacketBombExplosion.class, PacketBombExplosion.Message.class);
|
||||||
|
registerMessage(PacketSyncArcaneLock.class, PacketSyncArcaneLock.Message.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int nextPacketId = 0;
|
private static int nextPacketId = 0;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package electroblob.wizardry.spell;
|
|||||||
|
|
||||||
import electroblob.wizardry.Wizardry;
|
import electroblob.wizardry.Wizardry;
|
||||||
import electroblob.wizardry.item.SpellActions;
|
import electroblob.wizardry.item.SpellActions;
|
||||||
|
import electroblob.wizardry.packet.PacketSyncArcaneLock;
|
||||||
|
import electroblob.wizardry.packet.WizardryPacketHandler;
|
||||||
import electroblob.wizardry.util.*;
|
import electroblob.wizardry.util.*;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
@@ -74,12 +76,14 @@ public class ArcaneLock extends SpellRay {
|
|||||||
if(world.getPlayerEntityByUUID(tileentity.getTileData().getUniqueId(NBT_KEY)) == player){
|
if(world.getPlayerEntityByUUID(tileentity.getTileData().getUniqueId(NBT_KEY)) == player){
|
||||||
NBTExtras.removeUniqueId(tileentity.getTileData(), NBT_KEY);
|
NBTExtras.removeUniqueId(tileentity.getTileData(), NBT_KEY);
|
||||||
world.markAndNotifyBlock(pos, null, world.getBlockState(pos), world.getBlockState(pos), 3);
|
world.markAndNotifyBlock(pos, null, world.getBlockState(pos), world.getBlockState(pos), 3);
|
||||||
|
WizardryPacketHandler.net.sendToDimension(new PacketSyncArcaneLock.Message(pos, false, null), world.provider.getDimension());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
// Locking
|
// Locking
|
||||||
tileentity.getTileData().setUniqueId(NBT_KEY, player.getUniqueID());
|
tileentity.getTileData().setUniqueId(NBT_KEY, player.getUniqueID());
|
||||||
world.markAndNotifyBlock(pos, null, world.getBlockState(pos), world.getBlockState(pos), 3);
|
world.markAndNotifyBlock(pos, null, world.getBlockState(pos), world.getBlockState(pos), 3);
|
||||||
|
WizardryPacketHandler.net.sendToDimension(new PacketSyncArcaneLock.Message(pos, true, player.getUniqueID()), world.provider.getDimension());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user