This commit is contained in:
Boblet 2025-03-17 17:00:12 +01:00
commit 360daaa524
7 changed files with 112 additions and 82 deletions

View File

@ -26,6 +26,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
public boolean enableHUD = true;
public boolean enableBackpack = true;
public boolean enableMagnet = true;
private boolean[] keysPressed = new boolean[EnumKeybind.values().length];
@ -71,6 +72,10 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
return this.enableBackpack && getKeyPressed(EnumKeybind.JETPACK);
}
public boolean isMagnetActive(){
return this.enableMagnet;
}
public void setKeyPressed(EnumKeybind key, boolean 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);
}
}
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(!player.worldObj.isRemote) {
@ -174,6 +189,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
buf.writeBoolean(this.enableHUD);
buf.writeInt(this.reputation);
buf.writeBoolean(this.isOnLadder);
buf.writeBoolean(this.enableMagnet);
}
public void deserialize(ByteBuf buf) {
@ -185,6 +201,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
this.enableHUD = buf.readBoolean();
this.reputation = buf.readInt();
this.isOnLadder = buf.readBoolean();
this.enableMagnet = buf.readBoolean();
}
}
@ -198,6 +215,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
props.setFloat("shield", shield);
props.setFloat("maxShield", maxShield);
props.setBoolean("enableBackpack", enableBackpack);
props.setBoolean("enableMagnet", enableMagnet);
props.setBoolean("enableHUD", enableHUD);
props.setInteger("reputation", reputation);
props.setBoolean("isOnLadder", isOnLadder);
@ -216,6 +234,7 @@ public class HbmPlayerProps implements IExtendedEntityProperties {
this.shield = props.getFloat("shield");
this.maxShield = props.getFloat("maxShield");
this.enableBackpack = props.getBoolean("enableBackpack");
this.enableMagnet = props.getBoolean("enableMagnet");
this.enableHUD = props.getBoolean("enableHUD");
this.reputation = props.getInteger("reputation");
this.isOnLadder = props.getBoolean("isOnLadder");

View File

@ -22,6 +22,7 @@ public class HbmKeybinds {
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 magnetKey = new KeyBinding(category + ".toggleMagnet", Keyboard.KEY_Z, 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 trainKey = new KeyBinding(category + ".trainInv", Keyboard.KEY_R, category);
@ -43,6 +44,7 @@ public class HbmKeybinds {
public static void register() {
ClientRegistry.registerKeyBinding(calculatorKey);
ClientRegistry.registerKeyBinding(jetpackKey);
ClientRegistry.registerKeyBinding(magnetKey);
ClientRegistry.registerKeyBinding(hudKey);
ClientRegistry.registerKeyBinding(dashKey);
ClientRegistry.registerKeyBinding(trainKey);
@ -98,6 +100,7 @@ public class HbmKeybinds {
public static enum EnumKeybind {
JETPACK,
TOGGLE_JETPACK,
TOGGLE_MAGNET,
TOGGLE_HEAD,
DASH,
TRAIN,

View File

@ -2,6 +2,7 @@ package com.hbm.items.armor;
import java.util.List;
import com.hbm.extprop.HbmPlayerProps;
import com.hbm.handler.ArmorModHandler;
import net.minecraft.entity.EntityLivingBase;
@ -37,6 +38,9 @@ public class ItemModLodestone extends ItemArmorMod {
@Override
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));
for(EntityItem item : items) {

View File

@ -2038,6 +2038,7 @@ public class ClientProxy extends ServerProxy {
switch(key){
case JETPACK: return Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed();
case TOGGLE_JETPACK: return HbmKeybinds.jetpackKey.getIsKeyPressed();
case TOGGLE_MAGNET: return HbmKeybinds.magnetKey.getIsKeyPressed();
case TOGGLE_HEAD: return HbmKeybinds.hudKey.getIsKeyPressed();
case RELOAD: return HbmKeybinds.reloadKey.getIsKeyPressed();
case DASH: return HbmKeybinds.dashKey.getIsKeyPressed();

View File

@ -21,12 +21,13 @@ public class ServerProxy {
public static final int ID_CABLE = 3;
public static final int ID_DRONE = 4;
public static final int ID_JETPACK = 5;
public static final int ID_HUD = 6;
public static final int ID_DETONATOR = 7;
public static final int ID_FLUID_ID = 8;
public static final int ID_TOOLABILITY = 9;
public static final int ID_GUN_MODE = 10;
public static final int ID_GAS_HAZARD = 11;
public static final int ID_MAGNET = 6;
public static final int ID_HUD = 7;
public static final int ID_DETONATOR = 8;
public static final int ID_FLUID_ID = 9;
public static final int ID_TOOLABILITY = 10;
public static final int ID_GUN_MODE = 11;
public static final int ID_GAS_HAZARD = 12;
public void registerPreRenderInfo() { }
public void registerRenderInfo() { }

View File

@ -27,9 +27,7 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer {
this.bindTexture(pyl.color == 0 ? ResourceManager.wire_tex : ResourceManager.wire_greyscale_tex);
for(int i = 0; i < pyl.connected.size(); i++) {
int[] wire = pyl.connected.get(i);
pyl.getConnected().forEach(wire -> {
TileEntity tile = pyl.getWorldObj().getTileEntity(wire[0], wire[1], wire[2]);
if(tile instanceof TileEntityPylonBase) {
@ -75,7 +73,7 @@ public abstract class RenderPylonBase extends TileEntitySpecialRenderer {
first.zCoord + (sZ - first.zCoord) * 0.5);
}
}
}
});
}
/**

View File

@ -24,7 +24,7 @@ import net.minecraftforge.common.util.ForgeDirection;
public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
public List<int[]> connected = new ArrayList<int[]>();
protected List<int[]> connected = new ArrayList<>();
public int color;
public static int canConnect(TileEntityPylonBase first, TileEntityPylonBase second) {
@ -136,6 +136,10 @@ public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
return mounts[0].addVector(xCoord, yCoord, zCoord);
}
public List<int[]> getConnected() {
return connected;
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
@ -175,7 +179,7 @@ public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
this.readFromNBT(pkt.func_148857_g());
}
public static enum ConnectionType {
public enum ConnectionType {
SINGLE,
TRIPLE,
QUAD