Fix JABBA-related issues with crafting station slots (#54)

* Fix shift-merging tools voiding items

fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392>

* Change 0-sized ItemStacks into null stacks in crafting station attached slots

Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425>

* Update buildscript

* spotlessApply
This commit is contained in:
Raven Szewczyk authored and GitHub committed 2022-09-22 20:51:23 +02:00
1 parent 18bfeaff32
commit 39be06c23b
571 files changed
+25959 -28223

No files matched your search

+164 -162
View File
@@ -25,186 +25,188 @@ import tconstruct.util.network.GogglePacket;
public class ArmorControls {
public static final String keybindCategory = "tconstruct.keybindings";
public static final String[] keyDescs = new String[]{"key.tarmor", "key.tgoggles", "key.tbelt", "key.tzoom"};
public static KeyBinding armorKey = new KeyBinding(keyDescs[0], 24, keybindCategory);
public static KeyBinding toggleGoggles = new KeyBinding(keyDescs[1], 34, keybindCategory);
public static KeyBinding beltSwap = new KeyBinding(keyDescs[2], 48, keybindCategory);
public static KeyBinding zoomKey = new KeyBinding(keyDescs[3], 44, keybindCategory); //TODO: Make this hold, not toggle
static KeyBinding jumpKey;
static KeyBinding invKey;
static Minecraft mc;
public static final String keybindCategory = "tconstruct.keybindings";
public static final String[] keyDescs = new String[] {"key.tarmor", "key.tgoggles", "key.tbelt", "key.tzoom"};
public static KeyBinding armorKey = new KeyBinding(keyDescs[0], 24, keybindCategory);
public static KeyBinding toggleGoggles = new KeyBinding(keyDescs[1], 34, keybindCategory);
public static KeyBinding beltSwap = new KeyBinding(keyDescs[2], 48, keybindCategory);
public static KeyBinding zoomKey =
new KeyBinding(keyDescs[3], 44, keybindCategory); // TODO: Make this hold, not toggle
static KeyBinding jumpKey;
static KeyBinding invKey;
static Minecraft mc;
boolean jumping;
int midairJumps = 0;
boolean climbing = false;
boolean onGround = false;
public static boolean zoom = false;
boolean activeGoggles = false; //TODO: Set this on server login
boolean jumping;
int midairJumps = 0;
boolean climbing = false;
boolean onGround = false;
public static boolean zoom = false;
boolean activeGoggles = false; // TODO: Set this on server login
int currentTab = 1;
// boolean onStilts = false;
int currentTab = 1;
// boolean onStilts = false;
private final KeyBinding[] keys;
private final KeyBinding[] keys;
public ArmorControls() {
getVanillaKeyBindings();
keys = new KeyBinding[]{
armorKey,
toggleGoggles,
beltSwap,
zoomKey,
null, null
};
}
public ArmorControls() {
getVanillaKeyBindings();
keys = new KeyBinding[] {armorKey, toggleGoggles, beltSwap, zoomKey, null, null};
}
public void registerKeys() {
// Register bindings
for (KeyBinding key : keys) {
if (key != null) {
ClientRegistry.registerKeyBinding(key);
}
}
if (Loader.isModLoaded("notenoughkeys")) {
Api.registerMod(TConstruct.modID, keyDescs);
}
// Add mc keys
keys[4] = jumpKey;
keys[5] = invKey;
}
public void registerKeys() {
// Register bindings
for (KeyBinding key : keys) {
if (key != null) {
ClientRegistry.registerKeyBinding(key);
}
}
if (Loader.isModLoaded("notenoughkeys")) {
Api.registerMod(TConstruct.modID, keyDescs);
}
// Add mc keys
keys[4] = jumpKey;
keys[5] = invKey;
}
private static void getVanillaKeyBindings() {
mc = Minecraft.getMinecraft();
jumpKey = mc.gameSettings.keyBindJump;
invKey = mc.gameSettings.keyBindInventory;
}
private static void getVanillaKeyBindings() {
mc = Minecraft.getMinecraft();
jumpKey = mc.gameSettings.keyBindJump;
invKey = mc.gameSettings.keyBindInventory;
}
@SubscribeEvent
public void keyEvent(KeyInputEvent event) {
if (!Loader.isModLoaded("notenoughkeys")) {
checkAndPerformKeyActions(null, false);
}
}
@SubscribeEvent
public void keyEvent(KeyInputEvent event) {
if (!Loader.isModLoaded("notenoughkeys")) {
checkAndPerformKeyActions(null, false);
}
}
@Optional.Method(modid = "notenoughkeys")
@SubscribeEvent
public void keyEventSpecial(KeyBindingPressedEvent event) {
if (event.keyBinding != null && event.isKeyBindingPressed) {
checkAndPerformKeyActions(event.keyBinding, true);
}
}
@Optional.Method(modid = "notenoughkeys")
@SubscribeEvent
public void keyEventSpecial(KeyBindingPressedEvent event) {
if (event.keyBinding != null && event.isKeyBindingPressed) {
checkAndPerformKeyActions(event.keyBinding, true);
}
}
private void checkAndPerformKeyActions(KeyBinding keyBinding, boolean inputFromNotEnoughKeys) {
if (inputFromNotEnoughKeys ? keyBinding == armorKey : armorKey.isPressed()) {
openArmorGui();
return;
}
if (inputFromNotEnoughKeys ? keyBinding == jumpKey : jumpKey.isPressed()) {
performHigherJump();
return;
}
if (mc.currentScreen == null) {
if (inputFromNotEnoughKeys ? keyBinding == toggleGoggles : toggleGoggles.isPressed()) {
checkAndToggleNightVision();
return;
}
if (inputFromNotEnoughKeys ? keyBinding == beltSwap : beltSwap.isPressed()) {
doBeltSwapIfPossible();
return;
}
if (inputFromNotEnoughKeys ? keyBinding == zoomKey : zoomKey.isPressed()) {
zoom = !zoom;
}
}
}
private void checkAndPerformKeyActions(KeyBinding keyBinding, boolean inputFromNotEnoughKeys) {
if (inputFromNotEnoughKeys ? keyBinding == armorKey : armorKey.isPressed()) {
openArmorGui();
return;
}
if (inputFromNotEnoughKeys ? keyBinding == jumpKey : jumpKey.isPressed()) {
performHigherJump();
return;
}
if (mc.currentScreen == null) {
if (inputFromNotEnoughKeys ? keyBinding == toggleGoggles : toggleGoggles.isPressed()) {
checkAndToggleNightVision();
return;
}
if (inputFromNotEnoughKeys ? keyBinding == beltSwap : beltSwap.isPressed()) {
doBeltSwapIfPossible();
return;
}
if (inputFromNotEnoughKeys ? keyBinding == zoomKey : zoomKey.isPressed()) {
zoom = !zoom;
}
}
}
private void performHigherJump() {
if (mc.thePlayer.capabilities.isCreativeMode) {
return;
}
if (jumping && midairJumps > 0) {
mc.thePlayer.motionY = 0.42D;
mc.thePlayer.fallDistance = 0;
if (mc.thePlayer.isPotionActive(Potion.jump)) {
mc.thePlayer.motionY += (float) (mc.thePlayer.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F;
}
midairJumps--;
resetFallDamage();
}
if (!jumping) {
jumping = mc.thePlayer.isAirBorne;
ItemStack shoes = mc.thePlayer.getCurrentArmor(0);
if (shoes != null && shoes.hasTagCompound() && shoes.getTagCompound().hasKey("TinkerArmor")) {
NBTTagCompound shoeTag = shoes.getTagCompound().getCompoundTag("TinkerArmor");
midairJumps += shoeTag.getInteger("Double-Jump");
}
ItemStack wings = mc.thePlayer.getCurrentArmor(1);
if (wings != null && wings.hasTagCompound() && wings.getTagCompound().hasKey("TinkerArmor")) {
NBTTagCompound shoeTag = wings.getTagCompound().getCompoundTag("TinkerArmor");
midairJumps += shoeTag.getInteger("Double-Jump");
}
}
}
private void performHigherJump() {
if (mc.thePlayer.capabilities.isCreativeMode) {
return;
}
if (jumping && midairJumps > 0) {
mc.thePlayer.motionY = 0.42D;
mc.thePlayer.fallDistance = 0;
if (mc.thePlayer.isPotionActive(Potion.jump)) {
mc.thePlayer.motionY +=
(float) (mc.thePlayer.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F;
}
midairJumps--;
resetFallDamage();
}
if (!jumping) {
jumping = mc.thePlayer.isAirBorne;
ItemStack shoes = mc.thePlayer.getCurrentArmor(0);
if (shoes != null
&& shoes.hasTagCompound()
&& shoes.getTagCompound().hasKey("TinkerArmor")) {
NBTTagCompound shoeTag = shoes.getTagCompound().getCompoundTag("TinkerArmor");
midairJumps += shoeTag.getInteger("Double-Jump");
}
ItemStack wings = mc.thePlayer.getCurrentArmor(1);
if (wings != null
&& wings.hasTagCompound()
&& wings.getTagCompound().hasKey("TinkerArmor")) {
NBTTagCompound shoeTag = wings.getTagCompound().getCompoundTag("TinkerArmor");
midairJumps += shoeTag.getInteger("Double-Jump");
}
}
}
private void checkAndToggleNightVision() {
ItemStack goggles = mc.thePlayer.getCurrentArmor(3);
if (goggles != null && goggles.getItem() instanceof TravelGear) { // TODO: Genericize this
if (goggles.hasTagCompound() && goggles.getTagCompound().getCompoundTag(((TravelGear) goggles.getItem()).getBaseTagName()).getBoolean("Night Vision")) {
activeGoggles = !activeGoggles;
PlayerAbilityHelper.toggleGoggles(mc.thePlayer, activeGoggles);
toggleGoggles();
}
}
}
private void checkAndToggleNightVision() {
ItemStack goggles = mc.thePlayer.getCurrentArmor(3);
if (goggles != null && goggles.getItem() instanceof TravelGear) { // TODO: Genericize this
if (goggles.hasTagCompound()
&& goggles.getTagCompound()
.getCompoundTag(((TravelGear) goggles.getItem()).getBaseTagName())
.getBoolean("Night Vision")) {
activeGoggles = !activeGoggles;
PlayerAbilityHelper.toggleGoggles(mc.thePlayer, activeGoggles);
toggleGoggles();
}
}
}
public static boolean doBeltSwapIfPossible() {
if (ArmorProxyClient.armorExtended.inventory[3] != null) {
PlayerAbilityHelper.swapBelt(mc.thePlayer, ArmorProxyClient.armorExtended);
toggleBelt();
return true;
}
return false;
}
public static boolean doBeltSwapIfPossible() {
if (ArmorProxyClient.armorExtended.inventory[3] != null) {
PlayerAbilityHelper.swapBelt(mc.thePlayer, ArmorProxyClient.armorExtended);
toggleBelt();
return true;
}
return false;
}
public void landOnGround() {
midairJumps = 0;
jumping = false;
}
public void landOnGround() {
midairJumps = 0;
jumping = false;
}
public void resetControls() {
midairJumps = 0;
jumping = false;
climbing = false;
onGround = false;
}
public void resetControls() {
midairJumps = 0;
jumping = false;
climbing = false;
onGround = false;
}
void resetFallDamage() {
AbstractPacket packet = new DoubleJumpPacket();
updateServer(packet);
}
void resetFallDamage() {
AbstractPacket packet = new DoubleJumpPacket();
updateServer(packet);
}
public static void openArmorGui() {
AbstractPacket packet = new AccessoryInventoryPacket(ArmorProxyCommon.armorGuiID);
updateServer(packet);
}
public static void openArmorGui() {
AbstractPacket packet = new AccessoryInventoryPacket(ArmorProxyCommon.armorGuiID);
updateServer(packet);
}
public static void openKnapsackGui() {
AbstractPacket packet = new AccessoryInventoryPacket(ArmorProxyCommon.knapsackGuiID);
updateServer(packet);
}
public static void openKnapsackGui() {
AbstractPacket packet = new AccessoryInventoryPacket(ArmorProxyCommon.knapsackGuiID);
updateServer(packet);
}
private void toggleGoggles() {
AbstractPacket packet = new GogglePacket(activeGoggles);
updateServer(packet);
}
private void toggleGoggles() {
AbstractPacket packet = new GogglePacket(activeGoggles);
updateServer(packet);
}
private static void toggleBelt() {
AbstractPacket packet = new BeltPacket();
updateServer(packet);
}
static void updateServer(AbstractPacket abstractPacket) {
TConstruct.packetPipeline.sendToServer(abstractPacket);
}
private static void toggleBelt() {
AbstractPacket packet = new BeltPacket();
updateServer(packet);
}
static void updateServer(AbstractPacket abstractPacket) {
TConstruct.packetPipeline.sendToServer(abstractPacket);
}
}