From 65ae9b45abea24cf6b69520646fed4881fad6ca7 Mon Sep 17 00:00:00 2001 From: 70000hp <105080577+70000hp@users.noreply.github.com> Date: Tue, 20 Aug 2024 12:17:31 -0400 Subject: [PATCH] some usability improvements --- .../java/com/hbm/blocks/BlockDummyable.java | 4 +-- .../com/hbm/blocks/network/FluidDuctBase.java | 33 +++++++++++++++++-- .../java/com/hbm/handler/HbmKeybinds.java | 8 +++-- .../java/com/hbm/interfaces/ICopiable.java | 3 +- .../com/hbm/items/tool/ItemSettingsTool.java | 10 ++++-- src/main/java/com/hbm/main/ClientProxy.java | 3 +- .../tileentity/IControlReceiverFilter.java | 3 +- .../com/hbm/tileentity/IFluidCopiable.java | 3 +- 8 files changed, 53 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/hbm/blocks/BlockDummyable.java b/src/main/java/com/hbm/blocks/BlockDummyable.java index b81f81db6..e0463a1b0 100644 --- a/src/main/java/com/hbm/blocks/BlockDummyable.java +++ b/src/main/java/com/hbm/blocks/BlockDummyable.java @@ -520,11 +520,11 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl } @Override - public void pasteSettings(NBTTagCompound nbt, int index, World world, int x, int y, int z) { + public void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) { int[] pos = findCore(world, x, y, z); TileEntity tile = world.getTileEntity(pos[0], pos[1], pos[2]); if (tile instanceof ICopiable) - ((ICopiable) tile).pasteSettings(nbt, index, world, pos[0], pos[1], pos[2]); + ((ICopiable) tile).pasteSettings(nbt, index, world, player, pos[0], pos[1], pos[2]); } @Override diff --git a/src/main/java/com/hbm/blocks/network/FluidDuctBase.java b/src/main/java/com/hbm/blocks/network/FluidDuctBase.java index 3422d1f17..65af59af5 100644 --- a/src/main/java/com/hbm/blocks/network/FluidDuctBase.java +++ b/src/main/java/com/hbm/blocks/network/FluidDuctBase.java @@ -4,8 +4,11 @@ import java.util.ArrayList; import java.util.List; import com.hbm.blocks.IAnalyzable; +import com.hbm.extprop.HbmPlayerProps; +import com.hbm.handler.HbmKeybinds; import com.hbm.inventory.fluid.FluidType; import com.hbm.items.machine.IItemFluidIdentifier; +import com.hbm.items.machine.ItemFluidIDMulti; import com.hbm.tileentity.network.TileEntityPipeBaseNT; import api.hbm.fluid.IPipeNet; @@ -14,6 +17,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -36,13 +40,24 @@ public class FluidDuctBase extends BlockContainer implements IBlockFluidDuct, IA IItemFluidIdentifier id = (IItemFluidIdentifier) player.getHeldItem().getItem(); FluidType type = id.getType(world, x, y, z, player.getHeldItem()); - if(!player.isSneaking()) { + if(!HbmPlayerProps.getData(player).getKeyPressed(HbmKeybinds.EnumKeybind.TOOL_CTRL) && !player.isSneaking()) { TileEntity te = world.getTileEntity(x, y, z); if(te instanceof TileEntityPipeBaseNT) { TileEntityPipeBaseNT pipe = (TileEntityPipeBaseNT) te; - + + if(HbmPlayerProps.getData(player).getKeyPressed(HbmKeybinds.EnumKeybind.TOOL_ALT)) { + Item item = player.getHeldItem().getItem(); + if (item instanceof ItemFluidIDMulti) { + if (id.getType(world, x, y, z, player.getHeldItem()) != pipe.getType()) { + ItemFluidIDMulti.setType(player.getHeldItem(), pipe.getType(), true); + world.playSoundAtEntity(player, "random.orb", 0.25F, 0.75F); + return true; + } + } + } + if(pipe.getType() != type) { pipe.setType(type); return true; @@ -51,9 +66,21 @@ public class FluidDuctBase extends BlockContainer implements IBlockFluidDuct, IA } else { TileEntity te = world.getTileEntity(x, y, z); - + if(te instanceof TileEntityPipeBaseNT) { TileEntityPipeBaseNT pipe = (TileEntityPipeBaseNT) te; + + if(HbmPlayerProps.getData(player).getKeyPressed(HbmKeybinds.EnumKeybind.TOOL_ALT)) { + Item item = player.getHeldItem().getItem(); + if (item instanceof ItemFluidIDMulti) { + if (id.getType(world, x, y, z, player.getHeldItem()) != pipe.getType()) { + ItemFluidIDMulti.setType(player.getHeldItem(), pipe.getType(), true); + world.playSoundAtEntity(player, "random.orb", 0.25F, 0.75F); + return true; + } + } + } + changeTypeRecursively(world, x, y, z, pipe.getType(), type, 64); return true; } diff --git a/src/main/java/com/hbm/handler/HbmKeybinds.java b/src/main/java/com/hbm/handler/HbmKeybinds.java index 767c28ad7..a29dcad8c 100644 --- a/src/main/java/com/hbm/handler/HbmKeybinds.java +++ b/src/main/java/com/hbm/handler/HbmKeybinds.java @@ -24,7 +24,9 @@ public class HbmKeybinds { public static KeyBinding reloadKey = new KeyBinding(category + ".reload", Keyboard.KEY_R, 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 copyToolAlt = new KeyBinding(category + ".copyTool", Keyboard.KEY_LMENU, category); + public static KeyBinding copyToolAlt = new KeyBinding(category + ".copyToolAlt", Keyboard.KEY_LMENU, category); + + public static KeyBinding copyToolCtrl = new KeyBinding(category + ".copyToolCtrl", Keyboard.KEY_LCONTROL, category); public static KeyBinding craneUpKey = new KeyBinding(category + ".craneMoveUp", Keyboard.KEY_UP, category); public static KeyBinding craneDownKey = new KeyBinding(category + ".craneMoveDown", Keyboard.KEY_DOWN, category); @@ -45,6 +47,7 @@ public class HbmKeybinds { ClientRegistry.registerKeyBinding(craneRightKey); ClientRegistry.registerKeyBinding(craneLoadKey); ClientRegistry.registerKeyBinding(copyToolAlt); + ClientRegistry.registerKeyBinding(copyToolCtrl); } @SubscribeEvent @@ -78,6 +81,7 @@ public class HbmKeybinds { CRANE_LEFT, CRANE_RIGHT, CRANE_LOAD, - COPY_TOOL + TOOL_ALT, + TOOL_CTRL } } diff --git a/src/main/java/com/hbm/interfaces/ICopiable.java b/src/main/java/com/hbm/interfaces/ICopiable.java index 5a8f2997f..1fa9ba276 100644 --- a/src/main/java/com/hbm/interfaces/ICopiable.java +++ b/src/main/java/com/hbm/interfaces/ICopiable.java @@ -2,6 +2,7 @@ package com.hbm.interfaces; import com.hbm.util.Either; import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -10,7 +11,7 @@ public interface ICopiable { NBTTagCompound getSettings(World world, int x, int y, int z); - void pasteSettings(NBTTagCompound nbt, int index, World world, int x, int y, int z); + void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z); default String getSettingsSourceID(Either self) { Block block = self.isLeft() ? self.left().getBlockType() : self.right(); diff --git a/src/main/java/com/hbm/items/tool/ItemSettingsTool.java b/src/main/java/com/hbm/items/tool/ItemSettingsTool.java index b50462675..f0e1541cb 100644 --- a/src/main/java/com/hbm/items/tool/ItemSettingsTool.java +++ b/src/main/java/com/hbm/items/tool/ItemSettingsTool.java @@ -20,7 +20,6 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import javax.annotation.Nullable; -import java.util.ArrayList; import java.util.List; public class ItemSettingsTool extends Item { @@ -32,14 +31,18 @@ public class ItemSettingsTool extends Item { if(((EntityPlayer) entity).getHeldItem() == stack && stack.hasTagCompound()) { EntityPlayer player = ((EntityPlayer) entity); + int delay = stack.stackTagCompound.getInteger("inputDelay"); + delay++; displayInfo = stack.stackTagCompound.getTagList("displayInfo", 10); - if (HbmPlayerProps.getData(player).getKeyPressed(HbmKeybinds.EnumKeybind.COPY_TOOL)) { + if (HbmPlayerProps.getData(player).getKeyPressed(HbmKeybinds.EnumKeybind.TOOL_ALT) && delay > 4) { int index = stack.stackTagCompound.getInteger("copyIndex") + 1; if(index > displayInfo.tagCount() - 1) index = 0; stack.stackTagCompound.setInteger("copyIndex", index); + delay = 0; } + stack.stackTagCompound.setInteger("inputDelay", delay); if(world.getTotalWorldTime() % 5 != 0) return; if(displayInfo.tagCount() > 0){ @@ -75,6 +78,7 @@ public class ItemSettingsTool extends Item { stack.stackTagCompound = copiable.getSettings(world, x, y, z); stack.stackTagCompound.setString("tileName", copiable.getSettingsSourceID(schrodinger)); stack.stackTagCompound.setInteger("copyIndex", 0); + stack.stackTagCompound.setInteger("inputDelay", 0); String[] info = copiable.infoForDisplay(world, x, y, z); if(info != null) { NBTTagList displayInfo = new NBTTagList(); @@ -95,7 +99,7 @@ public class ItemSettingsTool extends Item { } else if(stack.hasTagCompound()) { int index = stack.stackTagCompound.getInteger("copyIndex"); - copiable.pasteSettings(stack.stackTagCompound, index, world, x, y, z); + copiable.pasteSettings(stack.stackTagCompound, index, world, player, x, y, z); } return !world.isRemote; diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index 1f2167262..4be95b1ee 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -2113,7 +2113,8 @@ public class ClientProxy extends ServerProxy { case CRANE_LEFT: return HbmKeybinds.craneLeftKey.getIsKeyPressed(); case CRANE_RIGHT: return HbmKeybinds.craneRightKey.getIsKeyPressed(); case CRANE_LOAD: return HbmKeybinds.craneLoadKey.getIsKeyPressed(); - case COPY_TOOL: return HbmKeybinds.copyToolAlt.getIsKeyPressed(); + case TOOL_ALT: return HbmKeybinds.copyToolAlt.getIsKeyPressed(); + case TOOL_CTRL: return HbmKeybinds.copyToolCtrl.getIsKeyPressed(); } return false; diff --git a/src/main/java/com/hbm/tileentity/IControlReceiverFilter.java b/src/main/java/com/hbm/tileentity/IControlReceiverFilter.java index 2e6c5a15a..844c001e2 100644 --- a/src/main/java/com/hbm/tileentity/IControlReceiverFilter.java +++ b/src/main/java/com/hbm/tileentity/IControlReceiverFilter.java @@ -3,6 +3,7 @@ package com.hbm.tileentity; import com.hbm.interfaces.IControlReceiver; import com.hbm.interfaces.ICopiable; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -66,7 +67,7 @@ public interface IControlReceiverFilter extends IControlReceiver, ICopiable { } @Override - default void pasteSettings(NBTTagCompound nbt, int index, World world, int x, int y, int z) { + default void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) { TileEntity tile = (TileEntity) this; IInventory inv = (IInventory) this; NBTTagList items = nbt.getTagList("items", 10); diff --git a/src/main/java/com/hbm/tileentity/IFluidCopiable.java b/src/main/java/com/hbm/tileentity/IFluidCopiable.java index 61933e829..023c8ac5b 100644 --- a/src/main/java/com/hbm/tileentity/IFluidCopiable.java +++ b/src/main/java/com/hbm/tileentity/IFluidCopiable.java @@ -5,6 +5,7 @@ import com.hbm.interfaces.ICopiable; import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.util.BobMathUtil; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; @@ -40,7 +41,7 @@ public interface IFluidCopiable extends ICopiable { } @Override - default void pasteSettings(NBTTagCompound nbt, int index, World world, int x, int y, int z) { + default void pasteSettings(NBTTagCompound nbt, int index, World world, EntityPlayer player, int x, int y, int z) { if(getTankToPaste() != null) { int[] ids = nbt.getIntArray("fluidID"); if(ids.length > 0) {