mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-12 00:07:37 +00:00
sync with server
This commit is contained in:
1 parent
8c82d0fa41
commit
3ae2128564
5 files changed
+51
-9
No files matched your search
@@ -163,11 +163,7 @@ public class GuiChisel extends GuiContainer {
|
||||
@Override
|
||||
protected void mouseClicked(int xCoord, int yCoord, int btn) {
|
||||
if (scrollBar != null) {
|
||||
int currentScroll = scrollBar.getCurrentScroll();
|
||||
scrollBar.click(xCoord - guiLeft, yCoord - guiTop);
|
||||
if (currentScroll != scrollBar.getCurrentScroll()) {
|
||||
menu.updateItems();
|
||||
}
|
||||
}
|
||||
super.mouseClicked(xCoord, yCoord, btn);
|
||||
}
|
||||
@@ -178,11 +174,7 @@ public class GuiChisel extends GuiContainer {
|
||||
|
||||
int i = Mouse.getEventDWheel();
|
||||
if (i != 0 && scrollBar != null) {
|
||||
int currentScroll = scrollBar.getCurrentScroll();
|
||||
scrollBar.wheel(i);
|
||||
if (currentScroll != scrollBar.getCurrentScroll()) {
|
||||
menu.updateItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package team.chisel.client.gui;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import team.chisel.inventory.ContainerChisel;
|
||||
import team.chisel.network.PacketHandler;
|
||||
import team.chisel.network.message.MessageScrollUpdate;
|
||||
|
||||
public class GuiScrollbar {
|
||||
public static final ResourceLocation TEXTURE_RESOURCE_LOCATION = new ResourceLocation("minecraft", "textures/gui/container/creative_inventory/tabs.png");
|
||||
@@ -62,6 +64,7 @@ public class GuiScrollbar {
|
||||
|
||||
private void setCurrentScroll(int scroll) {
|
||||
container.inventory.setCurrentScroll(scroll * rowSize);
|
||||
PacketHandler.INSTANCE.sendToServer(new MessageScrollUpdate(scroll * rowSize));
|
||||
}
|
||||
|
||||
private int applyRange(int scroll) {
|
||||
|
||||
@@ -31,7 +31,10 @@ public class InventoryChiselSelection implements IInventory {
|
||||
}
|
||||
|
||||
public void setCurrentScroll(int currentScroll) {
|
||||
this.currentScroll = currentScroll;
|
||||
if (this.currentScroll != currentScroll) {
|
||||
this.currentScroll = currentScroll;
|
||||
updateItems();
|
||||
}
|
||||
}
|
||||
|
||||
public int getCurrentScroll() {
|
||||
|
||||
@@ -5,6 +5,7 @@ import team.chisel.network.message.MessageAutoChisel;
|
||||
import team.chisel.network.message.MessageChiselMode;
|
||||
import team.chisel.network.message.MessageChiselSound;
|
||||
import team.chisel.network.message.MessagePresentConnect;
|
||||
import team.chisel.network.message.MessageScrollUpdate;
|
||||
import team.chisel.network.message.MessageSlotUpdate;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -21,5 +22,6 @@ public class PacketHandler {
|
||||
INSTANCE.registerMessage(MessageAutoChisel.Handler.class, MessageAutoChisel.class, id++, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageChiselMode.Handler.class, MessageChiselMode.class, id++, Side.SERVER);
|
||||
INSTANCE.registerMessage(MessagePresentConnect.Handler.class, MessagePresentConnect.class, id++, Side.CLIENT);
|
||||
INSTANCE.registerMessage(MessageScrollUpdate.Handler.class, MessageScrollUpdate.class, id++, Side.SERVER);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package team.chisel.network.message;
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.inventory.Container;
|
||||
import team.chisel.inventory.ContainerChisel;
|
||||
|
||||
public class MessageScrollUpdate implements IMessage {
|
||||
|
||||
private int currentScroll;
|
||||
|
||||
public MessageScrollUpdate() {
|
||||
}
|
||||
|
||||
public MessageScrollUpdate(int scroll) {
|
||||
currentScroll = scroll;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
currentScroll = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(currentScroll);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<MessageScrollUpdate, IMessage> {
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MessageScrollUpdate message, MessageContext ctx) {
|
||||
Container container = ctx.getServerHandler().playerEntity.openContainer;
|
||||
if (container instanceof ContainerChisel) {
|
||||
((ContainerChisel) container).inventory.setCurrentScroll(message.currentScroll);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user