mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-10-25 20:32:32 +00:00
Removed Tinkers Inventory GUI Tab (#279)
Co-authored-by: Martin Robertz <dream-master@gmx.net> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: GitHub GTNH Actions <2970688+Dream-Master@users.noreply.github.com>
This commit is contained in:
18 files changed
+384
-43
No files matched your search
@@ -110,6 +110,10 @@ import tconstruct.world.village.VillageToolStationHandler;
|
||||
+ "before:UndergroundBiomes")
|
||||
public class TConstruct {
|
||||
|
||||
public static final String HEART_CANISTER_RED_TYPE = "heartcanister_red";
|
||||
public static final String HEART_CANISTER_YELLOW_TYPE = "heartcanister_yellow";
|
||||
public static final String HEART_CANISTER_GREEN_TYPE = "heartcanister_green";
|
||||
|
||||
public static final String modVersion = Tags.VERSION;
|
||||
/** The value of one ingot in millibuckets */
|
||||
public static final int ingotLiquidValue = 144;
|
||||
@@ -226,6 +230,12 @@ public class TConstruct {
|
||||
if (LoadedMods.baublesExpanded) {
|
||||
BaubleExpandedSlots.tryRegisterType(BaubleExpandedSlots.quiverType);
|
||||
BaubleExpandedSlots.tryAssignSlotOfType(BaubleExpandedSlots.quiverType);
|
||||
BaubleExpandedSlots.tryRegisterType(HEART_CANISTER_RED_TYPE);
|
||||
BaubleExpandedSlots.tryAssignSlotOfType(HEART_CANISTER_RED_TYPE);
|
||||
BaubleExpandedSlots.tryRegisterType(HEART_CANISTER_YELLOW_TYPE);
|
||||
BaubleExpandedSlots.tryAssignSlotOfType(HEART_CANISTER_YELLOW_TYPE);
|
||||
BaubleExpandedSlots.tryRegisterType(HEART_CANISTER_GREEN_TYPE);
|
||||
BaubleExpandedSlots.tryAssignSlotOfType(HEART_CANISTER_GREEN_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -193,6 +193,9 @@ public class ArmorProxyClient extends ArmorProxyCommon {
|
||||
return new GuiInventory(player);
|
||||
}
|
||||
if (ID == ArmorProxyCommon.armorGuiID) {
|
||||
if (!PHConstruct.enableTinkerInventoryTab) {
|
||||
return null;
|
||||
}
|
||||
ArmorProxyClient.armorExtended.init(Minecraft.getMinecraft().thePlayer);
|
||||
return new ArmorExtendedGui(player.inventory, ArmorProxyClient.armorExtended);
|
||||
}
|
||||
@@ -216,7 +219,9 @@ public class ArmorProxyClient extends ArmorProxyCommon {
|
||||
controlInstance.registerKeys();
|
||||
|
||||
TabRegistry.registerTab(new InventoryTabVanilla());
|
||||
TabRegistry.registerTab(new InventoryTabArmorExtended());
|
||||
if (PHConstruct.enableTinkerInventoryTab) {
|
||||
TabRegistry.registerTab(new InventoryTabArmorExtended());
|
||||
}
|
||||
TabRegistry.registerTab(new InventoryTabKnapsack());
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import tconstruct.armor.inventory.ArmorExtendedContainer;
|
||||
import tconstruct.armor.inventory.KnapsackContainer;
|
||||
import tconstruct.armor.player.TPlayerStats;
|
||||
import tconstruct.common.TProxyCommon;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
public class ArmorProxyCommon implements IGuiHandler {
|
||||
|
||||
@@ -36,6 +37,9 @@ public class ArmorProxyCommon implements IGuiHandler {
|
||||
return player.inventoryContainer;
|
||||
}
|
||||
if (ID == ArmorProxyCommon.armorGuiID) {
|
||||
if (!PHConstruct.enableTinkerInventoryTab) {
|
||||
return null;
|
||||
}
|
||||
TPlayerStats stats = TPlayerStats.get(player);
|
||||
return new ArmorExtendedContainer(player.inventory, stats.armor);
|
||||
}
|
||||
|
||||
@@ -9,8 +9,11 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import tconstruct.armor.player.ArmorExtended;
|
||||
import tconstruct.armor.player.TPlayerStats;
|
||||
import tconstruct.compat.BaublesHelper;
|
||||
import tconstruct.compat.LoadedMods;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
public class PlayerAbilityHelper {
|
||||
@@ -38,6 +41,9 @@ public class PlayerAbilityHelper {
|
||||
NBTTagList slots = new NBTTagList();
|
||||
InventoryPlayer hotbar = player.inventory;
|
||||
ItemStack belt = armor.inventory[3];
|
||||
if (belt == null && LoadedMods.baubles) {
|
||||
belt = getBaublesBelt(player);
|
||||
}
|
||||
if (belt == null) return;
|
||||
|
||||
NBTTagCompound itemTag;
|
||||
@@ -67,6 +73,12 @@ public class PlayerAbilityHelper {
|
||||
belt.getTagCompound().setTag("Inventory", slots);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Baubles")
|
||||
private static ItemStack getBaublesBelt(EntityPlayer player) {
|
||||
return BaublesHelper
|
||||
.findFirstMatchingBauble(player, stack -> stack != null && stack.getItem() == TinkerArmor.travelBelt);
|
||||
}
|
||||
|
||||
public static void setEntitySize(Entity entity, float width, float height) {
|
||||
float f2;
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.armor.items.TravelWings;
|
||||
import tconstruct.armor.player.TPlayerStats;
|
||||
import tconstruct.compat.BaublesHelper;
|
||||
import tconstruct.compat.LoadedMods;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import tconstruct.util.network.ArmourGuiSyncPacket;
|
||||
@@ -90,6 +92,9 @@ public class TinkerArmorEvents {
|
||||
if (ArmorProxyClient.armorExtended != null) glove = ArmorProxyClient.armorExtended.getStackInSlot(1);
|
||||
else glove = null;
|
||||
}
|
||||
if (glove == null && LoadedMods.baubles) {
|
||||
glove = getBaublesTravelGlove(event.entityPlayer);
|
||||
}
|
||||
// original speed <= 0 means the block shouldn't be broken, don't increase further
|
||||
if (glove == null || !glove.hasTagCompound()
|
||||
|| (!PHConstruct.bypassGloveSpeedCheck && event.originalSpeed <= 0))
|
||||
@@ -104,6 +109,12 @@ public class TinkerArmorEvents {
|
||||
event.newSpeed = (event.originalSpeed + base) * modifier;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Baubles")
|
||||
private ItemStack getBaublesTravelGlove(EntityPlayer player) {
|
||||
return BaublesHelper
|
||||
.findFirstMatchingBauble(player, stack -> stack != null && stack.getItem() == TinkerArmor.travelGlove);
|
||||
}
|
||||
|
||||
public void jumpHeight(LivingJumpEvent event) {
|
||||
ItemStack stack = event.entityLiving.getEquipmentInSlot(2);
|
||||
if (stack != null && stack.getItem() instanceof TravelWings) {
|
||||
|
||||
@@ -2,21 +2,31 @@ package tconstruct.armor.items;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import baubles.api.expanded.IBaubleExpanded;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import mantle.items.abstracts.CraftingItem;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.armor.player.ArmorExtended;
|
||||
import tconstruct.armor.player.TPlayerStats;
|
||||
import tconstruct.library.TConstructRegistry;
|
||||
import tconstruct.library.accessory.IHealthAccessory;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
public class HeartCanister extends CraftingItem implements IHealthAccessory {
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "Baubles|Expanded", iface = "baubles.api.expanded.IBaubleExpanded"),
|
||||
@Optional.Interface(modid = "Baubles", iface = "baubles.api.IBauble") })
|
||||
public class HeartCanister extends CraftingItem implements IHealthAccessory, IBauble, IBaubleExpanded {
|
||||
|
||||
public HeartCanister() {
|
||||
super(
|
||||
@@ -36,19 +46,21 @@ public class HeartCanister extends CraftingItem implements IHealthAccessory {
|
||||
if (meta == 1 || meta == 3 || meta == 5) {
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
}
|
||||
if (!world.isRemote && meta == 2) {
|
||||
if (!world.isRemote && PHConstruct.enableTinkerInventoryTab && (meta == 2 || meta == 4 || meta == 6)) {
|
||||
TPlayerStats stats = TPlayerStats.get(player);
|
||||
if (stats != null && stats.armor != null) {
|
||||
ArmorExtended armor = stats.armor;
|
||||
ItemStack slotStack = armor.getStackInSlot(6);
|
||||
int targetSlot = meta == 2 ? 6 : meta == 4 ? 5 : 4;
|
||||
ItemStack slotStack = armor.getStackInSlot(targetSlot);
|
||||
if (slotStack == null) // || slotStack.getItem() == this)
|
||||
{
|
||||
armor.setInventorySlotContents(6, new ItemStack(this, 1, 2));
|
||||
armor.setInventorySlotContents(targetSlot, new ItemStack(this, 1, meta));
|
||||
stack.stackSize--;
|
||||
} else if (slotStack.getItem() == this && slotStack.stackSize < this.maxStackSize) {
|
||||
slotStack.stackSize++;
|
||||
stack.stackSize--;
|
||||
}
|
||||
} else if (slotStack.getItem() == this && slotStack.getItemDamage() == meta
|
||||
&& slotStack.stackSize < this.maxStackSize) {
|
||||
slotStack.stackSize++;
|
||||
stack.stackSize--;
|
||||
}
|
||||
armor.recalculateHealth(player, stats);
|
||||
}
|
||||
}
|
||||
@@ -105,6 +117,62 @@ public class HeartCanister extends CraftingItem implements IHealthAccessory {
|
||||
return ((type == 2 && slot == 6) || (type == 4 && slot == 5) || (type == 6 && slot == 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles|Expanded")
|
||||
public String[] getBaubleTypes(ItemStack itemstack) {
|
||||
return switch (itemstack.getItemDamage()) {
|
||||
case 2 -> new String[] { TConstruct.HEART_CANISTER_RED_TYPE };
|
||||
case 4 -> new String[] { TConstruct.HEART_CANISTER_YELLOW_TYPE };
|
||||
case 6 -> new String[] { TConstruct.HEART_CANISTER_GREEN_TYPE };
|
||||
default -> new String[0];
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public BaubleType getBaubleType(ItemStack itemStack) {
|
||||
return BaubleType.UNIVERSAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public void onEquipped(ItemStack itemstack, EntityLivingBase player) {
|
||||
recalculatePlayerHealth(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public void onUnequipped(ItemStack itemstack, EntityLivingBase player) {
|
||||
recalculatePlayerHealth(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
|
||||
int meta = itemstack.getItemDamage();
|
||||
return meta == 2 || meta == 4 || meta == 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private void recalculatePlayerHealth(EntityLivingBase entity) {
|
||||
if (!(entity instanceof EntityPlayer player)) {
|
||||
return;
|
||||
}
|
||||
TPlayerStats stats = TPlayerStats.get(player);
|
||||
if (stats != null && stats.armor != null) {
|
||||
stats.armor.recalculateHealth(player, stats);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHealthBoost(ItemStack item) {
|
||||
return item.stackSize * 2;
|
||||
|
||||
@@ -12,6 +12,11 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import baubles.api.expanded.BaubleExpandedSlots;
|
||||
import baubles.api.expanded.IBaubleExpanded;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import tconstruct.armor.ArmorProxyClient;
|
||||
@@ -19,7 +24,10 @@ import tconstruct.client.ArmorControls;
|
||||
import tconstruct.library.accessory.AccessoryCore;
|
||||
import tconstruct.library.accessory.IAccessoryModel;
|
||||
|
||||
public class TravelBelt extends AccessoryCore implements IAccessoryModel {
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "Baubles|Expanded", iface = "baubles.api.expanded.IBaubleExpanded"),
|
||||
@Optional.Interface(modid = "Baubles", iface = "baubles.api.IBauble") })
|
||||
public class TravelBelt extends AccessoryCore implements IAccessoryModel, IBauble, IBaubleExpanded {
|
||||
|
||||
public TravelBelt() {
|
||||
super("travelgear/travel_belt");
|
||||
@@ -30,6 +38,42 @@ public class TravelBelt extends AccessoryCore implements IAccessoryModel {
|
||||
return slot == 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles|Expanded")
|
||||
public String[] getBaubleTypes(ItemStack itemstack) {
|
||||
return new String[] { BaubleExpandedSlots.universalType };
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public BaubleType getBaubleType(ItemStack itemStack) {
|
||||
return BaubleType.UNIVERSAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public void onEquipped(ItemStack itemstack, EntityLivingBase player) {}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public void onUnequipped(ItemStack itemstack, EntityLivingBase player) {}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected void registerModifiers(IIconRegister iconRegister) {}
|
||||
|
||||
@@ -8,13 +8,21 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import baubles.api.expanded.BaubleExpandedSlots;
|
||||
import baubles.api.expanded.IBaubleExpanded;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import tconstruct.armor.ArmorProxyClient;
|
||||
import tconstruct.library.accessory.AccessoryCore;
|
||||
import tconstruct.library.accessory.IAccessoryModel;
|
||||
|
||||
public class TravelGlove extends AccessoryCore implements IAccessoryModel {
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(modid = "Baubles|Expanded", iface = "baubles.api.expanded.IBaubleExpanded"),
|
||||
@Optional.Interface(modid = "Baubles", iface = "baubles.api.IBauble") })
|
||||
public class TravelGlove extends AccessoryCore implements IAccessoryModel, IBauble, IBaubleExpanded {
|
||||
|
||||
public TravelGlove() {
|
||||
super("travelgear/travel_glove");
|
||||
@@ -25,6 +33,42 @@ public class TravelGlove extends AccessoryCore implements IAccessoryModel {
|
||||
return slot == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles|Expanded")
|
||||
public String[] getBaubleTypes(ItemStack itemstack) {
|
||||
return new String[] { BaubleExpandedSlots.universalType };
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public BaubleType getBaubleType(ItemStack itemStack) {
|
||||
return BaubleType.UNIVERSAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public void onEquipped(ItemStack itemstack, EntityLivingBase player) {}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public void onUnequipped(ItemStack itemstack, EntityLivingBase player) {}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemTool(ItemStack stack) {
|
||||
return true;
|
||||
|
||||
@@ -14,10 +14,11 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import tconstruct.compat.BaublesHelper;
|
||||
import tconstruct.compat.LoadedMods;
|
||||
import tconstruct.library.accessory.IHealthAccessory;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
@@ -114,42 +115,47 @@ public class ArmorExtended implements IInventory {
|
||||
}
|
||||
|
||||
public void recalculateHealth(EntityPlayer player, TPlayerStats stats) {
|
||||
Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
|
||||
if (inventory[4] != null || inventory[5] != null || inventory[6] != null) {
|
||||
int bonusHP = 0;
|
||||
for (int i = 4; i < 7; i++) {
|
||||
ItemStack stack = inventory[i];
|
||||
if (stack != null && stack.getItem() instanceof IHealthAccessory) {
|
||||
bonusHP += ((IHealthAccessory) stack.getItem()).getHealthBoost(stack);
|
||||
}
|
||||
int bonusHP = 0;
|
||||
for (int i = 4; i < 7; i++) {
|
||||
ItemStack stack = inventory[i];
|
||||
if (stack != null && stack.getItem() instanceof IHealthAccessory) {
|
||||
bonusHP += ((IHealthAccessory) stack.getItem()).getHealthBoost(stack);
|
||||
}
|
||||
int prevHealth = stats.bonusHealth;
|
||||
stats.bonusHealth = bonusHP;
|
||||
}
|
||||
|
||||
int healthChange = bonusHP - prevHealth;
|
||||
if (healthChange != 0) {
|
||||
IAttributeInstance attributeinstance = player.getAttributeMap()
|
||||
.getAttributeInstance(SharedMonsterAttributes.maxHealth);
|
||||
try {
|
||||
attributeinstance.removeModifier(attributeinstance.getModifier(globalID));
|
||||
} catch (Exception ignored) {}
|
||||
if (LoadedMods.baubles) {
|
||||
bonusHP += getBaublesHealthBoost(player);
|
||||
}
|
||||
|
||||
int prevHealth = stats.bonusHealth;
|
||||
stats.bonusHealth = bonusHP;
|
||||
int healthChange = bonusHP - prevHealth;
|
||||
if (healthChange != 0) {
|
||||
IAttributeInstance attributeinstance = player.getAttributeMap()
|
||||
.getAttributeInstance(SharedMonsterAttributes.maxHealth);
|
||||
try {
|
||||
attributeinstance.removeModifier(attributeinstance.getModifier(globalID));
|
||||
} catch (Exception ignored) {}
|
||||
if (bonusHP > 0) {
|
||||
attributeinstance
|
||||
.applyModifier(new AttributeModifier(globalID, "tconstruct.heartCanister", bonusHP, 0));
|
||||
}
|
||||
} else if (parent != null && parent.get() != null) {
|
||||
int prevHealth = stats.bonusHealth;
|
||||
int bonusHP = 0;
|
||||
stats.bonusHealth = bonusHP;
|
||||
int healthChange = bonusHP - prevHealth;
|
||||
if (healthChange != 0) {
|
||||
IAttributeInstance attributeinstance = player.getAttributeMap()
|
||||
.getAttributeInstance(SharedMonsterAttributes.maxHealth);
|
||||
try {
|
||||
attributeinstance.removeModifier(attributeinstance.getModifier(globalID));
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Baubles")
|
||||
private int getBaublesHealthBoost(EntityPlayer player) {
|
||||
int bonusHP = 0;
|
||||
ItemStack[] baubleStacks = BaublesHelper.getBaubleStacks(player);
|
||||
if (baubleStacks == null) {
|
||||
return 0;
|
||||
}
|
||||
for (ItemStack stack : baubleStacks) {
|
||||
if (stack != null && stack.getItem() instanceof IHealthAccessory) {
|
||||
bonusHP += ((IHealthAccessory) stack.getItem()).getHealthBoost(stack);
|
||||
}
|
||||
}
|
||||
return bonusHP;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,7 @@ import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
|
||||
@@ -33,6 +34,8 @@ import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import mantle.player.PlayerUtils;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.compat.BaublesHelper;
|
||||
import tconstruct.compat.LoadedMods;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
@@ -67,6 +70,7 @@ public class TPlayerHandler {
|
||||
public void onPlayerLogin(EntityPlayer player) {
|
||||
// Lookup player
|
||||
TPlayerStats stats = TPlayerStats.get(player);
|
||||
migrateDisabledAccessoryInventory(player, stats);
|
||||
|
||||
stats.level = player.experienceLevel;
|
||||
stats.hunger = player.getFoodStats().getFoodLevel();
|
||||
@@ -172,6 +176,35 @@ public class TPlayerHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void migrateDisabledAccessoryInventory(EntityPlayer player, TPlayerStats stats) {
|
||||
if (PHConstruct.enableTinkerInventoryTab || stats == null || stats.armor == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int slot = 0; slot < stats.armor.inventory.length; slot++) {
|
||||
ItemStack stack = stats.armor.inventory[slot];
|
||||
if (stack == null) continue;
|
||||
|
||||
ItemStack remaining = stack.copy();
|
||||
if (LoadedMods.baubles) {
|
||||
remaining = tryMoveToBaubles(player, remaining);
|
||||
}
|
||||
|
||||
if (remaining != null && remaining.stackSize > 0) {
|
||||
if (!player.inventory.addItemStackToInventory(remaining)) {
|
||||
AbilityHelper.spawnItemAtPlayer(player, remaining);
|
||||
}
|
||||
}
|
||||
stats.armor.inventory[slot] = null;
|
||||
}
|
||||
stats.armor.recalculateHealth(player, stats);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Baubles")
|
||||
private ItemStack tryMoveToBaubles(EntityPlayer player, ItemStack stack) {
|
||||
return BaublesHelper.tryMoveToBaubles(player, stack);
|
||||
}
|
||||
|
||||
void spawnPigmanModifier(EntityPlayer entityplayer) {
|
||||
ItemStack modifier = new ItemStack(TinkerTools.creativeModifier);
|
||||
|
||||
|
||||
@@ -23,7 +23,10 @@ import tconstruct.TConstruct;
|
||||
import tconstruct.armor.ArmorProxyClient;
|
||||
import tconstruct.armor.ArmorProxyCommon;
|
||||
import tconstruct.armor.PlayerAbilityHelper;
|
||||
import tconstruct.armor.TinkerArmor;
|
||||
import tconstruct.armor.items.TravelGear;
|
||||
import tconstruct.compat.BaublesHelper;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import tconstruct.util.network.AccessoryInventoryPacket;
|
||||
import tconstruct.util.network.BeltPacket;
|
||||
import tconstruct.util.network.DoubleJumpPacket;
|
||||
@@ -171,7 +174,7 @@ public class ArmorControls {
|
||||
}
|
||||
|
||||
public static boolean doBeltSwapIfPossible() {
|
||||
if (ArmorProxyClient.armorExtended.inventory[3] != null) {
|
||||
if (ArmorProxyClient.armorExtended.inventory[3] != null || hasBaublesTravelBelt()) {
|
||||
PlayerAbilityHelper.swapBelt(mc.thePlayer, ArmorProxyClient.armorExtended);
|
||||
toggleBelt();
|
||||
return true;
|
||||
@@ -179,6 +182,13 @@ public class ArmorControls {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Baubles")
|
||||
private static boolean hasBaublesTravelBelt() {
|
||||
return BaublesHelper.findFirstMatchingBauble(
|
||||
mc.thePlayer,
|
||||
stack -> stack != null && stack.getItem() == TinkerArmor.travelBelt) != null;
|
||||
}
|
||||
|
||||
public void landOnGround() {
|
||||
midairJumps = 0;
|
||||
jumping = false;
|
||||
@@ -197,6 +207,9 @@ public class ArmorControls {
|
||||
}
|
||||
|
||||
public static void openArmorGui() {
|
||||
if (!PHConstruct.enableTinkerInventoryTab) {
|
||||
return;
|
||||
}
|
||||
AbstractPacket packet = new AccessoryInventoryPacket(ArmorProxyCommon.armorGuiID);
|
||||
updateServer(packet);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package tconstruct.compat;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
public final class BaublesHelper {
|
||||
|
||||
private BaublesHelper() {}
|
||||
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public static ItemStack findFirstMatchingBauble(EntityPlayer player, Predicate<ItemStack> matcher) {
|
||||
IInventory baubleInventory = getBaubleInventory(player);
|
||||
if (baubleInventory == null) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < baubleInventory.getSizeInventory(); i++) {
|
||||
ItemStack stack = baubleInventory.getStackInSlot(i);
|
||||
if (matcher.test(stack)) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public static ItemStack[] getBaubleStacks(EntityPlayer player) {
|
||||
IInventory baubleInventory = getBaubleInventory(player);
|
||||
if (baubleInventory == null) {
|
||||
return null;
|
||||
}
|
||||
ItemStack[] stacks = new ItemStack[baubleInventory.getSizeInventory()];
|
||||
for (int i = 0; i < stacks.length; i++) {
|
||||
stacks[i] = baubleInventory.getStackInSlot(i);
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public static ItemStack tryMoveToBaubles(EntityPlayer player, ItemStack stack) {
|
||||
if (stack == null || stack.stackSize <= 0) {
|
||||
return null;
|
||||
}
|
||||
if (!(stack.getItem() instanceof baubles.api.IBauble)) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
IInventory baubleInventory = getBaubleInventory(player);
|
||||
if (baubleInventory == null) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
ItemStack remaining = stack.copy();
|
||||
for (int i = 0; i < baubleInventory.getSizeInventory() && remaining.stackSize > 0; i++) {
|
||||
if (!baubleInventory.isItemValidForSlot(i, remaining)) {
|
||||
continue;
|
||||
}
|
||||
ItemStack inSlot = baubleInventory.getStackInSlot(i);
|
||||
if (inSlot == null) {
|
||||
ItemStack placed = remaining.copy();
|
||||
placed.stackSize = 1;
|
||||
baubleInventory.setInventorySlotContents(i, placed);
|
||||
remaining.stackSize -= 1;
|
||||
}
|
||||
}
|
||||
return remaining.stackSize > 0 ? remaining : null;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Baubles")
|
||||
private static IInventory getBaubleInventory(EntityPlayer player) {
|
||||
baubles.common.container.InventoryBaubles baubleInventory = baubles.common.lib.PlayerHandler
|
||||
.getPlayerBaubles(player);
|
||||
if (baubleInventory == null) {
|
||||
return null;
|
||||
}
|
||||
return baubleInventory;
|
||||
}
|
||||
}
|
||||
@@ -281,6 +281,7 @@ public class PHConstruct {
|
||||
connectedTexturesMode = conTexMode.getInt(2);
|
||||
|
||||
showTravellerAccessories = config.get("Looks", "Show Traveller Gear Accessories", true).getBoolean(true);
|
||||
enableTinkerInventoryTab = config.get("Looks", "Enable Tinker Inventory Tab", true).getBoolean(true);
|
||||
|
||||
// dimension blacklist
|
||||
cfgForbiddenDim = config
|
||||
@@ -566,6 +567,7 @@ public class PHConstruct {
|
||||
// Looks
|
||||
public static int connectedTexturesMode;
|
||||
public static boolean showTravellerAccessories;
|
||||
public static boolean enableTinkerInventoryTab;
|
||||
|
||||
// dimensionblacklist
|
||||
public static boolean slimeIslGenDim0Only;
|
||||
|
||||
@@ -10,6 +10,7 @@ import tconstruct.TConstruct;
|
||||
import tconstruct.armor.ArmorProxyCommon;
|
||||
import tconstruct.armor.TinkerArmor;
|
||||
import tconstruct.armor.player.TPlayerStats;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
public class AccessoryInventoryPacket extends AbstractPacket {
|
||||
|
||||
@@ -47,6 +48,9 @@ public class AccessoryInventoryPacket extends AbstractPacket {
|
||||
(int) player.posZ);
|
||||
break;
|
||||
case ArmorProxyCommon.armorGuiID:
|
||||
if (!PHConstruct.enableTinkerInventoryTab) {
|
||||
break;
|
||||
}
|
||||
player.openGui(
|
||||
TConstruct.instance,
|
||||
ArmorProxyCommon.armorGuiID,
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
@@ -1195,3 +1195,6 @@ tconstruct.mobsinfocompat.tinkers_construct_beheading_1=If you are using a Cleav
|
||||
|
||||
#Baubles compat (Baubles Expanded already has the relevant localizations)
|
||||
baubletype.any=Equippable in a §aRing§7 slot
|
||||
slot.heartcanister_red=Red Heart Canister
|
||||
slot.heartcanister_yellow=Yellow Heart Canister
|
||||
slot.heartcanister_green=Green Heart Canister
|
||||
Reference in new issue
Block a user