mirror of
https://github.com/GTNewHorizons/ThaumicHorizons.git
synced 2026-10-26 14:33:47 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b198bd8568 | ||
|
|
5ebd91e844 | ||
|
|
0612173fc6 | ||
|
|
cfd2910120 |
No files matched your search
@@ -10,7 +10,8 @@ import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChatStyle;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -32,6 +33,8 @@ import thaumcraft.api.nodes.IRevealer;
|
||||
|
||||
public class THKeyHandler {
|
||||
|
||||
private static final ChatStyle INFUSION_MESSAGE = new ChatStyle().setColor(EnumChatFormatting.GRAY).setItalic(true);
|
||||
|
||||
public KeyBinding keyV;
|
||||
public KeyBinding keyM;
|
||||
public KeyBinding keyC;
|
||||
@@ -48,10 +51,19 @@ public class THKeyHandler {
|
||||
public static long lastPressV;
|
||||
|
||||
public THKeyHandler() {
|
||||
this.keyV = new KeyBinding("Change Arcane Lens", Keyboard.KEY_NONE, "Thaumcraft");
|
||||
this.keyM = new KeyBinding("Activate Morphic Fingers", Keyboard.KEY_NONE, "Thaumcraft");
|
||||
this.keyC = new KeyBinding("Toggle Spider Climb", Keyboard.KEY_NONE, "Thaumcraft");
|
||||
this.keyX = new KeyBinding("Toggle Chameleon Skin", Keyboard.KEY_NONE, "Thaumcraft");
|
||||
this.keyV = new KeyBinding(
|
||||
"thaumichorizons.key.arcane_lens",
|
||||
Keyboard.KEY_NONE,
|
||||
"thaumichorizons.keybind_group");
|
||||
this.keyM = new KeyBinding(
|
||||
"thaumichorizons.key.morphic_fingers",
|
||||
Keyboard.KEY_NONE,
|
||||
"thaumichorizons.keybind_group");
|
||||
this.keyC = new KeyBinding(
|
||||
"thaumichorizons.key.spider_climb",
|
||||
Keyboard.KEY_NONE,
|
||||
"thaumichorizons.keybind_group");
|
||||
this.keyX = new KeyBinding("thaumichorizons.key.chameleon", Keyboard.KEY_NONE, "thaumichorizons.keybind_group");
|
||||
this.keyPressedM = false;
|
||||
this.keyPressedC = false;
|
||||
this.keyPressedX = false;
|
||||
@@ -65,158 +77,122 @@ public class THKeyHandler {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public void playerTick(final TickEvent.PlayerTickEvent event) {
|
||||
if (event.side == Side.SERVER) {
|
||||
return;
|
||||
}
|
||||
if (event.phase == TickEvent.Phase.START) {
|
||||
if (this.keyV.getIsKeyPressed()) {
|
||||
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
|
||||
final EntityPlayer player = event.player;
|
||||
if (player != null) {
|
||||
if (!this.keyPressedV) {
|
||||
THKeyHandler.lastPressV = System.currentTimeMillis();
|
||||
THKeyHandler.radialLock = false;
|
||||
}
|
||||
if (!THKeyHandler.radialLock && player.inventory.armorItemInSlot(3) != null
|
||||
&& player.inventory.armorItemInSlot(3).getItem() instanceof IRevealer) {
|
||||
if (player.isSneaking()) {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketLensChangeToServer(player, "REMOVE"));
|
||||
} else {
|
||||
THKeyHandler.radialActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.keyPressedV = true;
|
||||
}
|
||||
} else {
|
||||
THKeyHandler.radialActive = false;
|
||||
if (this.keyPressedV) {
|
||||
if (event.side != Side.CLIENT || event.phase != TickEvent.Phase.START || event.player == null) return;
|
||||
|
||||
final EntityPlayer player = event.player;
|
||||
final EntityInfusionProperties infusions = (EntityInfusionProperties) player
|
||||
.getExtendedProperties("CreatureInfusion");
|
||||
|
||||
if (this.keyV.getIsKeyPressed()) {
|
||||
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
|
||||
if (!this.keyPressedV) {
|
||||
THKeyHandler.lastPressV = System.currentTimeMillis();
|
||||
THKeyHandler.radialLock = false;
|
||||
}
|
||||
this.keyPressedV = false;
|
||||
}
|
||||
if (this.keyM.getIsKeyPressed()) {
|
||||
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
|
||||
final EntityPlayer player = event.player;
|
||||
if (player != null) {
|
||||
if (!this.keyPressedM) {
|
||||
THKeyHandler.lastPressM = System.currentTimeMillis();
|
||||
}
|
||||
if (((EntityInfusionProperties) player.getExtendedProperties("CreatureInfusion"))
|
||||
.hasPlayerInfusion(2) && !this.keyPressedM) {
|
||||
player.openGui(
|
||||
ThaumicHorizons.instance,
|
||||
9,
|
||||
player.worldObj,
|
||||
(int) player.posX,
|
||||
(int) player.posY,
|
||||
(int) player.posZ);
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketFingersToServer(player, player.dimension));
|
||||
}
|
||||
if (!THKeyHandler.radialLock && player.inventory.armorItemInSlot(3) != null
|
||||
&& player.inventory.armorItemInSlot(3).getItem() instanceof IRevealer) {
|
||||
if (player.isSneaking()) {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketLensChangeToServer(player, "REMOVE"));
|
||||
} else {
|
||||
THKeyHandler.radialActive = true;
|
||||
}
|
||||
this.keyPressedM = true;
|
||||
}
|
||||
} else {
|
||||
if (this.keyPressedM) {
|
||||
this.keyPressedV = true;
|
||||
}
|
||||
} else {
|
||||
THKeyHandler.radialActive = false;
|
||||
if (this.keyPressedV) {
|
||||
THKeyHandler.lastPressV = System.currentTimeMillis();
|
||||
}
|
||||
this.keyPressedV = false;
|
||||
}
|
||||
|
||||
if (this.keyM.getIsKeyPressed()) {
|
||||
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
|
||||
if (!this.keyPressedM) {
|
||||
THKeyHandler.lastPressM = System.currentTimeMillis();
|
||||
}
|
||||
this.keyPressedM = false;
|
||||
}
|
||||
if (this.keyC.getIsKeyPressed()) {
|
||||
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
|
||||
final EntityPlayer player = event.player;
|
||||
if (player != null) {
|
||||
if (!this.keyPressedC) {
|
||||
THKeyHandler.lastPressC = System.currentTimeMillis();
|
||||
}
|
||||
if (((EntityInfusionProperties) player.getExtendedProperties("CreatureInfusion"))
|
||||
.hasPlayerInfusion(9) && !this.keyPressedC) {
|
||||
((EntityInfusionProperties) player.getExtendedProperties(
|
||||
"CreatureInfusion")).toggleClimb = !((EntityInfusionProperties) player
|
||||
.getExtendedProperties("CreatureInfusion")).toggleClimb;
|
||||
if (((EntityInfusionProperties) player
|
||||
.getExtendedProperties("CreatureInfusion")).toggleClimb) {
|
||||
player.addChatMessage(
|
||||
new ChatComponentText(
|
||||
EnumChatFormatting.ITALIC + ""
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ "Spider Climb disabled."));
|
||||
} else {
|
||||
player.addChatMessage(
|
||||
new ChatComponentText(
|
||||
EnumChatFormatting.ITALIC + ""
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ "Spider Climb enabled."));
|
||||
}
|
||||
PacketHandler.INSTANCE
|
||||
.sendToServer(new PacketToggleClimbToServer(player, player.dimension));
|
||||
}
|
||||
}
|
||||
this.keyPressedC = true;
|
||||
if (infusions.hasPlayerInfusion(2) && !this.keyPressedM) {
|
||||
player.openGui(
|
||||
ThaumicHorizons.instance,
|
||||
9,
|
||||
player.worldObj,
|
||||
(int) player.posX,
|
||||
(int) player.posY,
|
||||
(int) player.posZ);
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketFingersToServer(player, player.dimension));
|
||||
}
|
||||
} else {
|
||||
if (this.keyPressedC) {
|
||||
this.keyPressedM = true;
|
||||
}
|
||||
} else {
|
||||
if (this.keyPressedM) {
|
||||
THKeyHandler.lastPressM = System.currentTimeMillis();
|
||||
}
|
||||
this.keyPressedM = false;
|
||||
}
|
||||
|
||||
if (this.keyC.getIsKeyPressed()) {
|
||||
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
|
||||
if (!this.keyPressedC) {
|
||||
THKeyHandler.lastPressC = System.currentTimeMillis();
|
||||
}
|
||||
this.keyPressedC = false;
|
||||
}
|
||||
if (this.keyX.getIsKeyPressed()) {
|
||||
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
|
||||
final EntityPlayer player = event.player;
|
||||
if (player != null) {
|
||||
if (!this.keyPressedX) {
|
||||
THKeyHandler.lastPressX = System.currentTimeMillis();
|
||||
}
|
||||
if (((EntityInfusionProperties) player.getExtendedProperties("CreatureInfusion"))
|
||||
.hasPlayerInfusion(10) && !this.keyPressedX) {
|
||||
((EntityInfusionProperties) player.getExtendedProperties(
|
||||
"CreatureInfusion")).toggleInvisible = !((EntityInfusionProperties) player
|
||||
.getExtendedProperties("CreatureInfusion")).toggleInvisible;
|
||||
if (((EntityInfusionProperties) player
|
||||
.getExtendedProperties("CreatureInfusion")).toggleInvisible) {
|
||||
player.removePotionEffectClient(Potion.invisibility.id);
|
||||
player.setInvisible(false);
|
||||
player.addChatMessage(
|
||||
new ChatComponentText(
|
||||
EnumChatFormatting.ITALIC + ""
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ "Chameleon Skin disabled."));
|
||||
} else {
|
||||
final PotionEffect effect = new PotionEffect(
|
||||
Potion.invisibility.id,
|
||||
Integer.MAX_VALUE,
|
||||
0,
|
||||
true);
|
||||
effect.setCurativeItems(new ArrayList<>());
|
||||
player.addPotionEffect(effect);
|
||||
player.setInvisible(true);
|
||||
player.addChatMessage(
|
||||
new ChatComponentText(
|
||||
EnumChatFormatting.ITALIC + ""
|
||||
+ EnumChatFormatting.GRAY
|
||||
+ "Chameleon Skin enabled."));
|
||||
}
|
||||
PacketHandler.INSTANCE
|
||||
.sendToServer(new PacketToggleInvisibleToServer(player, player.dimension));
|
||||
}
|
||||
if (infusions.hasPlayerInfusion(9) && !this.keyPressedC) {
|
||||
infusions.toggleClimb = !infusions.toggleClimb;
|
||||
if (infusions.toggleClimb) {
|
||||
player.addChatMessage(
|
||||
new ChatComponentTranslation("selfInfusions.spiderClimb.disable")
|
||||
.setChatStyle(INFUSION_MESSAGE));
|
||||
} else {
|
||||
player.addChatMessage(
|
||||
new ChatComponentTranslation("selfInfusions.spiderClimb.enable")
|
||||
.setChatStyle(INFUSION_MESSAGE));
|
||||
}
|
||||
this.keyPressedX = true;
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketToggleClimbToServer(player, player.dimension));
|
||||
}
|
||||
} else {
|
||||
if (this.keyPressedX) {
|
||||
this.keyPressedC = true;
|
||||
}
|
||||
} else {
|
||||
if (this.keyPressedC) {
|
||||
THKeyHandler.lastPressC = System.currentTimeMillis();
|
||||
}
|
||||
this.keyPressedC = false;
|
||||
}
|
||||
|
||||
if (this.keyX.getIsKeyPressed()) {
|
||||
if (FMLClientHandler.instance().getClient().inGameHasFocus) {
|
||||
if (!this.keyPressedX) {
|
||||
THKeyHandler.lastPressX = System.currentTimeMillis();
|
||||
}
|
||||
this.keyPressedX = false;
|
||||
if (infusions.hasPlayerInfusion(10) && !this.keyPressedX) {
|
||||
infusions.toggleInvisible = !infusions.toggleInvisible;
|
||||
if (infusions.toggleInvisible) {
|
||||
player.removePotionEffectClient(Potion.invisibility.id);
|
||||
player.setInvisible(false);
|
||||
player.addChatMessage(
|
||||
new ChatComponentTranslation("selfInfusions.chameleonSkin.disable")
|
||||
.setChatStyle(INFUSION_MESSAGE));
|
||||
} else {
|
||||
final PotionEffect effect = new PotionEffect(
|
||||
Potion.invisibility.id,
|
||||
Integer.MAX_VALUE,
|
||||
0,
|
||||
true);
|
||||
effect.setCurativeItems(new ArrayList<>());
|
||||
player.addPotionEffect(effect);
|
||||
player.setInvisible(true);
|
||||
player.addChatMessage(
|
||||
new ChatComponentTranslation("selfInfusions.chameleonSkin.enable")
|
||||
.setChatStyle(INFUSION_MESSAGE));
|
||||
}
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketToggleInvisibleToServer(player, player.dimension));
|
||||
}
|
||||
this.keyPressedX = true;
|
||||
}
|
||||
} else {
|
||||
if (this.keyPressedX) {
|
||||
THKeyHandler.lastPressX = System.currentTimeMillis();
|
||||
}
|
||||
this.keyPressedX = false;
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
THKeyHandler.lastPressM = 0L;
|
||||
THKeyHandler.lastPressC = 0L;
|
||||
THKeyHandler.lastPressX = 0L;
|
||||
THKeyHandler.radialActive = false;
|
||||
THKeyHandler.radialLock = false;
|
||||
THKeyHandler.lastPressV = 0L;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
itemGroup.thaumichorizons=Thaumic Horizons
|
||||
|
||||
thaumichorizons.keybind_group=Thaumic Horizons
|
||||
thaumichorizons.key.arcane_lens=Change Arcane Lens
|
||||
thaumichorizons.key.morphic_fingers=Activate Morphic Fingers
|
||||
thaumichorizons.key.spider_climb=Toggle Spider Climb
|
||||
thaumichorizons.key.chameleon=Toggle Chameleon Skin
|
||||
|
||||
thaumichorizons.noJar=You need an empty warded jar to capture a creature!
|
||||
thaumichorizons.setBeacon=Soul beacon set!
|
||||
thaumichorizons.startSitting=is waiting.
|
||||
@@ -55,6 +61,11 @@ selfInfusions.warpedTumor=Self: Warped Tumor
|
||||
selfInfusions.spiderClimb=Self: Spider Climb
|
||||
selfInfusions.chameleonSkin=Self: Chameleon Skin
|
||||
|
||||
selfInfusions.spiderClimb.enable=Spider Climb enabled.
|
||||
selfInfusions.spiderClimb.disable=Spider Climb disabled.
|
||||
selfInfusions.chameleonSkin.enable=Chameleon Skin enabled.
|
||||
selfInfusions.chameleonSkin.disable=Chameleon Skin disabled.
|
||||
|
||||
###ENTITIES###
|
||||
|
||||
entity.ThaumicHorizons.PrimedAlchemite.name=Primed Alchemite
|
||||
|
||||
Reference in new issue
Block a user