Merge branch '1.13' into 1.14

This commit is contained in:
Vincent Lee committed 2019-06-24 19:25:02 -07:00
commit d6595872be
45 files changed
+1358 -1487

No files matched your search

@@ -32,15 +32,15 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.items.IItemHandler;
import org.lwjgl.opengl.GL11;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.lexicon.ILexicon;
import vazkii.botania.api.lexicon.ILexiconable;
import vazkii.botania.api.lexicon.LexiconEntry;
@@ -63,8 +63,8 @@ import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex.InputHandler;
import vazkii.botania.common.block.tile.mana.TilePool;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.core.helper.PlayerHelper;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.item.ItemCraftingHalo;
import vazkii.botania.common.item.ItemSextant;
import vazkii.botania.common.item.ItemTwigWand;
@@ -91,17 +91,17 @@ public final class HUDHandler {
Minecraft mc = Minecraft.getInstance();
Profiler profiler = mc.profiler;
if(event.getType() == ElementType.HEALTH && Botania.curiosLoaded) {
if(event.getType() == ElementType.HEALTH) {
profiler.startSection("botania-hud");
ItemStack tiara = CurioIntegration.findOrEmpty(ModItems.flightTiara, mc.player);
ItemStack tiara = EquipmentHandler.findOrEmpty(ModItems.flightTiara, mc.player);
if(!tiara.isEmpty()) {
profiler.startSection("flugelTiara");
ItemFlightTiara.renderHUD(mc.player, tiara);
profiler.endSection();
}
ItemStack dodgeRing = CurioIntegration.findOrEmpty(ModItems.dodgeRing, mc.player);
ItemStack dodgeRing = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, mc.player);
if(!dodgeRing.isEmpty()) {
profiler.startSection("dodgeRing");
ItemDodgeRing.renderHUD(mc.player, dodgeRing, event.getPartialTicks());
@@ -204,7 +204,7 @@ public final class HUDHandler {
boolean creative = false;
IItemHandler mainInv = new net.minecraftforge.items.ItemStackHandler(1); // player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElseThrow(NullPointerException::new);
IItemHandler accInv = Botania.curiosLoaded ? CurioIntegration.getAllCurios(player).orElse(null) : null;
IItemHandler accInv = BotaniaAPI.internalHandler.getAccessoriesInventory(player);
int invSize = mainInv.getSlots();
int size = invSize;
@@ -60,6 +60,7 @@ import vazkii.botania.common.core.command.CommandOpen;
import vazkii.botania.common.core.command.CommandShare;
import vazkii.botania.common.core.command.CommandSkyblockSpread;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.core.handler.IMCHandler;
import vazkii.botania.common.core.handler.IMCSender;
import vazkii.botania.common.core.handler.InternalMethodHandler;
@@ -103,7 +104,6 @@ import vazkii.botania.common.entity.EntityManaBurst;
import vazkii.botania.common.entity.EntityPinkWither;
import vazkii.botania.common.entity.EntitySignalFlare;
import vazkii.botania.common.entity.EntitySpark;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibMisc;
import vazkii.botania.common.network.PacketHandler;
@@ -174,11 +174,7 @@ public class Botania {
MinecraftForge.EVENT_BUS.register(TileCorporeaIndex.getInputHandler());
MinecraftForge.EVENT_BUS.register(new LootHandler());
if(curiosLoaded) {
CurioIntegration.init();
FMLJavaModLoadingContext.get().getModEventBus().register(CurioIntegration.class);
MinecraftForge.EVENT_BUS.register(CurioIntegration.class);
}
EquipmentHandler.init();
if(Botania.gardenOfGlassLoaded)
MinecraftForge.EVENT_BUS.register(SkyblockWorldEvents.class);
@@ -0,0 +1,166 @@
/**
* This class was created by <Hubry>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [May 30 2019, 16:45:42 (GMT)]
*/
package vazkii.botania.common.core.handler;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.InvWrapper;
import net.minecraftforge.items.wrapper.RangedWrapper;
import vazkii.botania.common.Botania;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.item.equipment.bauble.ItemBauble;
import java.util.Arrays;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.function.Predicate;
public abstract class EquipmentHandler {
private static EquipmentHandler instance;
public static void init() { //todo maybe support baubles when/if that gets released
if(Botania.curiosLoaded) {
instance = new CurioIntegration();
FMLJavaModLoadingContext.get().getModEventBus().register(CurioIntegration.class);
MinecraftForge.EVENT_BUS.register(CurioIntegration.class);
} else {
InventoryEquipmentHandler handler = new InventoryEquipmentHandler();
instance = handler;
MinecraftForge.EVENT_BUS.addListener(handler::onPlayerTick);
}
}
public static LazyOptional<IItemHandlerModifiable> getAllWorn(EntityLivingBase living) {
return instance.getAllWornItems(living);
}
public static ItemStack findOrEmpty(Item item, EntityLivingBase living) {
return instance.findItem(item, living);
}
public static ItemStack findOrEmpty(Predicate<ItemStack> pred, EntityLivingBase living) {
return instance.findItem(pred, living);
}
public static ICapabilityProvider initBaubleCap(ItemStack stack) {
if(instance != null) // Happens to be called in ModItems class init, which is too early to know about which handler to use
return instance.initCap(stack);
return null;
}
protected abstract LazyOptional<IItemHandlerModifiable> getAllWornItems(EntityLivingBase living);
protected abstract ItemStack findItem(Item item, EntityLivingBase living);
protected abstract ItemStack findItem(Predicate<ItemStack> pred, EntityLivingBase living);
protected abstract ICapabilityProvider initCap(ItemStack stack);
// Fallback equipment handler for curios-less (or baubles-less) installs.
static class InventoryEquipmentHandler extends EquipmentHandler {
private final Map<EntityPlayer, ItemStack[]> map = new WeakHashMap<>();
@SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
if(event.phase != TickEvent.Phase.START || event.player.world.isRemote)
return;
EntityPlayer player = event.player;
player.world.profiler.startSection("botania:tick_wearables");
ItemStack[] oldStacks = map.computeIfAbsent(player, p -> {
ItemStack[] array = new ItemStack[9];
Arrays.fill(array, ItemStack.EMPTY);
return array;
});
InventoryPlayer inv = player.inventory;
for(int i = 0; i < 9; i++) {
ItemStack old = oldStacks[i];
ItemStack current = inv.getStackInSlot(i);
if(!ItemStack.areItemStacksEqual(old, current)) {
if(old.getItem() instanceof ItemBauble) {
player.getAttributeMap().removeAttributeModifiers(((ItemBauble) old.getItem()).getEquippedAttributeModifiers(old));
((ItemBauble) old.getItem()).onUnequipped(old, player);
}
if(canEquip(current, player)) {
player.getAttributeMap().applyAttributeModifiers(((ItemBauble) current.getItem()).getEquippedAttributeModifiers(current));
((ItemBauble) current.getItem()).onEquipped(current, player);
}
oldStacks[i] = current.copy(); // shift-clicking mutates the stack we stored,
// making it empty and failing the equality check - let's avoid that
}
if(canEquip(current, player)) {
((ItemBauble) current.getItem()).onWornTick(current, player);
}
}
player.world.profiler.endSection();
}
@Override
protected LazyOptional<IItemHandlerModifiable> getAllWornItems(EntityLivingBase living) {
if(living instanceof EntityPlayer) {
return LazyOptional.of(() -> new RangedWrapper(new InvWrapper(((EntityPlayer) living).inventory), 0, 9));
}
return LazyOptional.empty();
}
@Override
protected ItemStack findItem(Item item, EntityLivingBase living) {
if(living instanceof EntityPlayer) {
InventoryPlayer inv = ((EntityPlayer) living).inventory;
for(int i = 0; i < 9; i++) {
ItemStack stack = inv.getStackInSlot(i);
if(stack.getItem() == item && canEquip(stack, living)) {
return stack;
}
}
}
return ItemStack.EMPTY;
}
@Override
protected ItemStack findItem(Predicate<ItemStack> pred, EntityLivingBase living) {
if(living instanceof EntityPlayer) {
InventoryPlayer inv = ((EntityPlayer) living).inventory;
for(int i = 0; i < 9; i++) {
ItemStack stack = inv.getStackInSlot(i);
if(pred.test(stack) && canEquip(stack, living)) {
return stack;
}
}
}
return ItemStack.EMPTY;
}
@Override
protected ICapabilityProvider initCap(ItemStack stack) {
return null;
}
private static boolean canEquip(ItemStack stack, EntityLivingBase player) {
return stack.getItem() instanceof ItemBauble && ((ItemBauble) stack.getItem()).canEquip(stack, player);
}
}
}
@@ -39,9 +39,9 @@ import vazkii.botania.api.recipe.RecipeManaInfusion;
import vazkii.botania.api.recipe.RecipePetals;
import vazkii.botania.api.recipe.RecipeRuneAltar;
import vazkii.botania.api.subtile.ISpecialFlower;
import vazkii.botania.api.subtile.TileEntitySpecialFlower;
import vazkii.botania.api.subtile.TileEntityFunctionalFlower;
import vazkii.botania.api.subtile.TileEntityGeneratingFlower;
import vazkii.botania.api.subtile.TileEntitySpecialFlower;
import vazkii.botania.client.core.handler.BossBarHandler;
import vazkii.botania.client.core.handler.HUDHandler;
import vazkii.botania.common.Botania;
@@ -50,7 +50,6 @@ import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.decor.BlockFloatingFlower;
import vazkii.botania.common.block.subtile.functional.SubTileSolegnolia;
import vazkii.botania.common.integration.corporea.WrappedIInventory;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.relic.ItemLokiRing;
import vazkii.botania.common.lexicon.page.PageBrew;
@@ -153,7 +152,7 @@ public class InternalMethodHandler extends DummyMethodHandler {
@Override
public IItemHandlerModifiable getAccessoriesInventory(PlayerEntity player) {
if(Botania.curiosLoaded) {
LazyOptional<IItemHandlerModifiable> cap = CurioIntegration.getAllCurios(player);
LazyOptional<IItemHandlerModifiable> cap = EquipmentHandler.getAllWorn(player);
return cap.orElseGet(EmptyHandler::new);
}
return new EmptyHandler();
@@ -12,17 +12,14 @@ import net.minecraft.potion.Effects;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.item.IPixieSpawner;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.helper.PlayerHelper;
import vazkii.botania.common.entity.EntityPixie;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumHelm;
import vazkii.botania.common.lib.LibMisc;
@@ -46,17 +43,13 @@ public final class PixieHandler {
ItemStack stack = PlayerHelper.getFirstHeldItemClass(player, IPixieSpawner.class);
float chance = getChance(stack);
for (ItemStack element : player.inventory.armorInventory)
for(ItemStack element : player.inventory.armorInventory)
chance += getChance(element);
if(Botania.curiosLoaded) {
LazyOptional<IItemHandlerModifiable> cap = CurioIntegration.getAllCurios(player);
if(cap.isPresent()) {
IItemHandlerModifiable handler = cap.orElseThrow(NullPointerException::new);
for(int i = 0; i < handler.getSlots(); i++)
chance += getChance(handler.getStackInSlot(i));
}
}
IItemHandlerModifiable handler = BotaniaAPI.internalHandler.getAccessoriesInventory(player);
for(int i = 0; i < handler.getSlots(); i++)
chance += getChance(handler.getStackInSlot(i));
if(Math.random() < chance) {
EntityPixie pixie = new EntityPixie(player.world);
@@ -28,21 +28,19 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.mana.IManaItem;
import vazkii.botania.api.mana.IManaPool;
import vazkii.botania.api.mana.spark.ISparkAttachable;
import vazkii.botania.api.mana.spark.ISparkEntity;
import vazkii.botania.api.mana.spark.SparkHelper;
import vazkii.botania.api.mana.spark.SparkUpgradeType;
import vazkii.botania.common.Botania;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.item.ItemSparkUpgrade;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibMisc;
import vazkii.botania.common.network.PacketBotaniaEffect;
import vazkii.botania.common.network.PacketHandler;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -52,6 +50,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import javax.annotation.Nonnull;
public class EntitySpark extends Entity implements ISparkEntity {
@ObjectHolder(LibMisc.MOD_ID + ":spark")
@@ -114,12 +113,9 @@ public class EntitySpark extends Entity implements ISparkEntity {
stacks.addAll(player.inventory.mainInventory);
stacks.addAll(player.inventory.armorInventory);
if(Botania.curiosLoaded) {
CurioIntegration.getAllCurios(player).ifPresent(inv -> {
for (int i = 0; i < inv.getSlots(); i++)
stacks.add(inv.getStackInSlot(i));
});
}
IItemHandler inv = BotaniaAPI.internalHandler.getAccessoriesInventory(player);
for(int i = 0; i < inv.getSlots(); i++)
stacks.add(inv.getStackInSlot(i));
for(ItemStack stack : stacks) {
if(stack.isEmpty() || !(stack.getItem() instanceof IManaItem))
@@ -1,36 +0,0 @@
package vazkii.botania.common.integration.curios;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import top.theillusivec4.curios.api.capability.ICurio;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.core.helper.PlayerHelper;
import vazkii.botania.common.lib.LibMisc;
public class BaseCurio implements ICurio {
protected final ItemStack stack;
public BaseCurio(ItemStack stack) {
this.stack = stack;
}
@Override
public boolean canRightClickEquip() {
return true;
}
@Override
public void onEquipped(String identifier, LivingEntity living) {
if(!living.world.isRemote && living instanceof ServerPlayerEntity) {
PlayerHelper.grantCriterion((ServerPlayerEntity) living, new ResourceLocation(LibMisc.MOD_ID, "main/bauble_wear"), "code_triggered");
}
}
@Override
public void playEquipSound(LivingEntity living) {
living.world.playSound(null, living.posX, living.posY, living.posZ, ModSounds.equipBauble, living.getSoundCategory(), 0.1F, 1.3F);
}
}
@@ -1,133 +1,144 @@
package vazkii.botania.common.integration.curios;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
import net.minecraftforge.registries.IRegistryDelegate;
import top.theillusivec4.curios.api.CuriosAPI;
import top.theillusivec4.curios.api.capability.CuriosCapability;
import top.theillusivec4.curios.api.capability.ICurio;
import top.theillusivec4.curios.api.imc.CurioIMCMessage;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.bauble.*;
import vazkii.botania.common.item.relic.ItemLokiRing;
import vazkii.botania.common.item.relic.ItemOdinRing;
import vazkii.botania.common.item.relic.ItemThorRing;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Predicate;
// Classloading-safe way to attach curio behaviour to our items
public class CurioIntegration {
private static final ResourceLocation KEY = new ResourceLocation(LibMisc.MOD_ID, "curio");
private static class Provider implements ICapabilityProvider {
private final ICurio curio;
private final LazyOptional<ICurio> curioCap;
public Provider(ICurio curio) {
this.curio = curio;
curioCap = LazyOptional.of(() -> this.curio);
}
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
return CuriosCapability.ITEM.orEmpty(cap, curioCap);
}
}
@SubscribeEvent
public static void sendImc(InterModEnqueueEvent evt) {
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("charm"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("ring"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("belt"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("body"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("head"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("trinket"));
}
public static LazyOptional<IItemHandlerModifiable> getAllCurios(LivingEntity living) {
return CuriosAPI.getCuriosHandler(living).map(h -> {
IItemHandlerModifiable[] invs = h.getCurioMap().values().toArray(new IItemHandlerModifiable[0]);
return new CombinedInvWrapper(invs);
});
}
// Convenience methods, also avoids referencing FinderData class in common code
public static ItemStack findOrEmpty(Item item, LivingEntity living) {
CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(item, living);
return result == null ? ItemStack.EMPTY : result.getStack();
}
public static ItemStack findOrEmpty(Predicate<ItemStack> pred, LivingEntity living) {
CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(pred, living);
return result == null ? ItemStack.EMPTY : result.getStack();
}
public static void init() {
FACTORIES.put(ModItems.auraRing.delegate, ItemAuraRing.Curio::new);
FACTORIES.put(ModItems.auraRingGreater.delegate, ItemGreaterAuraRing.Curio::new);
FACTORIES.put(ModItems.balanceCloak.delegate, ItemHolyCloak.Curio::new);
FACTORIES.put(ModItems.bloodPendant.delegate, ItemBloodPendant.Curio::new);
FACTORIES.put(ModItems.divaCharm.delegate, ItemDivaCharm.Curio::new);
FACTORIES.put(ModItems.dodgeRing.delegate, ItemDodgeRing.Curio::new);
FACTORIES.put(ModItems.flightTiara.delegate, ItemFlightTiara.Curio::new);
FACTORIES.put(ModItems.goddessCharm.delegate, ItemGoddessCharm.Curio::new);
FACTORIES.put(ModItems.holyCloak.delegate, ItemHolyCloak.Curio::new);
FACTORIES.put(ModItems.icePendant.delegate, ItemIcePendant.Curio::new);
FACTORIES.put(ModItems.invisibilityCloak.delegate, ItemInvisibilityCloak.Curio::new);
FACTORIES.put(ModItems.itemFinder.delegate, ItemItemFinder.Curio::new);
FACTORIES.put(ModItems.knockbackBelt.delegate, ItemKnockbackBelt.Curio::new);
FACTORIES.put(ModItems.lavaPendant.delegate, ItemLavaPendant.Curio::new);
FACTORIES.put(ModItems.lokiRing.delegate, s -> new ItemLokiRing.Curio(s, ((ItemLokiRing) ModItems.lokiRing).getDummy()));
FACTORIES.put(ModItems.magnetRing.delegate, ItemMagnetRing.Curio::new);
FACTORIES.put(ModItems.magnetRingGreater.delegate, ItemMagnetRing.Curio::new);
FACTORIES.put(ModItems.manaRing.delegate, BaseCurio::new);
FACTORIES.put(ModItems.manaRingGreater.delegate, BaseCurio::new);
FACTORIES.put(ModItems.miningRing.delegate, ItemMiningRing.Curio::new);
FACTORIES.put(ModItems.odinRing.delegate, s -> new ItemOdinRing.Curio(s, ((ItemOdinRing) ModItems.odinRing).getDummy()));
FACTORIES.put(ModItems.pixieRing.delegate, BaseCurio::new);
FACTORIES.put(ModItems.reachRing.delegate, ItemReachRing.Curio::new);
FACTORIES.put(ModItems.superLavaPendant.delegate, ItemSuperLavaPendant.Curio::new);
FACTORIES.put(ModItems.superTravelBelt.delegate, ItemTravelBelt.Curio::new);
FACTORIES.put(ModItems.swapRing.delegate, ItemSwapRing.Curio::new);
FACTORIES.put(ModItems.thirdEye.delegate, ItemThirdEye.Curio::new);
FACTORIES.put(ModItems.tinyPlanet.delegate, ItemTinyPlanet.Curio::new);
FACTORIES.put(ModItems.thorRing.delegate, s -> new RelicCurio(s, ((ItemThorRing) ModItems.thorRing).getDummy()));
FACTORIES.put(ModItems.travelBelt.delegate, ItemTravelBelt.Curio::new);
FACTORIES.put(ModItems.unholyCloak.delegate, ItemHolyCloak.Curio::new);
FACTORIES.put(ModItems.waterRing.delegate, ItemWaterRing.Curio::new);
for (Item i : ModItems.cosmetics.values()) {
FACTORIES.put(i.delegate, ItemBaubleCosmetic.Curio::new);
}
}
private static final Map<IRegistryDelegate<Item>, Function<ItemStack, ICurio>> FACTORIES = new HashMap<>();
@SubscribeEvent
public static void attachCaps(AttachCapabilitiesEvent<ItemStack> evt) {
ItemStack stack = evt.getObject();
Function<ItemStack, ICurio> factory = FACTORIES.get(stack.getItem().delegate);
if (factory != null) {
evt.addCapability(KEY, new Provider(factory.apply(stack)));
}
}
}
package vazkii.botania.common.integration.curios;
import com.google.common.collect.Multimap;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
import top.theillusivec4.curios.api.CuriosAPI;
import top.theillusivec4.curios.api.capability.CuriosCapability;
import top.theillusivec4.curios.api.capability.ICurio;
import top.theillusivec4.curios.api.imc.CurioIMCMessage;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.item.equipment.bauble.ItemBauble;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.function.Predicate;
// Classloading-safe way to attach curio behaviour to our items
public class CurioIntegration extends EquipmentHandler {
private static class Provider implements ICapabilityProvider {
private final ICurio curio;
private final LazyOptional<ICurio> curioCap;
Provider(ICurio curio) {
this.curio = curio;
curioCap = LazyOptional.of(() -> this.curio);
}
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable EnumFacing side) {
return CuriosCapability.ITEM.orEmpty(cap, curioCap);
}
}
@SubscribeEvent
public static void sendImc(InterModEnqueueEvent evt) {
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("charm"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("ring").setSize(2));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("belt"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("body"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("head"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("trinket"));
}
@Override
protected LazyOptional<IItemHandlerModifiable> getAllWornItems(EntityLivingBase living) {
return CuriosAPI.getCuriosHandler(living).map(h -> {
IItemHandlerModifiable[] invs = h.getCurioMap().values().toArray(new IItemHandlerModifiable[0]);
return new CombinedInvWrapper(invs);
});
}
@Override
protected ItemStack findItem(Item item, EntityLivingBase living) {
CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(item, living);
return result == null ? ItemStack.EMPTY : result.getStack();
}
@Override
protected ItemStack findItem(Predicate<ItemStack> pred, EntityLivingBase living) {
CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(pred, living);
return result == null ? ItemStack.EMPTY : result.getStack();
}
@Override
protected ICapabilityProvider initCap(ItemStack stack) {
return new Provider(new Wrapper(stack));
}
private static class Wrapper implements ICurio {
private final ItemStack stack;
Wrapper(ItemStack stack) {
this.stack = stack;
}
private ItemBauble getItem() {
return (ItemBauble) stack.getItem();
}
@Override
public void onCurioTick(String identifier, EntityLivingBase entity) {
getItem().onWornTick(stack, entity);
}
@Override
public void onEquipped(String identifier, EntityLivingBase entity) {
getItem().onEquipped(stack, entity);
}
@Override
public void onUnequipped(String identifier, EntityLivingBase entity) {
getItem().onUnequipped(stack, entity);
}
@Override
public boolean canEquip(String identifier, EntityLivingBase entity) {
return getItem().canEquip(stack, entity);
}
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(String identifier) {
return getItem().getEquippedAttributeModifiers(stack);
}
@Override
public boolean shouldSyncToTracking(String identifier, EntityLivingBase entity) {
return getItem().shouldSyncToTracking(stack, entity);
}
@Override
public void playEquipSound(EntityLivingBase entity) {
entity.world.playSound(null, entity.posX, entity.posY, entity.posZ, ModSounds.equipBauble, entity.getSoundCategory(), 0.1F, 1.3F);
}
@Override
public boolean canRightClickEquip() {
return true;
}
@Override
public boolean hasRender(String identifier, EntityLivingBase entity) {
return getItem().hasRender(stack, entity);
}
@Override
public void doRender(String identifier, EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
getItem().doRender(stack, entitylivingbaseIn, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
}
}
}
@@ -1,33 +0,0 @@
package vazkii.botania.common.integration.curios;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import vazkii.botania.common.item.relic.ItemRelic;
public class RelicCurio extends BaseCurio{
private final ItemRelic relicDelegate;
public RelicCurio(ItemStack stack, ItemRelic relicDelegate) {
super(stack);
this.relicDelegate = relicDelegate;
}
@Override
public void onCurioTick(String identifier, LivingEntity living) {
if(living instanceof PlayerEntity) {
PlayerEntity ePlayer = (PlayerEntity) living;
relicDelegate.updateRelic(stack, ePlayer);
if(relicDelegate.isRightPlayer(ePlayer, stack))
onValidPlayerWornTick(ePlayer);
}
}
@Override
public boolean canEquip(String identifier, LivingEntity living) {
return living instanceof PlayerEntity && relicDelegate.isRightPlayer((PlayerEntity) living, stack);
}
public void onValidPlayerWornTick(PlayerEntity player) {}
}
@@ -1,25 +0,0 @@
package vazkii.botania.common.integration.curios;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.potion.Effects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Effects;
import vazkii.botania.api.item.ICosmeticAttachable;
import vazkii.botania.api.item.IPhantomInkable;
import vazkii.botania.common.core.handler.ConfigHandler;
public class RenderableCurio extends BaseCurio {
public RenderableCurio(ItemStack stack) {
super(stack);
}
@Override
public boolean hasRender(String identifier, LivingEntity living) {
boolean hasCosmetic = stack.getItem() instanceof ICosmeticAttachable && !((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack).isEmpty();
boolean ink = stack.getItem() instanceof IPhantomInkable && ((IPhantomInkable) stack.getItem()).hasPhantomInk(stack);
boolean config = ConfigHandler.CLIENT.renderAccessories.get();
boolean invis = living.getActivePotionEffect(Effects.INVISIBILITY) != null;
return !hasCosmetic && !ink && config && !invis;
}
}
@@ -16,8 +16,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.mana.IManaGivingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.lib.LibItemNames;
public class ItemAuraRing extends ItemBauble implements IManaGivingItem {
@@ -25,16 +23,9 @@ public class ItemAuraRing extends ItemBauble implements IManaGivingItem {
super(props);
}
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onCurioTick(String identifier, LivingEntity player) {
if(player instanceof PlayerEntity && player.ticksExisted % 10 == 0)
ManaItemHandler.dispatchManaExact(stack, (PlayerEntity) player, 1, true);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
if (player instanceof EntityPlayer && player.ticksExisted % 10 == 0)
ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 1, true);
}
}
@@ -10,42 +10,36 @@
*/
package vazkii.botania.common.item.equipment.bauble;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.resources.I18n;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.fml.common.Mod;
import vazkii.botania.api.item.ICosmeticAttachable;
import vazkii.botania.api.item.IPhantomInkable;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.core.helper.PlayerHelper;
import vazkii.botania.common.entity.EntityDoppleganger;
import vazkii.botania.common.item.ItemMod;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.UUID;
@@ -133,4 +127,42 @@ public abstract class ItemBauble extends ItemMod implements ICosmeticAttachable,
public void setPhantomInk(ItemStack stack, boolean ink) {
ItemNBTHelper.setBoolean(stack, TAG_PHANTOM_INK, ink);
}
@Nullable
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
return EquipmentHandler.initBaubleCap(stack);
}
public void onWornTick(ItemStack stack, EntityLivingBase entity) {}
public void onEquipped(ItemStack stack, EntityLivingBase entity) {
if(!entity.world.isRemote && entity instanceof EntityPlayerMP) {
PlayerHelper.grantCriterion((EntityPlayerMP) entity, new ResourceLocation(LibMisc.MOD_ID, "main/bauble_wear"), "code_triggered");
}
}
public void onUnequipped(ItemStack stack, EntityLivingBase entity) {}
public boolean canEquip(ItemStack stack, EntityLivingBase entity) {
return true;
}
public Multimap<String, AttributeModifier> getEquippedAttributeModifiers(ItemStack stack) {
return HashMultimap.create();
}
public boolean shouldSyncToTracking(ItemStack stack, EntityLivingBase entity) {
return false;
}
public boolean hasRender(ItemStack stack, EntityLivingBase living) {
return !(stack.getItem() instanceof ICosmeticAttachable && !((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack).isEmpty())
&& !(stack.getItem() instanceof IPhantomInkable && ((IPhantomInkable) stack.getItem()).hasPhantomInk(stack))
&& ConfigHandler.CLIENT.renderAccessories.get()
&& living.getActivePotionEffect(MobEffects.INVISIBILITY) == null;
}
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {}
}
@@ -34,7 +34,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import org.lwjgl.opengl.GL11;
import vazkii.botania.api.item.AccessoryRenderHelper;
import vazkii.botania.api.item.ICosmeticBauble;
import vazkii.botania.common.integration.curios.RenderableCurio;
import java.util.List;
@@ -71,218 +70,212 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble {
super.addHiddenTooltip(stack, world, stacks, flags);
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Variant variant = ((ItemBaubleCosmetic) stack.getItem()).variant;
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Variant variant = ((ItemBaubleCosmetic) stack.getItem()).variant;
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
AccessoryRenderHelper.translateToHeadLevel(player);
AccessoryRenderHelper.translateToFace();
AccessoryRenderHelper.defaultTransforms();
switch (variant) {
case RED_GLASSES:
scale(1.25F);
GlStateManager.translatef(0F, -0.085F, 0.045F);
renderItem(stack);
break;
case ENGINEER_GOGGLES:
scale(1.25F);
GlStateManager.translatef(0F, -0.085F, 0.045F);
renderItem(stack);
break;
case EYEPATCH:
scale(0.55F);
GlStateManager.translatef(-0.45F, -0.25F, 0F);
renderItem(stack);
break;
case WICKED_EYEPATCH:
scale(0.55F);
GlStateManager.translatef(0.45F, -0.25F, 0F);
renderItem(stack);
break;
case RED_RIBBONS:
scale(0.9F);
GlStateManager.translatef(0F, 0.75F, 1F);
renderItem(stack);
break;
case PINK_FLOWER_BUD:
GlStateManager.rotatef(-90F, 0F, 1F, 0F);
GlStateManager.translatef(0.4F, 0.6F, 0.45F);
renderItem(stack);
break;
case POLKA_DOTTED_BOWS:
GlStateManager.rotatef(-90F, 0F, 1F, 0F);
GlStateManager.translatef(0.65F, 0.3F, 0.5F);
renderItem(stack);
GlStateManager.translatef(0F, 0F, -1F);
renderItem(stack);
break;
case BLUE_BUTTERFLY:
GlStateManager.translatef(-0.75F, 0.1F, 1F);
GlStateManager.pushMatrix();
AccessoryRenderHelper.translateToHeadLevel(player);
AccessoryRenderHelper.translateToFace();
GlStateManager.rotatef(45F, 0F, 1F, 0F);
renderItem(stack);
GlStateManager.popMatrix();
GlStateManager.translatef(0F, 0F, -0.75F);
GlStateManager.rotatef(-45F, 0F, 1F, 0F);
renderItem(stack);
break;
case CAT_EARS:
GlStateManager.translatef(0F, 0.25F, 0.25F);
renderItem(stack);
break;
case GOOGLY_EYES:
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.scalef(1.5F, 1.5F, 1F);
GlStateManager.translatef(0F, -0.05F, 0F);
renderItem(stack);
break;
case CLOCK_EYE:
scale(0.75F);
GlStateManager.translatef(-0.25F, -0.1F, 0F);
GlStateManager.rotatef(180F, 0F, 0F, 1F);
renderItem(stack);
break;
case UNICORN_HORN:
scale(1.25F);
GlStateManager.rotatef(-90F, 0F, 1F, 0F);
GlStateManager.translatef(0F, 0.4F, 0F);
renderItem(stack);
break;
case DEVIL_HORNS:
GlStateManager.translatef(0F, 0.2F, 0.25F);
renderItem(stack);
break;
case HYPER_PLUS:
scale(0.35F);
GlStateManager.translatef(-0.7F, 1F, -0.5F);
renderItem(stack);
GlStateManager.translatef(1.45F, 0F, 0F);
renderItem(stack);
break;
case ANCIENT_MASK:
scale(1.25F);
GlStateManager.translatef(0F, 0.025F, 0.01F);
renderItem(stack);
break;
case EERIE_MASK:
renderItem(stack);
break;
case ALIEN_ANTENNA:
scale(0.9F);
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.translatef(0F, 0.75F, -1F);
renderItem(stack);
break;
case ANAGLYPH_GLASSES:
scale(1.25F);
GlStateManager.translatef(0F, -0.025F, 0F);
renderItem(stack);
break;
case ORANGE_SHADES:
scale(1.25f);
GlStateManager.translatef(0F, 0.04F, 0F);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.color4f(1F, 1F, 1F, 0.7F);
renderItem(stack);
break;
case GROUCHO_GLASSES:
scale(1.5F);
GlStateManager.translatef(0F, -0.2125F, 0F);
renderItem(stack);
break;
case THICK_EYEBROWS:
scale(0.5F);
GlStateManager.translatef(-0.4F, 0.05F, 0F);
renderItem(stack);
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.translatef(-0.775F, 0F, 0F);
renderItem(stack);
break;
case TINY_POTATO_MASK:
scale(1.25F);
GlStateManager.translatef(0F, 0.025F, 0F);
renderItem(stack);
break;
case QUESTGIVER_MARK:
scale(0.8F);
GlStateManager.translatef(0F, 1F, 0.3F);
renderItem(stack);
break;
case THINKING_HAND:
scale(0.9f);
GlStateManager.translatef(0.2F, -0.5F, 0F);
GlStateManager.scalef(-1, 1, 1);
GlStateManager.rotatef(15F, 0F, 0F, 1F);
renderItem(stack);
break;
default: {
// body cosmetics
AccessoryRenderHelper.rotateIfSneaking(player);
AccessoryRenderHelper.translateToChest();
AccessoryRenderHelper.defaultTransforms();
switch (variant) {
case RED_GLASSES:
scale(1.25F);
GlStateManager.translatef(0F, -0.085F, 0.045F);
case BLACK_BOWTIE:
GlStateManager.translatef(0F, 0.15F, 0F);
renderItem(stack);
break;
case ENGINEER_GOGGLES:
scale(1.25F);
GlStateManager.translatef(0F, -0.085F, 0.045F);
case BLACK_TIE:
GlStateManager.translatef(0F, -0.15F, 0F);
renderItem(stack);
break;
case EYEPATCH:
scale(0.55F);
GlStateManager.translatef(-0.45F, -0.25F, 0F);
case PUFFY_SCARF:
GlStateManager.translatef(0F, -0.15F, 0F);
renderItem(stack);
break;
case WICKED_EYEPATCH:
scale(0.55F);
GlStateManager.translatef(0.45F, -0.25F, 0F);
renderItem(stack);
break;
case RED_RIBBONS:
scale(0.9F);
GlStateManager.translatef(0F, 0.75F, 1F);
renderItem(stack);
break;
case PINK_FLOWER_BUD:
GlStateManager.rotatef(-90F, 0F, 1F, 0F);
GlStateManager.translatef(0.4F, 0.6F, 0.45F);
renderItem(stack);
break;
case POLKA_DOTTED_BOWS:
GlStateManager.rotatef(-90F, 0F, 1F, 0F);
GlStateManager.translatef(0.65F, 0.3F, 0.5F);
renderItem(stack);
GlStateManager.translatef(0F, 0F, -1F);
renderItem(stack);
break;
case BLUE_BUTTERFLY:
GlStateManager.translatef(-0.75F, 0.1F, 1F);
GlStateManager.pushMatrix();
GlStateManager.rotatef(45F, 0F, 1F, 0F);
renderItem(stack);
GlStateManager.popMatrix();
GlStateManager.translatef(0F, 0F, -0.75F);
GlStateManager.rotatef(-45F, 0F, 1F, 0F);
renderItem(stack);
break;
case CAT_EARS:
GlStateManager.translatef(0F, 0.25F, 0.25F);
renderItem(stack);
break;
case GOOGLY_EYES:
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.scalef(1.5F, 1.5F, 1F);
GlStateManager.translatef(0F, -0.05F, 0F);
renderItem(stack);
break;
case CLOCK_EYE:
scale(0.75F);
GlStateManager.translatef(-0.25F, -0.1F, 0F);
GlStateManager.rotatef(180F, 0F, 0F, 1F);
renderItem(stack);
break;
case UNICORN_HORN:
scale(1.25F);
GlStateManager.rotatef(-90F, 0F, 1F, 0F);
GlStateManager.translatef(0F, 0.4F, 0F);
renderItem(stack);
break;
case DEVIL_HORNS:
GlStateManager.translatef(0F, 0.2F, 0.25F);
renderItem(stack);
break;
case HYPER_PLUS:
case WITCH_PIN:
scale(0.35F);
GlStateManager.translatef(-0.7F, 1F, -0.5F);
renderItem(stack);
GlStateManager.translatef(1.45F, 0F, 0F);
GlStateManager.translatef(-0.35F, 0.35F, 0.15F);
renderItem(stack);
break;
case ANCIENT_MASK:
scale(1.25F);
GlStateManager.translatef(0F, 0.025F, 0.01F);
case DEVIL_TAIL:
GlStateManager.rotatef(90F, 0F, 1F, 0F);
GlStateManager.translatef(0.5F, -0.75F, 0F);
renderItem(stack);
break;
case EERIE_MASK:
renderItem(stack);
break;
case ALIEN_ANTENNA:
case KAMUI_EYE: // DON'T LOSE YOUR WAAAAAAAAY
scale(0.9F);
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.translatef(0F, 0.75F, -1F);
GlStateManager.translatef(0.9F, 0.35F, 0F);
renderItem(stack);
GlStateManager.translatef(-1.3F, -0.5F, 0.5F);
GlStateManager.rotatef(180F, 0F, 0F, 1F);
GlStateManager.rotatef(180F, 1F, 0F, 0F);
renderKamuiBlack(stack);
break;
case ANAGLYPH_GLASSES:
scale(1.25F);
GlStateManager.translatef(0F, -0.025F, 0F);
renderItem(stack);
break;
case ORANGE_SHADES:
scale(1.25f);
GlStateManager.translatef(0F, 0.04F, 0F);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.color4f(1F, 1F, 1F, 0.7F);
renderItem(stack);
break;
case GROUCHO_GLASSES:
scale(1.5F);
GlStateManager.translatef(0F, -0.2125F, 0F);
renderItem(stack);
break;
case THICK_EYEBROWS:
case FOUR_LEAF_CLOVER:
scale(0.5F);
GlStateManager.translatef(-0.4F, 0.05F, 0F);
GlStateManager.translatef(0.35F, 0.3F, -0.075F);
renderItem(stack);
break;
case BOTANIST_EMBLEM:
scale(0.5F);
GlStateManager.translatef(0F, -0.75F, 0F);
renderItem(stack);
break;
case LUSITANIC_SHIELD:
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.translatef(-0.775F, 0F, 0F);
GlStateManager.translatef(0.035F, -0.2F, 0.55F);
GlStateManager.rotatef(8F, 0F, 0F, 1F);
renderItem(stack);
break;
case TINY_POTATO_MASK:
scale(1.25F);
GlStateManager.translatef(0F, 0.025F, 0F);
renderItem(stack);
default:
break;
case QUESTGIVER_MARK:
scale(0.8F);
GlStateManager.translatef(0F, 1F, 0.3F);
renderItem(stack);
break;
case THINKING_HAND:
scale(0.9f);
GlStateManager.translatef(0.2F, -0.5F, 0F);
GlStateManager.scalef(-1, 1, 1);
GlStateManager.rotatef(15F, 0F, 0F, 1F);
renderItem(stack);
break;
default: {
// body cosmetics
GlStateManager.popMatrix();
AccessoryRenderHelper.rotateIfSneaking(player);
AccessoryRenderHelper.translateToChest();
AccessoryRenderHelper.defaultTransforms();
switch (variant) {
case BLACK_BOWTIE:
GlStateManager.translatef(0F, 0.15F, 0F);
renderItem(stack);
break;
case BLACK_TIE:
GlStateManager.translatef(0F, -0.15F, 0F);
renderItem(stack);
break;
case PUFFY_SCARF:
GlStateManager.translatef(0F, -0.15F, 0F);
renderItem(stack);
break;
case WITCH_PIN:
scale(0.35F);
GlStateManager.translatef(-0.35F, 0.35F, 0.15F);
renderItem(stack);
break;
case DEVIL_TAIL:
GlStateManager.rotatef(90F, 0F, 1F, 0F);
GlStateManager.translatef(0.5F, -0.75F, 0F);
renderItem(stack);
break;
case KAMUI_EYE: // DON'T LOSE YOUR WAAAAAAAAY
scale(0.9F);
GlStateManager.translatef(0.9F, 0.35F, 0F);
renderItem(stack);
GlStateManager.translatef(-1.3F, -0.5F, 0.5F);
GlStateManager.rotatef(180F, 0F, 0F, 1F);
GlStateManager.rotatef(180F, 1F, 0F, 0F);
renderKamuiBlack(stack);
break;
case FOUR_LEAF_CLOVER:
scale(0.5F);
GlStateManager.translatef(0.35F, 0.3F, -0.075F);
renderItem(stack);
break;
case BOTANIST_EMBLEM:
scale(0.5F);
GlStateManager.translatef(0F, -0.75F, 0F);
renderItem(stack);
break;
case LUSITANIC_SHIELD:
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.translatef(0.035F, -0.2F, 0.55F);
GlStateManager.rotatef(8F, 0F, 0F, 1F);
renderItem(stack);
break;
default: break;
}
}
}
}
}
}
public static void scale(float f) {
@@ -47,7 +47,6 @@ import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.integration.curios.RenderableCurio;
import java.awt.Color;
import java.util.List;
@@ -95,59 +94,53 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
}
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onCurioTick(String identifier, LivingEntity player) {
Brew brew = ((IBrewItem) stack.getItem()).getBrew(stack);
if(brew != BotaniaAPI.fallbackBrew && player instanceof PlayerEntity && !player.world.isRemote) {
PlayerEntity eplayer = (PlayerEntity) player;
EffectInstance effect = brew.getPotionEffects(stack).get(0);
float cost = (float) brew.getManaCost(stack) / effect.getDuration() / (1 + effect.getAmplifier()) * 2.5F;
boolean doRand = cost < 1;
if(ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), false)) {
EffectInstance currentEffect = player.getActivePotionEffect(effect.getPotion());
boolean nightVision = effect.getPotion() == Effects.NIGHT_VISION;
if(currentEffect == null || currentEffect.getDuration() < (nightVision ? 305 : 3)) {
EffectInstance applyEffect = new EffectInstance(effect.getPotion(), nightVision ? 385 : 80, effect.getAmplifier(), true, true);
player.addPotionEffect(applyEffect);
}
if(!doRand || Math.random() < cost)
ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), true);
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
Brew brew = ((IBrewItem) stack.getItem()).getBrew(stack);
if (brew != BotaniaAPI.fallbackBrew && player instanceof EntityPlayer && !player.world.isRemote) {
EntityPlayer eplayer = (EntityPlayer) player;
PotionEffect effect = brew.getPotionEffects(stack).get(0);
float cost = (float) brew.getManaCost(stack) / effect.getDuration() / (1 + effect.getAmplifier()) * 2.5F;
boolean doRand = cost < 1;
if (ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), false)) {
PotionEffect currentEffect = player.getActivePotionEffect(effect.getPotion());
boolean nightVision = effect.getPotion() == MobEffects.NIGHT_VISION;
if (currentEffect == null || currentEffect.getDuration() < (nightVision ? 305 : 3)) {
PotionEffect applyEffect = new PotionEffect(effect.getPotion(), nightVision ? 385 : 80, effect.getAmplifier(), true, true);
player.addPotionEffect(applyEffect);
}
if (!doRand || Math.random() < cost)
ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), true);
}
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
AccessoryRenderHelper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EquipmentSlotType.CHEST).isEmpty();
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.26F, -0.4F, armor ? 0.2F : 0.15F);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
AccessoryRenderHelper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.26F, -0.4F, armor ? 0.2F : 0.15F);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
for(TextureAtlasSprite icon : new TextureAtlasSprite[] { MiscellaneousIcons.INSTANCE.bloodPendantChain, MiscellaneousIcons.INSTANCE.bloodPendantGem }) {
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
float f3 = icon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getWidth(), icon.getHeight(), 1F / 32F);
for (TextureAtlasSprite icon : new TextureAtlasSprite[]{MiscellaneousIcons.INSTANCE.bloodPendantChain, MiscellaneousIcons.INSTANCE.bloodPendantGem}) {
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
float f3 = icon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getWidth(), icon.getHeight(), 1F / 32F);
Color color = new Color(Minecraft.getInstance().getItemColors().getColor(stack, 1));
GlStateManager.color3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F);
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lightmapX, lightmapY);
}
GlStateManager.color3f(1, 1, 1);
Color color = new Color(Minecraft.getInstance().getItemColors().getColor(stack, 1));
GlStateManager.color3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F);
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY);
}
GlStateManager.color3f(1, 1, 1);
}
@Override
@@ -28,7 +28,6 @@ import net.minecraftforge.fml.DistExecutor;
import vazkii.botania.api.item.AccessoryRenderHelper;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.integration.curios.RenderableCurio;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.network.PacketHandler;
import vazkii.botania.common.network.PacketJump;
@@ -42,52 +41,46 @@ public class ItemCloudPendant extends ItemBauble {
super(props);
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
if(player instanceof EntityPlayerSP && player == Minecraft.getInstance().player) {
EntityPlayerSP playerSp = (EntityPlayerSP) player;
@Override
public void onCurioTick(String identifier, LivingEntity player) {
DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
if(player instanceof ClientPlayerEntity && player == Minecraft.getInstance().player) {
ClientPlayerEntity playerSp = (ClientPlayerEntity) player;
if(playerSp.onGround)
timesJumped = 0;
else {
if(playerSp.movementInput.jump) {
if(!jumpDown && timesJumped < ((ItemCloudPendant) stack.getItem()).getMaxAllowedJumps()) {
playerSp.jump();
PacketHandler.sendToServer(new PacketJump());
timesJumped++;
}
jumpDown = true;
} else jumpDown = false;
}
if (playerSp.onGround)
timesJumped = 0;
else {
if(playerSp.movementInput.jump) {
if (!jumpDown && timesJumped < ((ItemCloudPendant) stack.getItem()).getMaxAllowedJumps()) {
playerSp.jump();
PacketHandler.sendToServer(new PacketJump());
timesJumped++;
}
jumpDown = true;
} else jumpDown = false;
}
});
}
}
});
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
AccessoryRenderHelper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EquipmentSlotType.CHEST).isEmpty();
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.2F, -0.3F, armor ? 0.2F : 0.15F);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
AccessoryRenderHelper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.2F, -0.3F, armor ? 0.2F : 0.15F);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
TextureAtlasSprite gemIcon = stack.getItem() == ModItems.superCloudPendant
? MiscellaneousIcons.INSTANCE.nimbusGem
: MiscellaneousIcons.INSTANCE.cirrusGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F);
}
TextureAtlasSprite gemIcon = stack.getItem() == ModItems.superCloudPendant
? MiscellaneousIcons.INSTANCE.nimbusGem
: MiscellaneousIcons.INSTANCE.cirrusGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F);
}
public int getMaxAllowedJumps() {
@@ -30,20 +30,17 @@ import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.api.item.AccessoryRenderHelper;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.subtile.functional.SubTileHeiseiDream;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.integration.curios.RenderableCurio;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.network.PacketBotaniaEffect;
import vazkii.botania.common.network.PacketHandler;
@@ -58,11 +55,11 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem {
}
private void onEntityDamaged(LivingHurtEvent event) {
if (event.getSource().getImmediateSource() instanceof PlayerEntity && event.getEntityLiving() instanceof MobEntity && !event.getEntityLiving().world.isRemote && Math.random() < 0.6F) {
if(event.getSource().getImmediateSource() instanceof EntityPlayer && event.getEntityLiving() instanceof EntityLiving && !event.getEntityLiving().world.isRemote && Math.random() < 0.6F) {
Runnable lambda = () -> {
MobEntity target = (MobEntity) event.getEntityLiving();
PlayerEntity player = (PlayerEntity) event.getSource().getImmediateSource();
ItemStack amulet = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(ModItems.divaCharm, player) : ItemStack.EMPTY;
EntityLiving target = (EntityLiving) event.getEntityLiving();
EntityPlayer player = (EntityPlayer) event.getSource().getImmediateSource();
ItemStack amulet = EquipmentHandler.findOrEmpty(ModItems.divaCharm, player);
if(!amulet.isEmpty()) {
final int cost = 250;
@@ -100,21 +97,15 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem {
return true;
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
AccessoryRenderHelper.translateToHeadLevel(player);
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
GlStateManager.scaled(0.8, 0.8, 0.8);
GlStateManager.rotatef(-90, 0, 1, 0);
GlStateManager.rotatef(180, 1, 0, 0);
GlStateManager.translated(0.1625, -1.625, 0.40);
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND);
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
AccessoryRenderHelper.translateToHeadLevel(player);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.scaled(0.8, 0.8, 0.8);
GlStateManager.rotatef(-90, 0, 1, 0);
GlStateManager.rotatef(180, 1, 0, 0);
GlStateManager.translated(0.1625, -1.625, 0.40);
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND);
}
}
@@ -17,18 +17,15 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibMisc;
import vazkii.botania.common.network.PacketDodge;
@@ -54,7 +51,7 @@ public class ItemDodgeRing extends ItemBauble {
if(mc.player == null)
return;
ItemStack ringStack = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(ModItems.dodgeRing, mc.player) : ItemStack.EMPTY;
ItemStack ringStack = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, mc.player);
if(ringStack.isEmpty() || ItemNBTHelper.getInt(ringStack, TAG_DODGE_COOLDOWN, 0) > 0)
return;
@@ -77,17 +74,12 @@ public class ItemDodgeRing extends ItemBauble {
oldRightDown = mc.gameSettings.keyBindRight.isKeyDown();
}
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onCurioTick(String identifier, LivingEntity player) {
int cd = ItemNBTHelper.getInt(stack, TAG_DODGE_COOLDOWN, 0);
if(cd > 0)
ItemNBTHelper.setInt(stack, TAG_DODGE_COOLDOWN, cd - 1);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
int cd = ItemNBTHelper.getInt(stack, TAG_DODGE_COOLDOWN, 0);
if(cd > 0)
ItemNBTHelper.setInt(stack, TAG_DODGE_COOLDOWN, cd - 1);
}
private static void dodge(PlayerEntity player, boolean left) {
@@ -34,14 +34,13 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.lwjgl.opengl.GL11;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.api.item.AccessoryRenderHelper;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
@@ -52,12 +51,11 @@ import vazkii.botania.client.core.helper.ShaderHelper;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.core.helper.StringObfuscator;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.integration.curios.RenderableCurio;
import vazkii.botania.common.item.ModItems;
import javax.annotation.Nonnull;
@@ -111,9 +109,9 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
@SubscribeEvent
public void updatePlayerFlyStatus(LivingUpdateEvent event) {
if(event.getEntityLiving() instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) event.getEntityLiving();
ItemStack tiara = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(ModItems.flightTiara, player) : ItemStack.EMPTY;
if(event.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
ItemStack tiara = EquipmentHandler.findOrEmpty(ModItems.flightTiara, player);
int left = ItemNBTHelper.getInt(tiara, TAG_TIME_LEFT, MAX_FLY_TIME);
if(playersWithFlight.contains(playerStr(player))) {
@@ -211,8 +209,8 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
return player.getGameProfile().getName() + ":" + player.world.isRemote;
}
private boolean shouldPlayerHaveFlight(PlayerEntity player) {
ItemStack armor = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(ModItems.flightTiara, player) : ItemStack.EMPTY;
private boolean shouldPlayerHaveFlight(EntityPlayer player) {
ItemStack armor = EquipmentHandler.findOrEmpty(ModItems.flightTiara, player);
if(!armor.isEmpty()) {
int left = ItemNBTHelper.getInt(armor, TAG_TIME_LEFT, MAX_FLY_TIME);
boolean flying = ItemNBTHelper.getBoolean(armor, TAG_FLYING, false);
@@ -231,216 +229,210 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem {
return true;
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
@Override
public void onEquipped(ItemStack stack, EntityLivingBase living) {
super.onEquipped(stack, living);
int variant = ItemNBTHelper.getInt(stack, TAG_VARIANT, 0);
if(variant != WING_TYPES && StringObfuscator.matchesHash(stack.getDisplayName().getString(), SUPER_AWESOME_HASH)) {
ItemNBTHelper.setInt(stack, TAG_VARIANT, WING_TYPES);
stack.clearCustomName();
}
}
@Override
public void onEquipped(String identifier, LivingEntity living) {
super.onEquipped(identifier, living);
int variant = ItemNBTHelper.getInt(stack, TAG_VARIANT, 0);
if(variant != WING_TYPES && StringObfuscator.matchesHash(stack.getDisplayName().getString(), SUPER_AWESOME_HASH)) {
ItemNBTHelper.setInt(stack, TAG_VARIANT, WING_TYPES);
stack.clearCustomName();
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
if(player instanceof EntityPlayer) {
EntityPlayer p = (EntityPlayer) player;
boolean flying = p.abilities.isFlying;
boolean wasSprting = ItemNBTHelper.getBoolean(stack, TAG_IS_SPRINTING, false);
boolean isSprinting = p.isSprinting();
if(isSprinting != wasSprting)
ItemNBTHelper.setBoolean(stack, TAG_IS_SPRINTING, isSprinting);
int time = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME);
int newTime = time;
Vector3 look = new Vector3(p.getLookVec()).multiply(1, 0, 1).normalize();
if(flying) {
if(time > 0 && !ItemNBTHelper.getBoolean(stack, TAG_INFINITE_FLIGHT, false))
newTime--;
final int maxCd = 80;
int cooldown = ItemNBTHelper.getInt(stack, TAG_DASH_COOLDOWN, 0);
if(!wasSprting && isSprinting && cooldown == 0) {
p.motionX += look.x;
p.motionZ += look.z;
p.world.playSound(null, p.posX, p.posY, p.posZ, ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F);
ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, maxCd);
} else if(cooldown > 0) {
if(maxCd - cooldown < 2)
player.moveRelative(0F, 0F, 1F, 5F);
else if(maxCd - cooldown < 10)
player.setSprinting(false);
ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, cooldown - 2);
}
} else if(!flying) {
boolean doGlide = player.isSneaking() && !player.onGround && player.fallDistance >= 2F;
if(time < MAX_FLY_TIME && player.ticksExisted % (doGlide ? 6 : 2) == 0)
newTime++;
if(doGlide) {
player.motionY = Math.max(-0.15F, player.motionY);
float mul = 0.6F;
player.motionX = look.x * mul;
player.motionZ = look.z * mul;
player.fallDistance = 2F;
}
}
ItemNBTHelper.setBoolean(stack, TAG_FLYING, flying);
if(newTime != time)
ItemNBTHelper.setInt(stack, TAG_TIME_LEFT, newTime);
}
}
@Override
public void onCurioTick(String identifier, LivingEntity player) {
if(player instanceof PlayerEntity) {
PlayerEntity p = (PlayerEntity) player;
boolean flying = p.abilities.isFlying;
@Override
public boolean shouldSyncToTracking(ItemStack stack, EntityLivingBase living) {
return true;
}
boolean wasSprting = ItemNBTHelper.getBoolean(stack, TAG_IS_SPRINTING, false);
boolean isSprinting = p.isSprinting();
if(isSprinting != wasSprting)
ItemNBTHelper.setBoolean(stack, TAG_IS_SPRINTING, isSprinting);
@Override
public boolean hasRender(ItemStack stack, EntityLivingBase living) {
return super.hasRender(stack, living) && living instanceof EntityPlayer;
}
int time = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME);
int newTime = time;
Vector3 look = new Vector3(p.getLookVec()).multiply(1, 0, 1).normalize();
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
int meta = ItemNBTHelper.getInt(stack, TAG_VARIANT, 0);
if(meta > 0 && meta <= MiscellaneousIcons.INSTANCE.tiaraWingIcons.length) {
TextureAtlasSprite icon = MiscellaneousIcons.INSTANCE.tiaraWingIcons[meta - 1];
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
if(flying) {
if(time > 0 && !ItemNBTHelper.getBoolean(stack, TAG_INFINITE_FLIGHT, false))
newTime--;
final int maxCd = 80;
int cooldown = ItemNBTHelper.getInt(stack, TAG_DASH_COOLDOWN, 0);
if(!wasSprting && isSprinting && cooldown == 0) {
p.motionX += look.x;
p.motionZ += look.z;
p.world.playSound(null, p.posX, p.posY, p.posZ, ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F);
ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, maxCd);
} else if(cooldown > 0) {
if(maxCd - cooldown < 2)
player.moveRelative(0F, 0F, 1F, 5F);
else if(maxCd - cooldown < 10)
player.setSprinting(false);
ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, cooldown - 2);
}
} else if(!flying) {
boolean doGlide = player.isSneaking() && !player.onGround && player.fallDistance >= 2F;
if(time < MAX_FLY_TIME && player.ticksExisted % (doGlide ? 6 : 2) == 0)
newTime++;
boolean flying = ((EntityPlayer) player).abilities.isFlying;
if(doGlide) {
player.motionY = Math.max(-0.15F, player.motionY);
float mul = 0.6F;
player.motionX = look.x * mul;
player.motionZ = look.z * mul;
player.fallDistance = 2F;
}
}
float rz = 120F;
float rx = 20F + (float) ((Math.sin((double) (player.ticksExisted + partialTicks) * (flying ? 0.4F : 0.2F)) + 0.5F) * (flying ? 30F : 5F));
float ry = 0F;
float h = 0.2F;
float i = 0.15F;
float s = 1F;
ItemNBTHelper.setBoolean(stack, TAG_FLYING, flying);
if(newTime != time)
ItemNBTHelper.setInt(stack, TAG_TIME_LEFT, newTime);
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.color4f(1F, 1F, 1F, 1F);
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
float lbx = OpenGlHelper.lastBrightnessX;
float lby = OpenGlHelper.lastBrightnessY;
switch (meta) {
case 1: { // Jibril
h = 0.4F;
break;
}
case 2: { // Sephiroth
s = 1.3F;
break;
}
case 3: { // Cirno
h = -0.1F;
rz = 0F;
rx = 0F;
i = 0.3F;
break;
}
case 4: { // Phoenix
rz = 180F;
h = 0.5F;
rx = 20F;
ry = -(float) ((Math.sin((double) (player.ticksExisted + partialTicks) * (flying ? 0.4F : 0.2F)) + 0.6F) * (flying ? 30F : 5F));
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY);
break;
}
case 5: { // Kuroyukihime
h = 0.8F;
rz = 180F;
ry = -rx;
rx = 0F;
s = 2F;
break;
}
case 6: { // Random Devil
rz = 150F;
break;
}
case 7: { // Lyfa
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY);
h = -0.1F;
rz = 0F;
ry = -rx;
rx = 0F;
GlStateManager.color4f(1F, 1F, 1F, 0.5F + (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.2F);
break;
}
case 8: { // Mega Ultra Chicken
h = 0.1F;
break;
}
case 9: { // The One
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY);
rz = 180F;
rx = 0F;
h = 1.1F;
ry = -(float) ((Math.sin((double) (player.ticksExisted + partialTicks) * 0.2F) + 0.6F) * (flying ? 12F : 5F));
GlStateManager.color4f(1F, 1F, 1F, 0.5F + (flying ? (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.25F + 0.25F : 0F));
}
}
}
@Override
public boolean shouldSyncToTracking(String identifier, LivingEntity living) {
return true;
}
// account for padding in the texture
float mul = 32F / 20F;
s *= mul;
@Override
public boolean hasRender(String identifier, LivingEntity living) {
return super.hasRender(identifier, living) && living instanceof PlayerEntity;
}
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
float f3 = icon.getMaxV();
float sr = 1F / s;
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
int meta = ItemNBTHelper.getInt(stack, TAG_VARIANT, 0);
if(meta > 0 && meta <= MiscellaneousIcons.INSTANCE.tiaraWingIcons.length) {
TextureAtlasSprite icon = MiscellaneousIcons.INSTANCE.tiaraWingIcons[meta - 1];
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
AccessoryRenderHelper.rotateIfSneaking(player);
boolean flying = ((PlayerEntity) player).abilities.isFlying;
GlStateManager.translatef(0F, h, i);
float rz = 120F;
float rx = 20F + (float) ((Math.sin((double) (player.ticksExisted + partialTicks) * (flying ? 0.4F : 0.2F)) + 0.5F) * (flying ? 30F : 5F));
float ry = 0F;
float h = 0.2F;
float i = 0.15F;
float s = 1F;
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.color4f(1F, 1F, 1F, 1F);
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
float lbx = GLX.lastBrightnessX;
float lby = GLX.lastBrightnessY;
switch(meta) {
case 1 : { // Jibril
h = 0.4F;
break;
}
case 2 : { // Sephiroth
s = 1.3F;
break;
}
case 3 : { // Cirno
h = -0.1F;
rz = 0F;
rx = 0F;
i = 0.3F;
break;
}
case 4 : { // Phoenix
rz = 180F;
h = 0.5F;
rx = 20F;
ry = -(float) ((Math.sin((double) (player.ticksExisted + partialTicks) * (flying ? 0.4F : 0.2F)) + 0.6F) * (flying ? 30F : 5F));
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lightmapX, lightmapY);
break;
}
case 5 : { // Kuroyukihime
h = 0.8F;
rz = 180F;
ry = -rx;
rx = 0F;
s = 2F;
break;
}
case 6 : { // Random Devil
rz = 150F;
break;
}
case 7 : { // Lyfa
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lightmapX, lightmapY);
h = -0.1F;
rz = 0F;
ry = -rx;
rx = 0F;
GlStateManager.color4f(1F, 1F, 1F, 0.5F + (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.2F);
break;
}
case 8 : { // Mega Ultra Chicken
h = 0.1F;
break;
}
case 9 : { // The One
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lightmapX, lightmapY);
rz = 180F;
rx = 0F;
h = 1.1F;
ry = -(float) ((Math.sin((double) (player.ticksExisted + partialTicks) * 0.2F) + 0.6F) * (flying ? 12F : 5F));
GlStateManager.color4f(1F, 1F, 1F, 0.5F + (flying ? (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.25F + 0.25F : 0F));
}
}
// account for padding in the texture
float mul = 32F / 20F;
s *= mul;
float f = icon.getMinU();
float f1 = icon.getMaxU();
float f2 = icon.getMinV();
float f3 = icon.getMaxV();
float sr = 1F / s;
AccessoryRenderHelper.rotateIfSneaking(player);
GlStateManager.translatef(0F, h, i);
GlStateManager.rotatef(rz, 0F, 0F, 1F);
GlStateManager.rotatef(rx, 1F, 0F, 0F);
GlStateManager.rotatef(ry, 0F, 1F, 0F);
GlStateManager.scalef(s, s, s);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getWidth(), icon.getHeight(), 1F / 32F);
GlStateManager.scalef(sr, sr, sr);
GlStateManager.rotatef(-ry, 0F, 1F, 0F);
GlStateManager.rotatef(-rx, 1F, 0F, 0F);
GlStateManager.rotatef(-rz, 0F, 0F, 1F);
if(meta != 2) { // Sephiroth
GlStateManager.scalef(-1F, 1F, 1F);
GlStateManager.rotatef(rz, 0F, 0F, 1F);
GlStateManager.rotatef(rx, 1F, 0F, 0F);
GlStateManager.rotatef(ry, 0F, 1F, 0F);
GlStateManager.scalef(s, s, s);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getWidth(), icon.getHeight(), 1F / 32F);
GlStateManager.scalef(sr, sr, sr);
GlStateManager.rotatef(-ry, 0F, 1F, 0F);
GlStateManager.rotatef(-ry, 1F, 0F, 0F);
GlStateManager.rotatef(-rx, 1F, 0F, 0F);
GlStateManager.rotatef(-rz, 0F, 0F, 1F);
if(meta != 2) { // Sephiroth
GlStateManager.scalef(-1F, 1F, 1F);
GlStateManager.rotatef(rz, 0F, 0F, 1F);
GlStateManager.rotatef(rx, 1F, 0F, 0F);
GlStateManager.rotatef(ry, 0F, 1F, 0F);
GlStateManager.scalef(s, s, s);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getWidth(), icon.getHeight(), 1F / 32F);
GlStateManager.scalef(sr, sr, sr);
GlStateManager.rotatef(-ry, 1F, 0F, 0F);
GlStateManager.rotatef(-rx, 1F, 0F, 0F);
GlStateManager.rotatef(-rz, 0F, 0F, 1F);
}
GlStateManager.color3f(1F, 1F, 1F);
GlStateManager.popMatrix();
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lbx, lby);
if(meta == 1)
renderHalo(player, partialTicks);
}
GlStateManager.color3f(1F, 1F, 1F);
GlStateManager.popMatrix();
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lbx, lby);
if(meta == 1)
renderHalo(player, partialTicks);
}
}
@@ -21,18 +21,15 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.Explosion;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.world.ExplosionEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.api.item.AccessoryRenderHelper;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.Botania;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.integration.curios.RenderableCurio;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibMisc;
@@ -53,8 +50,8 @@ public class ItemGoddessCharm extends ItemBauble implements IManaUsingItem {
Vec3d vec = e.getPosition();
List<PlayerEntity> players = event.getWorld().getEntitiesWithinAABB(PlayerEntity.class, new AxisAlignedBB(vec.x, vec.y, vec.z, vec.x, vec.y, vec.z).grow(8));
for(PlayerEntity player : players) {
ItemStack charm = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(ModItems.goddessCharm, player) : ItemStack.EMPTY;
for(EntityPlayer player : players) {
ItemStack charm = EquipmentHandler.findOrEmpty(ModItems.goddessCharm, player);
if(!charm.isEmpty() && ManaItemHandler.requestManaExact(charm, player, COST, true)) {
event.getAffectedBlocks().clear();
return;
@@ -62,23 +59,17 @@ public class ItemGoddessCharm extends ItemBauble implements IManaUsingItem {
}
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
GlStateManager.pushMatrix();
AccessoryRenderHelper.translateToHeadLevel(player);
AccessoryRenderHelper.translateToFace();
AccessoryRenderHelper.defaultTransforms();
GlStateManager.rotatef(-90F, 0F, 1F, 0F);
GlStateManager.translatef(0.5F, 0.2F, 0.45F);
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
GlStateManager.popMatrix();
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
GlStateManager.pushMatrix();
AccessoryRenderHelper.translateToHeadLevel(player);
AccessoryRenderHelper.translateToFace();
AccessoryRenderHelper.defaultTransforms();
GlStateManager.rotatef(-90F, 0F, 1F, 0F);
GlStateManager.translatef(0.5F, 0.2F, 0.45F);
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
GlStateManager.popMatrix();
}
@Override
@@ -15,7 +15,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import vazkii.botania.api.mana.IManaGivingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.integration.curios.BaseCurio;
public class ItemGreaterAuraRing extends ItemBauble implements IManaGivingItem {
@@ -23,15 +22,9 @@ public class ItemGreaterAuraRing extends ItemBauble implements IManaGivingItem {
super(props);
}
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onCurioTick(String identifier, LivingEntity player) {
if(player instanceof PlayerEntity && player.ticksExisted % 2 == 0)
ManaItemHandler.dispatchManaExact(stack, (PlayerEntity) player, 1, true);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
if (player instanceof EntityPlayer && player.ticksExisted % 2 == 0)
ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 1, true);
}
}
@@ -10,8 +10,6 @@
*/
package vazkii.botania.common.item.equipment.bauble;
import vazkii.botania.common.lib.LibItemNames;
public class ItemGreaterMagnetRing extends ItemMagnetRing {
public ItemGreaterMagnetRing(Properties props) {
@@ -11,7 +11,6 @@
package vazkii.botania.common.item.equipment.bauble;
import net.minecraft.item.ItemStack;
import vazkii.botania.common.lib.LibItemNames;
public class ItemGreaterManaRing extends ItemManaRing {
@@ -20,19 +20,17 @@ import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import top.theillusivec4.curios.api.CuriosAPI;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import vazkii.botania.api.item.AccessoryRenderHelper;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.client.model.ModelCloak;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.integration.curios.RenderableCurio;
public class ItemHolyCloak extends ItemBauble {
@@ -51,9 +49,9 @@ public class ItemHolyCloak extends ItemBauble {
}
private void onPlayerDamage(LivingHurtEvent event) {
if(event.getEntityLiving() instanceof PlayerEntity && !event.getSource().canHarmInCreative()) {
PlayerEntity player = (PlayerEntity) event.getEntityLiving();
ItemStack stack = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(s -> s.getItem() instanceof ItemHolyCloak, player) : ItemStack.EMPTY;
if(event.getEntityLiving() instanceof EntityPlayer && !event.getSource().canHarmInCreative()) {
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
ItemStack stack = EquipmentHandler.findOrEmpty(this, player);
if(!stack.isEmpty() && !isInEffect(stack)) {
ItemHolyCloak cloak = (ItemHolyCloak) stack.getItem();
@@ -68,44 +66,38 @@ public class ItemHolyCloak extends ItemBauble {
}
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase living) {
int cooldown = getCooldown(stack);
if(cooldown > 0)
setCooldown(stack, cooldown - 1);
}
@Override
public void onCurioTick(String identifier, LivingEntity living) {
int cooldown = getCooldown(stack);
if(cooldown > 0)
setCooldown(stack, cooldown - 1);
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
ItemHolyCloak item = ((ItemHolyCloak) stack.getItem());
AccessoryRenderHelper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.translatef(0F, armor ? -0.07F : -0.01F, 0F);
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
ItemHolyCloak item = ((ItemHolyCloak) stack.getItem());
AccessoryRenderHelper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EquipmentSlotType.CHEST).isEmpty();
GlStateManager.translatef(0F, armor ? -0.07F : -0.01F, 0F);
float s = 1F / 16F;
GlStateManager.scalef(s, s, s);
if(model == null)
model = new ModelCloak();
float s = 1F / 16F;
GlStateManager.scalef(s, s, s);
if(model == null)
model = new ModelCloak();
GlStateManager.enableLighting();
GlStateManager.enableRescaleNormal();
GlStateManager.enableLighting();
GlStateManager.enableRescaleNormal();
Minecraft.getInstance().textureManager.bindTexture(item.getCloakTexture());
model.render(1F);
Minecraft.getInstance().textureManager.bindTexture(item.getCloakTexture());
model.render(1F);
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, lightmapX, lightmapY);
Minecraft.getInstance().textureManager.bindTexture(item.getCloakGlowTexture());
model.render(1F);
}
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY);
Minecraft.getInstance().textureManager.bindTexture(item.getCloakGlowTexture());
model.render(1F);
}
public boolean effectOnDamage(LivingHurtEvent event, PlayerEntity player, ItemStack stack) {
@@ -27,8 +27,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.integration.curios.RenderableCurio;
public class ItemIcePendant extends ItemBauble {
@@ -36,38 +34,32 @@ public class ItemIcePendant extends ItemBauble {
super(props);
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onCurioTick(String type, LivingEntity entity) {
if(!entity.world.isRemote) {
boolean lastOnGround = entity.onGround;
entity.onGround = true;
FrostWalkerEnchantment.freezeNearby(entity, entity.world, new BlockPos(entity), 8);
entity.onGround = lastOnGround;
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
boolean armor = !player.getItemStackFromSlot(EquipmentSlotType.CHEST).isEmpty();
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.36F, -0.3F, armor ? 0.2F : 0.15F);
GlStateManager.rotatef(-45F, 0F, 0F, 1F);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.snowflakePendantGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F);
@Override
public void onWornTick(ItemStack stack, EntityLivingBase entity) {
if(!entity.world.isRemote) {
boolean lastOnGround = entity.onGround;
entity.onGround = true;
EnchantmentFrostWalker.freezeNearby(entity, entity.world, new BlockPos(entity), 8);
entity.onGround = lastOnGround;
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.36F, -0.3F, armor ? 0.2F : 0.15F);
GlStateManager.rotatef(-45F, 0F, 0F, 1F);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.snowflakePendantGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F);
}
}
@@ -20,8 +20,6 @@ import net.minecraft.potion.Effects;
import net.minecraft.potion.EffectInstance;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.lib.LibItemNames;
public class ItemInvisibilityCloak extends ItemBauble implements IManaUsingItem {
@@ -29,31 +27,25 @@ public class ItemInvisibilityCloak extends ItemBauble implements IManaUsingItem
super(props);
}
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
PotionEffect effect = player.getActivePotionEffect(MobEffects.INVISIBILITY);
if(effect != null && player instanceof EntityPlayer && effect.getAmplifier() == -42)
player.removePotionEffect(MobEffects.INVISIBILITY);
}
@Override
public void onUnequipped(String identifier, LivingEntity player) {
EffectInstance effect = player.getActivePotionEffect(Effects.INVISIBILITY);
if(effect != null && player instanceof PlayerEntity && effect.getAmplifier() == -42)
player.removePotionEffect(Effects.INVISIBILITY);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
if(player instanceof EntityPlayer && !player.world.isRemote) {
int manaCost = 2;
boolean hasMana = ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, false);
if(!hasMana)
onUnequipped(stack, player);
else {
if(player.getActivePotionEffect(MobEffects.INVISIBILITY) != null)
player.removePotionEffect(MobEffects.INVISIBILITY);
@Override
public void onCurioTick(String identifier, LivingEntity player) {
if(player instanceof PlayerEntity && !player.world.isRemote) {
int manaCost = 2;
boolean hasMana = ManaItemHandler.requestManaExact(stack, (PlayerEntity) player, manaCost, false);
if(!hasMana)
onUnequipped(identifier, player);
else {
if(player.getActivePotionEffect(Effects.INVISIBILITY) != null)
player.removePotionEffect(Effects.INVISIBILITY);
player.addPotionEffect(new EffectInstance(Effects.INVISIBILITY, Integer.MAX_VALUE, -42, true, true));
}
player.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, Integer.MAX_VALUE, -42, true, true));
}
}
}
@@ -37,9 +37,9 @@ import net.minecraft.util.Direction;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.village.MerchantRecipe;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
@@ -50,8 +50,6 @@ import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.integration.curios.RenderableCurio;
import vazkii.botania.common.item.ModItems;
import java.util.ArrayList;
import java.util.Collection;
@@ -66,43 +64,37 @@ public class ItemItemFinder extends ItemBauble {
super(props);
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
if(!(player instanceof EntityPlayer))
return;
@Override
public void onCurioTick(String identifier, LivingEntity player) {
if(!(player instanceof PlayerEntity))
return;
if(player.world.isRemote)
this.tickClient(stack, (EntityPlayer) player);
else this.tickServer(stack, (EntityPlayer) player);
}
if(player.world.isRemote)
((ItemItemFinder) ModItems.itemFinder).tickClient(stack, (PlayerEntity) player);
else ((ItemItemFinder) ModItems.itemFinder).tickServer(stack, (PlayerEntity) player);
}
@Override
public boolean shouldSyncToTracking(ItemStack stack, EntityLivingBase living) {
return true;
}
@Override
public boolean shouldSyncToTracking(String identifier, LivingEntity living) {
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.itemFinderGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
boolean armor = !living.getItemStackFromSlot(EquipmentSlotType.HEAD).isEmpty();
AccessoryRenderHelper.translateToHeadLevel(living);
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
GlStateManager.rotatef(90F, 0F, 1F, 0F);
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.4F, -1.4F, armor ? -0.3F : -0.25F);
GlStateManager.scalef(0.75F, 0.75F, 0.75F);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 16F);
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.itemFinderGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
boolean armor = !living.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty();
AccessoryRenderHelper.translateToHeadLevel(living);
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.rotatef(90F, 0F, 1F, 0F);
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.4F, -1.4F, armor ? -0.3F : -0.25F);
GlStateManager.scalef(0.75F, 0.75F, 0.75F);
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 16F);
}
protected void tickClient(ItemStack stack, PlayerEntity player) {
@@ -120,7 +112,7 @@ public class ItemItemFinder extends ItemBauble {
int[] entities = ItemNBTHelper.getIntArray(stack, TAG_ENTITY_POSITIONS);
for(int i : entities) {
Entity e = player.world.getEntityByID(i);
Entity e = player.world.getEntityByID(i);
if(e != null && Math.random() < 0.6) {
Botania.proxy.setWispFXDepthTest(Math.random() < 0.6);
Botania.proxy.wispFX(e.posX + (float) (Math.random() * 0.5 - 0.25) * 0.45F, e.posY + e.height, e.posZ + (float) (Math.random() * 0.5 - 0.25) * 0.45F, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.15F + 0.05F * (float) Math.random(), -0.05F - 0.03F * (float) Math.random());
@@ -23,7 +23,6 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.integration.curios.RenderableCurio;
public class ItemKnockbackBelt extends ItemBauble {
@@ -34,32 +33,26 @@ public class ItemKnockbackBelt extends ItemBauble {
super(props);
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public Multimap<String, AttributeModifier> getEquippedAttributeModifiers(ItemStack stack) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
attributes.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(getBaubleUUID(stack), "Knockback Belt", 1, 0).setSaved(false));
return attributes;
}
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(String identifier) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
attributes.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(getBaubleUUID(stack), "Knockback Belt", 1, 0).setSaved(false));
return attributes;
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(texture);
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(texture);
GlStateManager.translatef(0F, 0.2F, 0F);
GlStateManager.translatef(0F, 0.2F, 0F);
float s = 1.05F / 16F;
GlStateManager.scalef(s, s, s);
float s = 1.05F / 16F;
GlStateManager.scalef(s, s, s);
if(model == null)
model = new ModelBiped();
if(model == null)
model = new BipedModel();
model.bipedBody.render(1F);
}
model.bipedBody.render(1F);
}
}
@@ -24,7 +24,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.item.AccessoryRenderHelper;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.integration.curios.RenderableCurio;
public class ItemLavaPendant extends ItemBauble {
@@ -32,33 +31,27 @@ public class ItemLavaPendant extends ItemBauble {
super(props);
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
if(player.isBurning())
player.extinguish();
}
@Override
public void onCurioTick(String identifier, LivingEntity player) {
if(player.isBurning())
player.extinguish();
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
AccessoryRenderHelper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
GlStateManager.rotatef(180, 0, 0, 1);
GlStateManager.translated(-0.5, -0.90, armor ? -0.4 : -0.25);
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
AccessoryRenderHelper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EquipmentSlotType.CHEST).isEmpty();
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
GlStateManager.rotatef(180, 0, 0, 1);
GlStateManager.translated(-0.5, -0.90, armor ? -0.4 : -0.25);
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.pyroclastGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F);
}
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.pyroclastGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F);
}
}
@@ -25,20 +25,16 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.item.ItemTossEvent;
import net.minecraftforge.items.IItemHandler;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.item.IRelic;
import vazkii.botania.api.mana.IManaItem;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.subtile.functional.SubTileSolegnolia;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.core.helper.MathHelper;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
import java.util.List;
@@ -64,51 +60,45 @@ public class ItemMagnetRing extends ItemBauble {
}
private void onTossItem(ItemTossEvent event) {
ItemStack ring = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(this, event.getPlayer()) : ItemStack.EMPTY;
ItemStack ring = EquipmentHandler.findOrEmpty(this, event.getPlayer());
if(!ring.isEmpty()) {
setCooldown(ring, 100);
}
}
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
int cooldown = getCooldown(stack);
if(SubTileSolegnolia.hasSolegnoliaAround(player)) {
if(cooldown < 0)
setCooldown(stack, 2);
return;
}
@Override
public void onCurioTick(String identifier, LivingEntity player) {
int cooldown = getCooldown(stack);
if(cooldown <= 0) {
if(player.isSneaking() == ConfigHandler.COMMON.invertMagnetRing.get()) {
double x = player.posX;
double y = player.posY + 0.75;
double z = player.posZ;
if(SubTileSolegnolia.hasSolegnoliaAround(player)) {
if(cooldown < 0)
setCooldown(stack, 2);
return;
}
int range = ((ItemMagnetRing) stack.getItem()).range;
List<EntityItem> items = player.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
int pulled = 0;
for(EntityItem item : items)
if(((ItemMagnetRing) stack.getItem()).canPullItem(item)) {
if(pulled > 200)
break;
if(cooldown <= 0) {
if(player.isSneaking() == ConfigHandler.COMMON.invertMagnetRing.get()) {
double x = player.posX;
double y = player.posY + 0.75;
double z = player.posZ;
int range = ((ItemMagnetRing) stack.getItem()).range;
List<ItemEntity> items = player.world.getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
int pulled = 0;
for(ItemEntity item : items)
if(((ItemMagnetRing) stack.getItem()).canPullItem(item)) {
if(pulled > 200)
break;
MathHelper.setEntityMotionFromVector(item, new Vector3(x, y, z), 0.45F);
if(player.world.isRemote) {
boolean red = player.world.rand.nextBoolean();
Botania.proxy.sparkleFX(item.posX, item.posY, item.posZ, red ? 1F : 0F, 0F, red ? 0F : 1F, 1F, 3);
}
pulled++;
MathHelper.setEntityMotionFromVector(item, new Vector3(x, y, z), 0.45F);
if(player.world.isRemote) {
boolean red = player.world.rand.nextBoolean();
Botania.proxy.sparkleFX(item.posX, item.posY, item.posZ, red ? 1F : 0F, 0F, red ? 0F : 1F, 1F, 3);
}
}
} else setCooldown(stack, cooldown - 1);
}
pulled++;
}
}
} else setCooldown(stack, cooldown - 1);
}
private boolean canPullItem(ItemEntity item) {
@@ -18,8 +18,6 @@ import net.minecraft.potion.Effects;
import net.minecraft.potion.EffectInstance;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.lib.LibItemNames;
public class ItemMiningRing extends ItemBauble implements IManaUsingItem {
@@ -27,38 +25,32 @@ public class ItemMiningRing extends ItemBauble implements IManaUsingItem {
super(props);
}
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
if(player instanceof EntityPlayer && !player.world.isRemote) {
int manaCost = 5;
boolean hasMana = ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, false);
if(!hasMana)
onUnequipped(stack, player);
else {
if(player.getActivePotionEffect(MobEffects.HASTE) != null)
player.removePotionEffect(MobEffects.HASTE);
@Override
public void onCurioTick(String identifier, LivingEntity player) {
if(player instanceof PlayerEntity && !player.world.isRemote) {
int manaCost = 5;
boolean hasMana = ManaItemHandler.requestManaExact(stack, (PlayerEntity) player, manaCost, false);
if(!hasMana)
onUnequipped(identifier, player);
else {
if(player.getActivePotionEffect(Effects.HASTE) != null)
player.removePotionEffect(Effects.HASTE);
player.addPotionEffect(new EffectInstance(Effects.HASTE, Integer.MAX_VALUE, 1, true, true));
}
if(player.swingProgress == 0.25F)
ManaItemHandler.requestManaExact(stack, (PlayerEntity) player, manaCost, true);
player.addPotionEffect(new PotionEffect(MobEffects.HASTE, Integer.MAX_VALUE, 1, true, true));
}
}
@Override
public void onUnequipped(String identifier, LivingEntity player) {
EffectInstance effect = player.getActivePotionEffect(Effects.HASTE);
if(effect != null && effect.getAmplifier() == 1)
player.removePotionEffect(Effects.HASTE);
if(player.swingProgress == 0.25F)
ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, true);
}
}
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
PotionEffect effect = player.getActivePotionEffect(MobEffects.HASTE);
if(effect != null && effect.getAmplifier() == 1)
player.removePotionEffect(MobEffects.HASTE);
}
@Override
public boolean usesMana(ItemStack stack) {
return true;
@@ -31,14 +31,11 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.api.item.AccessoryRenderHelper;
import vazkii.botania.api.item.IBurstViewerBauble;
import vazkii.botania.api.item.ICosmeticAttachable;
import vazkii.botania.api.item.ICosmeticBauble;
import vazkii.botania.common.Botania;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.integration.curios.RenderableCurio;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.item.ModItems;
public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosmeticBauble {
@@ -47,25 +44,19 @@ public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosm
super(props);
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty();
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
boolean armor = !player.getItemStackFromSlot(EquipmentSlotType.HEAD).isEmpty();
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
AccessoryRenderHelper.translateToHeadLevel(player);
AccessoryRenderHelper.translateToFace();
AccessoryRenderHelper.defaultTransforms();
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
GlStateManager.translatef(0.5F, -0.2F, armor ? 0.12F : 0F);
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
}
AccessoryRenderHelper.translateToHeadLevel(player);
AccessoryRenderHelper.translateToFace();
AccessoryRenderHelper.defaultTransforms();
GlStateManager.rotatef(180F, 0F, 1F, 0F);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
GlStateManager.translatef(0.5F, -0.2F, armor ? 0.12F : 0F);
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
}
@OnlyIn(Dist.CLIENT)
@@ -105,8 +96,8 @@ public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosm
mc.fontRenderer.drawStringWithShadow(text, x + 20, y + 4, 0xFFFFFF);
}
public static boolean hasMonocle(PlayerEntity player) {
ItemStack stack = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(ModItems.monocle, player) : ItemStack.EMPTY;
public static boolean hasMonocle(EntityPlayer player) {
ItemStack stack = EquipmentHandler.findOrEmpty(ModItems.monocle, player);
if(!stack.isEmpty()) {
Item item = stack.getItem();
if(item instanceof IBurstViewerBauble)
@@ -15,25 +15,17 @@ import com.google.common.collect.Multimap;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import vazkii.botania.common.integration.curios.BaseCurio;
public class ItemReachRing extends ItemBauble {
public ItemReachRing(Properties props) {
super(props);
}
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(String identifier) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
attributes.put(PlayerEntity.REACH_DISTANCE.getName(), new AttributeModifier(getBaubleUUID(stack), "Reach Ring", 3.5, 0).setSaved(false));
return attributes;
}
@Override
public Multimap<String, AttributeModifier> getEquippedAttributeModifiers(ItemStack stack) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
attributes.put(EntityPlayer.REACH_DISTANCE.getName(), new AttributeModifier(getBaubleUUID(stack), "Reach Ring", 3.5, 0).setSaved(false));
return attributes;
}
}
@@ -25,7 +25,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.item.AccessoryRenderHelper;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.integration.curios.RenderableCurio;
public class ItemSuperLavaPendant extends ItemBauble {
@@ -33,37 +32,32 @@ public class ItemSuperLavaPendant extends ItemBauble {
super(props);
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onCurioTick(String identifier, LivingEntity living) {
living.isImmuneToFire = true;
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase living) {
living.isImmuneToFire = true;
}
@Override
public void onUnequipped(String identifier, LivingEntity living) {
living.isImmuneToFire = false;
}
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase living) {
living.isImmuneToFire = false;
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
AccessoryRenderHelper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EquipmentSlotType.CHEST).isEmpty();
GlStateManager.scaled(0.5, 0.5, 0.5);
GlStateManager.rotatef(180, 0, 0, 1);
GlStateManager.translated(-0.5, -0.90, armor ? -0.4 : -0.25);
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
AccessoryRenderHelper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.scaled(0.5, 0.5, 0.5);
GlStateManager.rotatef(180, 0, 0, 1);
GlStateManager.translated(-0.5, -0.90, armor ? -0.4 : -0.25);
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.crimsonGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F);
}
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.crimsonGem;
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F);
}
}
@@ -22,9 +22,7 @@ import net.minecraft.util.Hand;
import net.minecraft.util.math.RayTraceResult;
import vazkii.botania.api.item.ISortableTool;
import vazkii.botania.api.item.ISortableTool.ToolType;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.item.equipment.tool.ToolCommons;
import vazkii.botania.common.lib.LibItemNames;
public class ItemSwapRing extends ItemBauble {
@@ -32,64 +30,58 @@ public class ItemSwapRing extends ItemBauble {
super(props);
}
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
@Override
public void onWornTick(ItemStack stack, EntityLivingBase entity) {
if(!(entity instanceof EntityPlayer))
return;
EntityPlayer player = (EntityPlayer) entity;
ItemStack currentStack = player.getHeldItemMainhand();
if(currentStack.isEmpty() || !(currentStack.getItem() instanceof ISortableTool))
return;
ISortableTool tool = (ISortableTool) currentStack.getItem();
RayTraceResult pos = ToolCommons.raytraceFromEntity(entity.world, entity, true, 4.5F);
ToolType typeToFind = null;
if(player.isSwingInProgress && pos != null && pos.getBlockPos() != null) {
IBlockState state = entity.world.getBlockState(pos.getBlockPos());
Material mat = state.getMaterial();
if(ToolCommons.materialsPick.contains(mat))
typeToFind = ToolType.PICK;
else if(ToolCommons.materialsShovel.contains(mat))
typeToFind = ToolType.SHOVEL;
else if(ToolCommons.materialsAxe.contains(mat))
typeToFind = ToolType.AXE;
}
@Override
public void onCurioTick(String identifier, LivingEntity entity) {
if(!(entity instanceof PlayerEntity))
return;
if(typeToFind == null)
return;
PlayerEntity player = (PlayerEntity) entity;
ItemStack currentStack = player.getHeldItemMainhand();
if(currentStack.isEmpty() || !(currentStack.getItem() instanceof ISortableTool))
return;
ItemStack bestTool = currentStack;
int bestToolPriority = tool.getSortingType(currentStack) == typeToFind ? tool.getSortingPriority(currentStack) : -1;
int bestSlot = -1;
ISortableTool tool = (ISortableTool) currentStack.getItem();
RayTraceResult pos = ToolCommons.raytraceFromEntity(entity.world, entity, true, 4.5F);
ToolType typeToFind = null;
if(player.isSwingInProgress && pos != null && pos.getBlockPos() != null) {
BlockState state = entity.world.getBlockState(pos.getBlockPos());
Material mat = state.getMaterial();
if(ToolCommons.materialsPick.contains(mat))
typeToFind = ToolType.PICK;
else if(ToolCommons.materialsShovel.contains(mat))
typeToFind = ToolType.SHOVEL;
else if(ToolCommons.materialsAxe.contains(mat))
typeToFind = ToolType.AXE;
}
if(typeToFind == null)
return;
ItemStack bestTool = currentStack;
int bestToolPriority = tool.getSortingType(currentStack) == typeToFind ? tool.getSortingPriority(currentStack) : -1;
int bestSlot = -1;
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackInSlot = player.inventory.getStackInSlot(i);
if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof ISortableTool && stackInSlot != currentStack) {
ISortableTool toolInSlot = (ISortableTool) stackInSlot.getItem();
if(toolInSlot.getSortingType(stackInSlot).equals(typeToFind)) {
int priority = toolInSlot.getSortingPriority(stackInSlot);
if(priority > bestToolPriority) {
bestTool = stackInSlot;
bestToolPriority = priority;
bestSlot = i;
}
for(int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack stackInSlot = player.inventory.getStackInSlot(i);
if(!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof ISortableTool && stackInSlot != currentStack) {
ISortableTool toolInSlot = (ISortableTool) stackInSlot.getItem();
if(toolInSlot.getSortingType(stackInSlot).equals(typeToFind)) {
int priority = toolInSlot.getSortingPriority(stackInSlot);
if(priority > bestToolPriority) {
bestTool = stackInSlot;
bestToolPriority = priority;
bestSlot = i;
}
}
}
}
if(bestSlot != -1) {
player.setHeldItem(Hand.MAIN_HAND, bestTool);
player.inventory.setInventorySlotContents(bestSlot, currentStack);
}
if(bestSlot != -1) {
player.setHeldItem(EnumHand.MAIN_HAND, bestTool);
player.inventory.setInventorySlotContents(bestSlot, currentStack);
}
}
}
@@ -34,81 +34,74 @@ import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.integration.curios.RenderableCurio;
import java.util.List;
public class ItemThirdEye extends ItemBauble implements IManaUsingItem {
private static final int COST = 2;
public ItemThirdEye(Properties props) {
super(props);
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase living) {
if(!(living instanceof EntityPlayer))
return;
EntityPlayer eplayer = (EntityPlayer) living;
@Override
public void onCurioTick(String identifier, LivingEntity living) {
if(!(living instanceof PlayerEntity))
return;
PlayerEntity eplayer = (PlayerEntity) living;
double range = 24;
AxisAlignedBB aabb = new AxisAlignedBB(living.posX, living.posY, living.posZ, living.posX, living.posY, living.posZ).grow(range);
List<EntityLivingBase> mobs = living.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, (Entity e) -> e instanceof IMob);
double range = 24;
AxisAlignedBB aabb = new AxisAlignedBB(living.posX, living.posY, living.posZ, living.posX, living.posY, living.posZ).grow(range);
List<LivingEntity> mobs = living.world.getEntitiesWithinAABB(LivingEntity.class, aabb, (Entity e) -> e instanceof IMob);
for(LivingEntity e : mobs) {
EffectInstance potion = e.getActivePotionEffect(Effects.GLOWING);
if((potion == null || potion.getDuration() <= 2) && ManaItemHandler.requestManaExact(stack, eplayer, COST, true))
e.addPotionEffect(new EffectInstance(Effects.GLOWING, 12, 0));
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
boolean armor = !living.getItemStackFromSlot(EquipmentSlotType.CHEST).isEmpty();
GlStateManager.rotatef(180, 0, 0, 1);
GlStateManager.translated(-0.3, -0.6, armor ? -0.18 : -0.12);
GlStateManager.scaled(0.6, 0.6, 0.6);
for(int i = 0; i < 3; i++) {
GlStateManager.pushMatrix();
float width = 1F / 16F;
switch(i) {
case 0: break;
case 1:
double scale1 = 0.75;
width /= 2F;
GlStateManager.translated(0.15, 0.15, -0.05);
double time = ClientTickHandler.total * 0.12;
double dist = 0.05;
GlStateManager.translated(Math.sin(time) * dist, Math.cos(time * 0.5) * dist, 0);
GlStateManager.scaled(scale1, scale1, scale1);
break;
case 2:
GlStateManager.translated(0, 0, -0.05);
break;
}
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.thirdEyeLayers[i];
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), width);
GlStateManager.popMatrix();
}
for(EntityLivingBase e : mobs) {
PotionEffect potion = e.getActivePotionEffect(MobEffects.GLOWING);
if((potion == null || potion.getDuration() <= 2) && ManaItemHandler.requestManaExact(stack, eplayer, COST, true))
e.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 12, 0));
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
boolean armor = !living.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.rotatef(180, 0, 0, 1);
GlStateManager.translated(-0.3, -0.6, armor ? -0.18 : -0.12);
GlStateManager.scaled(0.6, 0.6, 0.6);
for(int i = 0; i < 3; i++) {
GlStateManager.pushMatrix();
float width = 1F / 16F;
switch (i) {
case 0: break;
case 1:
double scale1 = 0.75;
width /= 2F;
GlStateManager.translated(0.15, 0.15, -0.05);
double time = ClientTickHandler.total * 0.12;
double dist = 0.05;
GlStateManager.translated(Math.sin(time) * dist, Math.cos(time * 0.5) * dist, 0);
GlStateManager.scaled(scale1, scale1, scale1);
break;
case 2:
GlStateManager.translated(0, 0, -0.05);
break;
}
TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.thirdEyeLayers[i];
float f = gemIcon.getMinU();
float f1 = gemIcon.getMaxU();
float f2 = gemIcon.getMinV();
float f3 = gemIcon.getMaxV();
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), width);
GlStateManager.popMatrix();
}
}
@Override
public boolean usesMana(ItemStack stack) {
return true;
@@ -27,7 +27,6 @@ import vazkii.botania.api.internal.IManaBurst;
import vazkii.botania.api.mana.ITinyPlanetExcempt;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.integration.curios.RenderableCurio;
import java.util.List;
@@ -38,29 +37,23 @@ public class ItemTinyPlanet extends ItemBauble {
public ItemTinyPlanet(Properties props) {
super(props);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
double x = player.posX;
double y = player.posY + player.getEyeHeight();
double z = player.posZ;
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
applyEffect(player.world, x, y, z);
}
@Override
public void onCurioTick(String identifier, LivingEntity player) {
double x = player.posX;
double y = player.posY + player.getEyeHeight();
double z = player.posZ;
applyEffect(player.world, x, y, z);
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
GlStateManager.translatef(0, -1.5F, 0.5F);
Minecraft.getInstance().getBlockRendererDispatcher().renderBlockBrightness(ModBlocks.tinyPlanet.getDefaultState(), 1.0F);
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
GlStateManager.translatef(0, -1.5F, 0.5F);
Minecraft.getInstance().getBlockRendererDispatcher().renderBlockBrightness(ModBlocks.tinyPlanet.getDefaultState(), 1.0F);
}
public static void applyEffect(World world, double x, double y, double z) {
@@ -17,21 +17,18 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.api.item.AccessoryRenderHelper;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.Botania;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.integration.curios.RenderableCurio;
import vazkii.botania.common.core.handler.EquipmentHandler;
import java.util.ArrayList;
import java.util.List;
@@ -65,9 +62,9 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem {
@SubscribeEvent
public void updatePlayerStepStatus(LivingUpdateEvent event) {
if(event.getEntityLiving() instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) event.getEntityLiving();
ItemStack belt = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player) : ItemStack.EMPTY;
if(event.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
ItemStack belt = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player);
String s = playerStr(player);
if(playersWithStepup.contains(s)) {
@@ -87,7 +84,7 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem {
if(player.isSneaking())
player.stepHeight = 0.60001F; // Not 0.6F because that is the default
else player.stepHeight = 1.25F;
else player.stepHeight = 1.25F;
} else {
player.stepHeight = 0.6F;
@@ -110,9 +107,9 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem {
@SubscribeEvent
public void onPlayerJump(LivingJumpEvent event) {
if(event.getEntityLiving() instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) event.getEntityLiving();
ItemStack belt = CurioIntegration.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player);
if(event.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
ItemStack belt = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player);
if(!belt.isEmpty() && ManaItemHandler.requestManaExact(belt, player, COST, false)) {
player.motionY += ((ItemTravelBelt) belt.getItem()).jump;
@@ -121,8 +118,8 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem {
}
}
private boolean shouldPlayerHaveStepup(PlayerEntity player) {
ItemStack result = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player) : ItemStack.EMPTY;
private boolean shouldPlayerHaveStepup(EntityPlayer player) {
ItemStack result = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player);
return !result.isEmpty() && ManaItemHandler.requestManaExact(result, player, COST, false);
}
@@ -142,26 +139,21 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem {
return texture;
}
public static class Curio extends RenderableCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, LivingEntity player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(((ItemTravelBelt) stack.getItem()).getRenderTexture());
AccessoryRenderHelper.rotateIfSneaking(player);
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(((ItemTravelBelt) stack.getItem()).getRenderTexture());
AccessoryRenderHelper.rotateIfSneaking(player);
GlStateManager.translatef(0F, 0.2F, 0F);
GlStateManager.translatef(0F, 0.2F, 0F);
float s = 1.05F / 16F;
GlStateManager.scalef(s, s, s);
if(model == null)
model = new BipedModel();
float s = 1.05F / 16F;
GlStateManager.scalef(s, s, s);
if(model == null)
model = new ModelBiped();
model.bipedBody.render(1F);
}
model.bipedBody.render(1F);
}
@Override
@@ -14,12 +14,10 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.potion.Effects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.EffectInstance;
import top.theillusivec4.curios.api.CuriosAPI;
import net.minecraft.potion.PotionEffect;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.item.ModItems;
public class ItemWaterRing extends ItemBauble implements IManaUsingItem {
@@ -31,54 +29,48 @@ public class ItemWaterRing extends ItemBauble implements IManaUsingItem {
super(props);
}
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase living) {
if(living.isInWaterOrBubbleColumn()) {
if(living instanceof EntityPlayer) {
// only activate for one ring at a time
ItemStack result = EquipmentHandler.findOrEmpty(ModItems.waterRing, living);
if(result != stack)
return;
}
@Override
public void onCurioTick(String identifier, LivingEntity living) {
if(living.isInWaterOrBubbleColumn()) {
if(living instanceof PlayerEntity) {
// only activate for one ring at a time
ItemStack result = CurioIntegration.findOrEmpty(ModItems.waterRing, living);
if(result != stack)
return;
}
double motionX = living.motionX * SPEED_MULT;
double motionY = living.motionY * SPEED_MULT;
double motionZ = living.motionZ * SPEED_MULT;
double motionX = living.motionX * SPEED_MULT;
double motionY = living.motionY * SPEED_MULT;
double motionZ = living.motionZ * SPEED_MULT;
boolean flying = living instanceof EntityPlayer && ((EntityPlayer) living).abilities.isFlying;
boolean flying = living instanceof PlayerEntity && ((PlayerEntity) living).abilities.isFlying;
if(Math.abs(motionX) < MAX_SPEED && !flying)
living.motionX = motionX;
if(Math.abs(motionY) < MAX_SPEED && !flying)
living.motionY = motionY;
if(Math.abs(motionZ) < MAX_SPEED && !flying)
living.motionZ = motionZ;
if(Math.abs(motionX) < MAX_SPEED && !flying)
living.motionX = motionX;
if(Math.abs(motionY) < MAX_SPEED && !flying)
living.motionY = motionY;
if(Math.abs(motionZ) < MAX_SPEED && !flying)
living.motionZ = motionZ;
PotionEffect effect = living.getActivePotionEffect(MobEffects.NIGHT_VISION);
if(effect == null) {
PotionEffect neweffect = new PotionEffect(MobEffects.NIGHT_VISION, Integer.MAX_VALUE, -42, true, true);
living.addPotionEffect(neweffect);
}
EffectInstance effect = living.getActivePotionEffect(Effects.NIGHT_VISION);
if(effect == null) {
EffectInstance neweffect = new EffectInstance(Effects.NIGHT_VISION, Integer.MAX_VALUE, -42, true, true);
living.addPotionEffect(neweffect);
}
if(living.getAir() <= 1 && living instanceof EntityPlayer) {
int mana = ManaItemHandler.requestMana(stack, (EntityPlayer) living, 300, true);
if(mana > 0)
living.setAir(mana);
}
} else onUnequipped(stack, living);
}
if(living.getAir() <= 1 && living instanceof PlayerEntity) {
int mana = ManaItemHandler.requestMana(stack, (PlayerEntity) living, 300, true);
if(mana > 0)
living.setAir(mana);
}
} else onUnequipped(identifier, living);
}
@Override
public void onUnequipped(String identifier, LivingEntity living) {
EffectInstance effect = living.getActivePotionEffect(Effects.NIGHT_VISION);
if(effect != null && effect.getAmplifier() == -42)
living.removePotionEffect(Effects.NIGHT_VISION);
}
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase living) {
PotionEffect effect = living.getActivePotionEffect(MobEffects.NIGHT_VISION);
if(effect != null && effect.getAmplifier() == -42)
living.removePotionEffect(MobEffects.NIGHT_VISION);
}
@Override
@@ -10,12 +10,8 @@
*/
package vazkii.botania.common.item.relic;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
@@ -28,24 +24,24 @@ import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.api.item.ISequentialBreaker;
import vazkii.botania.api.item.IWireframeCoordinateListProvider;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.integration.curios.RelicCurio;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.tool.ToolCommons;
import vazkii.botania.common.lib.LibMisc;
import java.util.ArrayList;
import java.util.List;
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinateListProvider, IManaUsingItem {
@@ -112,7 +108,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
if(player.world.isAirBlock(pos) && ManaItemHandler.requestManaExact(lokiRing, player, cost, true)) {
ItemStack saveHeld = heldItemStack.copy();
heldItemStack.onItemUse(new ItemUseContext(player, heldItemStack, pos, lookPos.sideHit, (float) lookPos.hitVec.x - pos.getX(), (float) lookPos.hitVec.y - pos.getY(), (float) lookPos.hitVec.z - pos.getZ()));
if (player.isCreative())
if(player.isCreative())
player.setHeldItem(event.getHand(), saveHeld);
}
}
@@ -128,7 +124,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
ISequentialBreaker breaker = (ISequentialBreaker) item;
boolean dispose = breaker.disposeOfTrashBlocks(stack);
for (BlockPos offset : cursors) {
for(BlockPos offset : cursors) {
BlockPos coords = pos.add(offset);
BlockState state = player.world.getBlockState(coords);
breaker.breakOtherBlock(player, stack, coords, pos, side);
@@ -137,20 +133,14 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
}
}
public static class Curio extends RelicCurio {
public Curio(ItemStack stack, ItemRelic relicDelegate) {
super(stack, relicDelegate);
}
@Override
public boolean shouldSyncToTracking(ItemStack stack, EntityLivingBase entity) {
return true;
}
@Override
public boolean shouldSyncToTracking(String identifier, LivingEntity living) {
return true;
}
@Override
public void onUnequipped(String identifier, LivingEntity living) {
setCursorList(stack, null);
}
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase living) {
setCursorList(stack, null);
}
@Override
@@ -165,8 +155,8 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
List<BlockPos> list = getCursorList(stack);
BlockPos origin = getOriginPos(stack);
for (int i = 0; i < list.size(); i++) {
if (origin.getY() != -1) {
for(int i = 0; i < list.size(); i++) {
if(origin.getY() != -1) {
list.set(i, list.get(i).add(origin));
} else {
list.set(i, list.get(i).add(lookPos.getBlockPos()));
@@ -184,11 +174,8 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
return getLokiRing(player) == stack ? getOriginPos(stack) : null;
}
private static ItemStack getLokiRing(PlayerEntity player) {
if(Botania.curiosLoaded) {
return CurioIntegration.findOrEmpty(ModItems.lokiRing, player);
}
return ItemStack.EMPTY;
private static ItemStack getLokiRing(EntityPlayer player) {
return EquipmentHandler.findOrEmpty(ModItems.lokiRing, player);
}
@@ -224,8 +211,8 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat
private static void setCursorList(ItemStack stack, List<BlockPos> cursors) {
if(stack == null)
return;
CompoundNBT cmp = new CompoundNBT();
NBTTagCompound cmp = new NBTTagCompound();
if(cursors != null) {
int i = 0;
for(BlockPos cursor : cursors) {
@@ -12,7 +12,6 @@ package vazkii.botania.common.item.relic;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.PlayerEntity;
@@ -20,23 +19,15 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.items.IItemHandler;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.integration.curios.RelicCurio;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
@@ -57,32 +48,26 @@ public class ItemOdinRing extends ItemRelicBauble {
fireNegations.add(DamageSource.ON_FIRE.damageType);
}
public static class Curio extends RelicCurio {
public Curio(ItemStack stack, ItemRelic relicDelegate) {
super(stack, relicDelegate);
}
@Override
public void onValidPlayerWornTick(EntityPlayer player) {
if(player.isBurning() && ConfigHandler.COMMON.ringOfOdinFireResist.get())
player.extinguish();
}
@Override
public void onValidPlayerWornTick(PlayerEntity player) {
if(player.isBurning() && ConfigHandler.COMMON.ringOfOdinFireResist.get())
player.extinguish();
}
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(String identifier) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
attributes.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(getBaubleUUID(stack), "Odin Ring", 20, 0).setSaved(false));
return attributes;
}
@Override
public Multimap<String, AttributeModifier> getEquippedAttributeModifiers(ItemStack stack) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
attributes.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(getBaubleUUID(stack), "Odin Ring", 20, 0).setSaved(false));
return attributes;
}
@SubscribeEvent
public static void onPlayerAttacked(LivingAttackEvent event) {
if(Botania.curiosLoaded && event.getEntityLiving() instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) event.getEntityLiving();
if(event.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
boolean negate = damageNegations.contains(event.getSource().damageType)
|| (ConfigHandler.COMMON.ringOfOdinFireResist.get() && fireNegations.contains(event.getSource().damageType));
boolean hasRing = !CurioIntegration.findOrEmpty(ModItems.odinRing, player).isEmpty();
boolean hasRing = !EquipmentHandler.findOrEmpty(ModItems.odinRing, player).isEmpty();
if(hasRing && negate)
event.setCanceled(true);
}
@@ -81,4 +81,20 @@ public abstract class ItemRelicBauble extends ItemBauble implements IRelic {
return Integer.MAX_VALUE;
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase entity) {
if(entity instanceof EntityPlayer) {
EntityPlayer ePlayer = (EntityPlayer) entity;
dummy.updateRelic(stack, ePlayer);
if(dummy.isRightPlayer(ePlayer, stack))
onValidPlayerWornTick(ePlayer);
}
}
public void onValidPlayerWornTick(EntityPlayer player) { }
@Override
public boolean canEquip(ItemStack stack, EntityLivingBase entity) {
return entity instanceof EntityPlayer && dummy.isRightPlayer((EntityPlayer) entity, stack);
}
}
@@ -14,11 +14,8 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.items.IItemHandler;
import vazkii.botania.common.Botania;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
public class ItemThorRing extends ItemRelicBauble {
@@ -32,10 +29,7 @@ public class ItemThorRing extends ItemRelicBauble {
return new ResourceLocation(LibMisc.MOD_ID, "challenge/thor_ring");
}
public static ItemStack getThorRing(PlayerEntity player) {
if(Botania.curiosLoaded) {
return CurioIntegration.findOrEmpty(ModItems.thorRing, player);
}
return ItemStack.EMPTY;
public static ItemStack getThorRing(EntityPlayer player) {
return EquipmentHandler.findOrEmpty(ModItems.thorRing, player);
}
}
@@ -10,23 +10,18 @@
*/
package vazkii.botania.common.network;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.fml.network.NetworkEvent;
import net.minecraftforge.items.IItemHandler;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.bauble.ItemDodgeRing;
import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraSword;
import java.util.function.Supplier;
@@ -42,11 +37,7 @@ public class PacketDodge {
ServerPlayerEntity player = ctx.get().getSender();
player.world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F);
ItemStack ringStack = ItemStack.EMPTY;
if(Botania.curiosLoaded) {
ringStack = CurioIntegration.findOrEmpty(ModItems.dodgeRing, player);
}
ItemStack ringStack = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, player);
if(ringStack.isEmpty()) {
player.connection.disconnect(new TranslationTextComponent("botaniamisc.invalidDodge"));
return;
@@ -14,8 +14,7 @@ import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.network.NetworkEvent;
import vazkii.botania.common.Botania;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.core.handler.EquipmentHandler;
import vazkii.botania.common.item.equipment.bauble.ItemCloudPendant;
import vazkii.botania.common.item.equipment.bauble.ItemTravelBelt;
@@ -32,16 +31,14 @@ public class PacketJump {
ctx.get().enqueueWork(() -> {
ServerPlayerEntity player = ctx.get().getSender();
if(Botania.curiosLoaded) {
ItemStack amuletStack = CurioIntegration.findOrEmpty(s -> s.getItem() instanceof ItemCloudPendant, player);
if(!amuletStack.isEmpty()) {
player.addExhaustion(0.3F);
player.fallDistance = 0;
ItemStack amuletStack = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemCloudPendant, player);
if(!amuletStack.isEmpty()) {
player.addExhaustion(0.3F);
player.fallDistance = 0;
ItemStack belt = CurioIntegration.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player);
if(!belt.isEmpty())
player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer * ((ItemCloudPendant) amuletStack.getItem()).getMaxAllowedJumps();
}
ItemStack belt = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player);
if(!belt.isEmpty())
player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer * ((ItemCloudPendant) amuletStack.getItem()).getMaxAllowedJumps();
}
});
ctx.get().setPacketHandled(true);