mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-22 21:20:06 +00:00
Merge remote-tracking branch 'origin/Ranzu/TinkerBaubles' into dev
This commit is contained in:
8 files changed
+111
-68
No files matched your search
@@ -9,8 +9,10 @@ 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;
|
||||
|
||||
@@ -71,16 +73,10 @@ public class PlayerAbilityHelper {
|
||||
belt.getTagCompound().setTag("Inventory", slots);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Baubles")
|
||||
private static ItemStack getBaublesBelt(EntityPlayer player) {
|
||||
baubles.common.container.InventoryBaubles baubleInventory = baubles.common.lib.PlayerHandler
|
||||
.getPlayerBaubles(player);
|
||||
if (baubleInventory == null || baubleInventory.stackList == null) return null;
|
||||
for (ItemStack bauble : baubleInventory.stackList) {
|
||||
if (bauble != null && bauble.getItem() == TinkerArmor.travelBelt) {
|
||||
return bauble;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return BaublesHelper
|
||||
.findFirstMatchingBauble(player, stack -> stack != null && stack.getItem() == TinkerArmor.travelBelt);
|
||||
}
|
||||
|
||||
public static void setEntitySize(Entity entity, float width, float height) {
|
||||
|
||||
@@ -30,6 +30,7 @@ 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;
|
||||
@@ -92,16 +93,7 @@ public class TinkerArmorEvents {
|
||||
else glove = null;
|
||||
}
|
||||
if (glove == null && LoadedMods.baubles) {
|
||||
baubles.common.container.InventoryBaubles baubleInventory = baubles.common.lib.PlayerHandler
|
||||
.getPlayerBaubles(event.entityPlayer);
|
||||
if (baubleInventory != null && baubleInventory.stackList != null) {
|
||||
for (ItemStack bauble : baubleInventory.stackList) {
|
||||
if (bauble != null && bauble.getItem() == TinkerArmor.travelGlove) {
|
||||
glove = bauble;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
glove = getBaublesTravelGlove(event.entityPlayer);
|
||||
}
|
||||
// original speed <= 0 means the block shouldn't be broken, don't increase further
|
||||
if (glove == null || !glove.hasTagCompound()
|
||||
@@ -117,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) {
|
||||
|
||||
@@ -131,8 +131,7 @@ public class HeartCanister extends CraftingItem implements IHealthAccessory, IBa
|
||||
@Override
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public BaubleType getBaubleType(ItemStack itemStack) {
|
||||
int meta = itemStack.getItemDamage();
|
||||
return (meta == 2 || meta == 4 || meta == 6) ? BaubleType.UNIVERSAL : BaubleType.RING;
|
||||
return BaubleType.UNIVERSAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.network.ByteBufUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import tconstruct.compat.BaublesHelper;
|
||||
import tconstruct.compat.LoadedMods;
|
||||
import tconstruct.library.accessory.IHealthAccessory;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
@@ -145,12 +146,11 @@ public class ArmorExtended implements IInventory {
|
||||
@Optional.Method(modid = "Baubles")
|
||||
private int getBaublesHealthBoost(EntityPlayer player) {
|
||||
int bonusHP = 0;
|
||||
baubles.common.container.InventoryBaubles baubleInventory = baubles.common.lib.PlayerHandler
|
||||
.getPlayerBaubles(player);
|
||||
if (baubleInventory == null || baubleInventory.stackList == null) {
|
||||
ItemStack[] baubleStacks = BaublesHelper.getBaubleStacks(player);
|
||||
if (baubleStacks == null) {
|
||||
return 0;
|
||||
}
|
||||
for (ItemStack stack : baubleInventory.stackList) {
|
||||
for (ItemStack stack : baubleStacks) {
|
||||
if (stack != null && stack.getItem() instanceof IHealthAccessory) {
|
||||
bonusHP += ((IHealthAccessory) stack.getItem()).getHealthBoost(stack);
|
||||
}
|
||||
|
||||
@@ -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,7 @@ 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;
|
||||
@@ -198,34 +200,9 @@ public class TPlayerHandler {
|
||||
stats.armor.recalculateHealth(player, stats);
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Baubles")
|
||||
private ItemStack tryMoveToBaubles(EntityPlayer player, ItemStack stack) {
|
||||
if (stack == null || stack.stackSize <= 0) {
|
||||
return null;
|
||||
}
|
||||
if (!(stack.getItem() instanceof baubles.api.IBauble)) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
baubles.common.container.InventoryBaubles baubleInventory = baubles.common.lib.PlayerHandler
|
||||
.getPlayerBaubles(player);
|
||||
if (baubleInventory == null || baubleInventory.stackList == 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;
|
||||
return BaublesHelper.tryMoveToBaubles(player, stack);
|
||||
}
|
||||
|
||||
void spawnPigmanModifier(EntityPlayer entityplayer) {
|
||||
|
||||
@@ -25,7 +25,7 @@ import tconstruct.armor.ArmorProxyCommon;
|
||||
import tconstruct.armor.PlayerAbilityHelper;
|
||||
import tconstruct.armor.TinkerArmor;
|
||||
import tconstruct.armor.items.TravelGear;
|
||||
import tconstruct.compat.LoadedMods;
|
||||
import tconstruct.compat.BaublesHelper;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import tconstruct.util.network.AccessoryInventoryPacket;
|
||||
import tconstruct.util.network.BeltPacket;
|
||||
@@ -182,21 +182,11 @@ public class ArmorControls {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Optional.Method(modid = "Baubles")
|
||||
private static boolean hasBaublesTravelBelt() {
|
||||
if (!LoadedMods.baubles) {
|
||||
return false;
|
||||
}
|
||||
baubles.common.container.InventoryBaubles baubleInventory = baubles.common.lib.PlayerHandler
|
||||
.getPlayerBaubles(mc.thePlayer);
|
||||
if (baubleInventory == null || baubleInventory.stackList == null) {
|
||||
return false;
|
||||
}
|
||||
for (ItemStack bauble : baubleInventory.stackList) {
|
||||
if (bauble != null && bauble.getItem() == TinkerArmor.travelBelt) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return BaublesHelper.findFirstMatchingBauble(
|
||||
mc.thePlayer,
|
||||
stack -> stack != null && stack.getItem() == TinkerArmor.travelBelt) != null;
|
||||
}
|
||||
|
||||
public void landOnGround() {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,8 @@ public class ConveyorBase extends MantleBlock {
|
||||
texturename = name;
|
||||
}
|
||||
|
||||
public boolean isBlockReplaceable(World world, int x, int y, int z) {
|
||||
@Override
|
||||
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user