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

@@ -6,26 +6,20 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.*;
import tconstruct.library.tools.ToolCore;
public class ModButtertouch extends ModBoolean
{
public class ModButtertouch extends ModBoolean {
public ModButtertouch(ItemStack[] items, int effect)
{
public ModButtertouch(ItemStack[] items, int effect) {
super(items, effect, "Silk Touch", "\u00a7e", "Silky");
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
if (tool.getItem() instanceof ToolCore)
{
protected boolean canModify(ItemStack tool, ItemStack[] input) {
if (tool.getItem() instanceof ToolCore) {
ToolCore toolItem = (ToolCore) tool.getItem();
if (!validType(toolItem))
return false;
if (!validType(toolItem)) return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.getBoolean("Lava") && !tags.hasKey("Lapis"))
{
if (!tags.getBoolean("Lava") && !tags.hasKey("Lapis")) {
return tags.getInteger("Modifiers") > 0 && !tags.getBoolean(key);
}
}
@@ -33,8 +27,7 @@ public class ModButtertouch extends ModBoolean
}
@Override
public void modify (ItemStack[] input, ItemStack tool)
{
public void modify(ItemStack[] input, ItemStack tool) {
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
tags.setBoolean(key, true);
addEnchantment(tool, Enchantment.silkTouch, 1);
@@ -45,57 +38,48 @@ public class ModButtertouch extends ModBoolean
int attack = tags.getInteger("Attack");
attack -= 3;
if (attack < 0)
attack = 0;
if (attack < 0) attack = 0;
tags.setInteger("Attack", attack);
int miningSpeed = tags.getInteger("MiningSpeed");
miningSpeed -= 300;
if (miningSpeed < 0)
miningSpeed = 0;
if (miningSpeed < 0) miningSpeed = 0;
tags.setInteger("MiningSpeed", miningSpeed);
if (tags.hasKey("MiningSpeed2"))
{
if (tags.hasKey("MiningSpeed2")) {
int miningSpeed2 = tags.getInteger("MiningSpeed2");
miningSpeed2 -= 300;
if (miningSpeed2 < 0)
miningSpeed2 = 0;
if (miningSpeed2 < 0) miningSpeed2 = 0;
tags.setInteger("MiningSpeed2", miningSpeed2);
}
addToolTip(tool, color + tooltipName, color + key);
}
public void addEnchantment (ItemStack tool, Enchantment enchant, int level) //TODO: Move this to ItemModifier
{
public void addEnchantment(ItemStack tool, Enchantment enchant, int level) // TODO: Move this to ItemModifier
{
NBTTagList tags = new NBTTagList();
Map enchantMap = EnchantmentHelper.getEnchantments(tool);
Iterator iterator = enchantMap.keySet().iterator();
int index;
int lvl;
boolean hasEnchant = false;
while (iterator.hasNext())
{
while (iterator.hasNext()) {
NBTTagCompound enchantTag = new NBTTagCompound();
index = ((Integer) iterator.next()).intValue();
lvl = (Integer) enchantMap.get(index);
if (index == enchant.effectId)
{
if (index == enchant.effectId) {
hasEnchant = true;
enchantTag.setShort("id", (short) index);
enchantTag.setShort("lvl", (short) ((byte) level));
tags.appendTag(enchantTag);
}
else
{
} else {
enchantTag.setShort("id", (short) index);
enchantTag.setShort("lvl", (short) ((byte) lvl));
tags.appendTag(enchantTag);
}
}
if (!hasEnchant)
{
if (!hasEnchant) {
NBTTagCompound enchantTag = new NBTTagCompound();
enchantTag.setShort("id", (short) enchant.effectId);
enchantTag.setShort("lvl", (short) ((byte) level));
@@ -104,8 +88,7 @@ public class ModButtertouch extends ModBoolean
tool.stackTagCompound.setTag("ench", tags);
}
public boolean validType (ToolCore tool)
{
public boolean validType(ToolCore tool) {
List list = Arrays.asList(tool.getTraits());
return list.contains("weapon") || list.contains("harvest");
}