mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 17:44:46 +00:00
IPlayer:
-Added disableMouseInput(long time, int... buttonIds) function.
This commit is contained in:
1 parent
dfec85484b
commit
dd207757ea
6 files changed
+64
-5
No files matched your search
@@ -129,6 +129,18 @@ public class NoppesUtilPlayer {
|
||||
player.worldObj.updateEntityWithOptionalForce(player, false);
|
||||
}
|
||||
|
||||
public static void disableMouseInput(EntityPlayerMP player, long time, int... buttonIds) {
|
||||
StringBuilder stringedIds = new StringBuilder();
|
||||
for (int i = 0; i < buttonIds.length; i++) {
|
||||
stringedIds.append(i);
|
||||
if (i < buttonIds.length - 1) {
|
||||
stringedIds.append(";");
|
||||
}
|
||||
}
|
||||
|
||||
Server.sendData(player, EnumPacketClient.DISABLE_MOUSE_INPUT, time, stringedIds.toString());
|
||||
}
|
||||
|
||||
public static void swingPlayerArm(EntityPlayerMP player){
|
||||
Server.sendData(player, EnumPacketClient.SWING_PLAYER_ARM);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,45 @@
|
||||
package noppes.npcs.client;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraftforge.client.event.MouseEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
import noppes.npcs.client.gui.OverlayQuestTracking;
|
||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||
import noppes.npcs.client.renderer.RenderCNPCPlayer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ClientEventHandler {
|
||||
RenderCNPCPlayer renderCNPCPlayer = new RenderCNPCPlayer();
|
||||
private final RenderCNPCPlayer renderCNPCPlayer = new RenderCNPCPlayer();
|
||||
public static HashMap<Integer,Long> disabledButtonTimes = new HashMap<>();
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMouse(MouseEvent event) {
|
||||
if (Minecraft.getMinecraft().currentScreen != null)
|
||||
return;
|
||||
|
||||
ArrayList<Integer> removeList = new ArrayList<>();
|
||||
for (Map.Entry<Integer,Long> entry : disabledButtonTimes.entrySet()) {
|
||||
if (entry.getValue() > 0) {
|
||||
if (entry.getKey() == event.button || entry.getKey() == -1) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
disabledButtonTimes.put(entry.getKey(), entry.getValue() - 1);
|
||||
} else {
|
||||
removeList.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
for (int i : removeList) {
|
||||
disabledButtonTimes.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onOverlayRender(RenderGameOverlayEvent.Post event){
|
||||
|
||||
@@ -288,5 +288,20 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
NoppesUtil.updateSkinOverlayData(sendingPlayer, compound);
|
||||
}
|
||||
else if(type == EnumPacketClient.DISABLE_MOUSE_INPUT) {
|
||||
long length = buffer.readLong();
|
||||
try {
|
||||
String parsedButtons = Server.readString(buffer);
|
||||
if (parsedButtons == null || parsedButtons.isEmpty()) {
|
||||
ClientEventHandler.disabledButtonTimes.put(-1, length);
|
||||
return;
|
||||
}
|
||||
|
||||
String[] splitIds = parsedButtons.split(";");
|
||||
for (String s : splitIds) {
|
||||
ClientEventHandler.disabledButtonTimes.put(Integer.parseInt(s), length);
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,5 +39,6 @@ public enum EnumPacketClient {
|
||||
SWING_PLAYER_ARM,
|
||||
UPDATE_ITEM,
|
||||
PLAYER_UPDATE_SKIN_OVERLAYS,
|
||||
OVERLAY_QUEST_TRACKING
|
||||
OVERLAY_QUEST_TRACKING,
|
||||
DISABLE_MOUSE_INPUT
|
||||
}
|
||||
@@ -474,6 +474,10 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
NoppesUtilPlayer.swingPlayerArm(player);
|
||||
}
|
||||
|
||||
public void disableMouseInput(long time, int... buttonIds) {
|
||||
NoppesUtilPlayer.disableMouseInput(player ,time, buttonIds);
|
||||
}
|
||||
|
||||
public void stopUsingItem(){
|
||||
player.stopUsingItem();
|
||||
}
|
||||
|
||||
@@ -177,6 +177,8 @@ public interface IPlayer<T extends EntityPlayerMP> extends IEntityLivingBase<T>
|
||||
|
||||
void setRotation(float rotationYaw, float rotationPitch);
|
||||
|
||||
void disableMouseInput(long time, int... buttonIds);
|
||||
|
||||
void stopUsingItem();
|
||||
|
||||
void clearItemInUse();
|
||||
|
||||
Reference in new issue
Block a user