mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #1982 from KellenHurrey/master
Added a keybind for toggling the magnet armor modifications
This commit is contained in:
commit
850679ca94
@ -26,6 +26,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
|
|||||||
|
|
||||||
public boolean enableHUD = true;
|
public boolean enableHUD = true;
|
||||||
public boolean enableBackpack = true;
|
public boolean enableBackpack = true;
|
||||||
|
public boolean enableMagnet = true;
|
||||||
|
|
||||||
private boolean[] keysPressed = new boolean[EnumKeybind.values().length];
|
private boolean[] keysPressed = new boolean[EnumKeybind.values().length];
|
||||||
|
|
||||||
@ -71,6 +72,10 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
|
|||||||
return this.enableBackpack && getKeyPressed(EnumKeybind.JETPACK);
|
return this.enableBackpack && getKeyPressed(EnumKeybind.JETPACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMagnetActive(){
|
||||||
|
return this.enableMagnet;
|
||||||
|
}
|
||||||
|
|
||||||
public void setKeyPressed(EnumKeybind key, boolean pressed) {
|
public void setKeyPressed(EnumKeybind key, boolean pressed) {
|
||||||
|
|
||||||
if(!getKeyPressed(key) && pressed) {
|
if(!getKeyPressed(key) && pressed) {
|
||||||
@ -86,6 +91,16 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
|
|||||||
MainRegistry.proxy.displayTooltip(EnumChatFormatting.RED + "Jetpack OFF", MainRegistry.proxy.ID_JETPACK);
|
MainRegistry.proxy.displayTooltip(EnumChatFormatting.RED + "Jetpack OFF", MainRegistry.proxy.ID_JETPACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (key == EnumKeybind.TOGGLE_MAGNET){
|
||||||
|
if (!player.worldObj.isRemote){
|
||||||
|
this.enableMagnet = !this.enableMagnet;
|
||||||
|
|
||||||
|
if(this.enableMagnet)
|
||||||
|
MainRegistry.proxy.displayTooltip(EnumChatFormatting.GREEN + "Magnet ON", MainRegistry.proxy.ID_MAGNET);
|
||||||
|
else
|
||||||
|
MainRegistry.proxy.displayTooltip(EnumChatFormatting.RED + "Magnet OFF", MainRegistry.proxy.ID_MAGNET);
|
||||||
|
}
|
||||||
|
}
|
||||||
if(key == EnumKeybind.TOGGLE_HEAD) {
|
if(key == EnumKeybind.TOGGLE_HEAD) {
|
||||||
|
|
||||||
if(!player.worldObj.isRemote) {
|
if(!player.worldObj.isRemote) {
|
||||||
@ -174,6 +189,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
|
|||||||
buf.writeBoolean(this.enableHUD);
|
buf.writeBoolean(this.enableHUD);
|
||||||
buf.writeInt(this.reputation);
|
buf.writeInt(this.reputation);
|
||||||
buf.writeBoolean(this.isOnLadder);
|
buf.writeBoolean(this.isOnLadder);
|
||||||
|
buf.writeBoolean(this.enableMagnet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deserialize(ByteBuf buf) {
|
public void deserialize(ByteBuf buf) {
|
||||||
@ -185,6 +201,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
|
|||||||
this.enableHUD = buf.readBoolean();
|
this.enableHUD = buf.readBoolean();
|
||||||
this.reputation = buf.readInt();
|
this.reputation = buf.readInt();
|
||||||
this.isOnLadder = buf.readBoolean();
|
this.isOnLadder = buf.readBoolean();
|
||||||
|
this.enableMagnet = buf.readBoolean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,6 +215,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
|
|||||||
props.setFloat("shield", shield);
|
props.setFloat("shield", shield);
|
||||||
props.setFloat("maxShield", maxShield);
|
props.setFloat("maxShield", maxShield);
|
||||||
props.setBoolean("enableBackpack", enableBackpack);
|
props.setBoolean("enableBackpack", enableBackpack);
|
||||||
|
props.setBoolean("enableMagnet", enableMagnet);
|
||||||
props.setBoolean("enableHUD", enableHUD);
|
props.setBoolean("enableHUD", enableHUD);
|
||||||
props.setInteger("reputation", reputation);
|
props.setInteger("reputation", reputation);
|
||||||
props.setBoolean("isOnLadder", isOnLadder);
|
props.setBoolean("isOnLadder", isOnLadder);
|
||||||
@ -216,6 +234,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
|
|||||||
this.shield = props.getFloat("shield");
|
this.shield = props.getFloat("shield");
|
||||||
this.maxShield = props.getFloat("maxShield");
|
this.maxShield = props.getFloat("maxShield");
|
||||||
this.enableBackpack = props.getBoolean("enableBackpack");
|
this.enableBackpack = props.getBoolean("enableBackpack");
|
||||||
|
this.enableMagnet = props.getBoolean("enableMagnet");
|
||||||
this.enableHUD = props.getBoolean("enableHUD");
|
this.enableHUD = props.getBoolean("enableHUD");
|
||||||
this.reputation = props.getInteger("reputation");
|
this.reputation = props.getInteger("reputation");
|
||||||
this.isOnLadder = props.getBoolean("isOnLadder");
|
this.isOnLadder = props.getBoolean("isOnLadder");
|
||||||
|
|||||||
@ -22,6 +22,7 @@ public class HbmKeybinds {
|
|||||||
|
|
||||||
public static KeyBinding calculatorKey = new KeyBinding(category + ".calculator", Keyboard.KEY_N, category);
|
public static KeyBinding calculatorKey = new KeyBinding(category + ".calculator", Keyboard.KEY_N, category);
|
||||||
public static KeyBinding jetpackKey = new KeyBinding(category + ".toggleBack", Keyboard.KEY_C, category);
|
public static KeyBinding jetpackKey = new KeyBinding(category + ".toggleBack", Keyboard.KEY_C, category);
|
||||||
|
public static KeyBinding magnetKey = new KeyBinding(category + ".toggleMagnet", Keyboard.KEY_Z, category);
|
||||||
public static KeyBinding hudKey = new KeyBinding(category + ".toggleHUD", Keyboard.KEY_V, category);
|
public static KeyBinding hudKey = new KeyBinding(category + ".toggleHUD", Keyboard.KEY_V, category);
|
||||||
public static KeyBinding dashKey = new KeyBinding(category + ".dash", Keyboard.KEY_LSHIFT, category);
|
public static KeyBinding dashKey = new KeyBinding(category + ".dash", Keyboard.KEY_LSHIFT, category);
|
||||||
public static KeyBinding trainKey = new KeyBinding(category + ".trainInv", Keyboard.KEY_R, category);
|
public static KeyBinding trainKey = new KeyBinding(category + ".trainInv", Keyboard.KEY_R, category);
|
||||||
@ -43,6 +44,7 @@ public class HbmKeybinds {
|
|||||||
public static void register() {
|
public static void register() {
|
||||||
ClientRegistry.registerKeyBinding(calculatorKey);
|
ClientRegistry.registerKeyBinding(calculatorKey);
|
||||||
ClientRegistry.registerKeyBinding(jetpackKey);
|
ClientRegistry.registerKeyBinding(jetpackKey);
|
||||||
|
ClientRegistry.registerKeyBinding(magnetKey);
|
||||||
ClientRegistry.registerKeyBinding(hudKey);
|
ClientRegistry.registerKeyBinding(hudKey);
|
||||||
ClientRegistry.registerKeyBinding(dashKey);
|
ClientRegistry.registerKeyBinding(dashKey);
|
||||||
ClientRegistry.registerKeyBinding(trainKey);
|
ClientRegistry.registerKeyBinding(trainKey);
|
||||||
@ -98,6 +100,7 @@ public class HbmKeybinds {
|
|||||||
public static enum EnumKeybind {
|
public static enum EnumKeybind {
|
||||||
JETPACK,
|
JETPACK,
|
||||||
TOGGLE_JETPACK,
|
TOGGLE_JETPACK,
|
||||||
|
TOGGLE_MAGNET,
|
||||||
TOGGLE_HEAD,
|
TOGGLE_HEAD,
|
||||||
DASH,
|
DASH,
|
||||||
TRAIN,
|
TRAIN,
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.hbm.items.armor;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.hbm.extprop.HbmPlayerProps;
|
||||||
import com.hbm.handler.ArmorModHandler;
|
import com.hbm.handler.ArmorModHandler;
|
||||||
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
@ -36,7 +37,10 @@ public class ItemModLodestone extends ItemArmorMod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modUpdate(EntityLivingBase entity, ItemStack armor) {
|
public void modUpdate(EntityLivingBase entity, ItemStack armor) {
|
||||||
|
|
||||||
|
// No magnet if keybind toggled
|
||||||
|
if (entity instanceof EntityPlayer && !HbmPlayerProps.getData((EntityPlayer) entity).isMagnetActive()) return;
|
||||||
|
|
||||||
List<EntityItem> items = entity.worldObj.getEntitiesWithinAABB(EntityItem.class, entity.boundingBox.expand(range, range, range));
|
List<EntityItem> items = entity.worldObj.getEntitiesWithinAABB(EntityItem.class, entity.boundingBox.expand(range, range, range));
|
||||||
|
|
||||||
for(EntityItem item : items) {
|
for(EntityItem item : items) {
|
||||||
|
|||||||
@ -2038,6 +2038,7 @@ public class ClientProxy extends ServerProxy {
|
|||||||
switch(key){
|
switch(key){
|
||||||
case JETPACK: return Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed();
|
case JETPACK: return Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed();
|
||||||
case TOGGLE_JETPACK: return HbmKeybinds.jetpackKey.getIsKeyPressed();
|
case TOGGLE_JETPACK: return HbmKeybinds.jetpackKey.getIsKeyPressed();
|
||||||
|
case TOGGLE_MAGNET: return HbmKeybinds.magnetKey.getIsKeyPressed();
|
||||||
case TOGGLE_HEAD: return HbmKeybinds.hudKey.getIsKeyPressed();
|
case TOGGLE_HEAD: return HbmKeybinds.hudKey.getIsKeyPressed();
|
||||||
case RELOAD: return HbmKeybinds.reloadKey.getIsKeyPressed();
|
case RELOAD: return HbmKeybinds.reloadKey.getIsKeyPressed();
|
||||||
case DASH: return HbmKeybinds.dashKey.getIsKeyPressed();
|
case DASH: return HbmKeybinds.dashKey.getIsKeyPressed();
|
||||||
|
|||||||
@ -21,12 +21,13 @@ public class ServerProxy {
|
|||||||
public static final int ID_CABLE = 3;
|
public static final int ID_CABLE = 3;
|
||||||
public static final int ID_DRONE = 4;
|
public static final int ID_DRONE = 4;
|
||||||
public static final int ID_JETPACK = 5;
|
public static final int ID_JETPACK = 5;
|
||||||
public static final int ID_HUD = 6;
|
public static final int ID_MAGNET = 6;
|
||||||
public static final int ID_DETONATOR = 7;
|
public static final int ID_HUD = 7;
|
||||||
public static final int ID_FLUID_ID = 8;
|
public static final int ID_DETONATOR = 8;
|
||||||
public static final int ID_TOOLABILITY = 9;
|
public static final int ID_FLUID_ID = 9;
|
||||||
public static final int ID_GUN_MODE = 10;
|
public static final int ID_TOOLABILITY = 10;
|
||||||
public static final int ID_GAS_HAZARD = 11;
|
public static final int ID_GUN_MODE = 11;
|
||||||
|
public static final int ID_GAS_HAZARD = 12;
|
||||||
|
|
||||||
public void registerPreRenderInfo() { }
|
public void registerPreRenderInfo() { }
|
||||||
public void registerRenderInfo() { }
|
public void registerRenderInfo() { }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user