mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-14 01:04:16 +00:00
Fix accidental double toggle of ring of loki (#20)
This commit is contained in:
1 parent
54f79398b1
commit
09ccf50fde
3 files changed
+13
-8
No files matched your search
@@ -141,8 +141,8 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void toggleMode(ItemStack stack) {
|
||||
stack.stackTagCompound.setBoolean(TAG_MODE, !isRingEnabled(stack));
|
||||
public static void setMode(ItemStack stack, boolean state) {
|
||||
stack.stackTagCompound.setBoolean(TAG_MODE, state);
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void renderHUDNotification(){
|
||||
|
||||
@@ -10,7 +10,6 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class PacketLokiToggle implements IMessage, IMessageHandler<PacketLokiToggle, IMessage> {
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
// not needed
|
||||
@@ -26,8 +25,11 @@ public class PacketLokiToggle implements IMessage, IMessageHandler<PacketLokiTog
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
final ItemStack aRing = ItemLokiRing.getLokiRing(player);
|
||||
if (aRing != null) {
|
||||
ItemLokiRing.toggleMode(aRing);
|
||||
PacketHandler.INSTANCE.sendTo(new PacketLokiToggleAck(), player);
|
||||
boolean ringState = !ItemLokiRing.isRingEnabled(aRing);
|
||||
ItemLokiRing.setMode(aRing, ringState);
|
||||
PacketLokiToggleAck ackMessage = new PacketLokiToggleAck();
|
||||
ackMessage.state = ringState;
|
||||
PacketHandler.INSTANCE.sendTo(ackMessage, player);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -13,14 +14,16 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketLokiToggleAck implements IMessage, IMessageHandler<PacketLokiToggleAck, IMessage> {
|
||||
|
||||
public boolean state;
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
// not needed
|
||||
state = byteBuf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf byteBuf) {
|
||||
// not needed
|
||||
byteBuf.writeBoolean(state);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -29,7 +32,7 @@ public class PacketLokiToggleAck implements IMessage, IMessageHandler<PacketLoki
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
final ItemStack aRing = ItemLokiRing.getLokiRing(mc.thePlayer) ;
|
||||
if (aRing != null) {
|
||||
ItemLokiRing.toggleMode(aRing);
|
||||
ItemLokiRing.setMode(aRing, message.state);
|
||||
ItemLokiRing.renderHUDNotification();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user