more curios

This commit is contained in:
Vincent Lee authored and Vincent Lee committed 2019-06-02 12:44:22 -07:00
1 parent 3595f35e5b
commit 5fbf520c1d
21 files changed
+436 -407

No files matched your search

@@ -42,7 +42,7 @@ public interface IBaubleRender {
* Rotates the render for a bauble correctly if the player is sneaking.
* Use for renders under {@link RenderType#BODY}.
*/
public static void rotateIfSneaking(EntityPlayer player) {
public static void rotateIfSneaking(EntityLivingBase player) {
if(player.isSneaking())
applySneakingRotation();
}
@@ -15,6 +15,6 @@ package vazkii.botania.api.item;
* other baubles to add the render to them. Other cosmetic baubles
* can't be stacked on this.
*/
public interface ICosmeticBauble extends IBaubleRender {
public interface ICosmeticBauble {
}
@@ -167,6 +167,7 @@ public class Botania {
MinecraftForge.EVENT_BUS.register(new LootHandler());
if(ModList.get().isLoaded("curios")) {
CurioIntegration.init();
FMLJavaModLoadingContext.get().getModEventBus().register(CurioIntegration.class);
MinecraftForge.EVENT_BUS.register(CurioIntegration.class);
}
@@ -1,5 +1,6 @@
package vazkii.botania.common.integration.curios;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
@@ -10,26 +11,22 @@ 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.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.ItemAuraRing;
import vazkii.botania.common.item.equipment.bauble.ItemGreaterAuraRing;
import vazkii.botania.common.item.equipment.bauble.ItemIcePendant;
import vazkii.botania.common.item.equipment.bauble.ItemItemFinder;
import vazkii.botania.common.item.equipment.bauble.ItemKnockbackBelt;
import vazkii.botania.common.item.equipment.bauble.ItemMiningRing;
import vazkii.botania.common.item.equipment.bauble.ItemReachRing;
import vazkii.botania.common.item.equipment.bauble.ItemThirdEye;
import vazkii.botania.common.item.equipment.bauble.ItemWaterRing;
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.lib.LibMisc;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
// Classloading-safe way to attach curio behaviour to our items
public class CurioIntegration {
@@ -60,32 +57,45 @@ public class CurioIntegration {
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("head"));
}
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.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.swapRing.delegate, ItemSwapRing.Curio::new);
FACTORIES.put(ModItems.thirdEye.delegate, ItemThirdEye.Curio::new);
FACTORIES.put(ModItems.tinyPlanet.delegate, ItemTinyPlanet.Curio::new);
FACTORIES.put(ModItems.unholyCloak.delegate, ItemHolyCloak.Curio::new);
FACTORIES.put(ModItems.waterRing.delegate, ItemWaterRing.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();
if(stack.getItem() == ModItems.icePendant) {
evt.addCapability(KEY, new Provider(new ItemIcePendant.Curio(stack)));
} else if (stack.getItem() == ModItems.waterRing) {
evt.addCapability(KEY, new Provider(new ItemWaterRing.Curio(stack)));
} else if (stack.getItem() == ModItems.knockbackBelt) {
evt.addCapability(KEY, new Provider(new ItemKnockbackBelt.Curio(stack)));
} else if (stack.getItem() == ModItems.odinRing) {
evt.addCapability(KEY, new Provider(new ItemOdinRing.Curio(stack, ((ItemOdinRing) ModItems.odinRing).getDummy())));
} else if (stack.getItem() == ModItems.lokiRing) {
evt.addCapability(KEY, new Provider(new ItemLokiRing.Curio(stack, ((ItemLokiRing) ModItems.lokiRing).getDummy())));
} else if (stack.getItem() == ModItems.reachRing) {
evt.addCapability(KEY, new Provider(new ItemReachRing.Curio(stack)));
} else if (stack.getItem() == ModItems.thirdEye) {
evt.addCapability(KEY, new Provider(new ItemThirdEye.Curio(stack)));
} else if (stack.getItem() == ModItems.itemFinder) {
evt.addCapability(KEY, new Provider(new ItemItemFinder.Curio(stack)));
} else if (stack.getItem() == ModItems.auraRing) {
evt.addCapability(KEY, new Provider(new ItemAuraRing.Curio(stack)));
} else if (stack.getItem() == ModItems.auraRingGreater) {
evt.addCapability(KEY, new Provider(new ItemGreaterAuraRing.Curio(stack)));
} else if (stack.getItem() == ModItems.miningRing) {
evt.addCapability(KEY, new Provider(new ItemMiningRing.Curio(stack)));
Function<ItemStack, ICurio> factory = FACTORIES.get(stack.getItem().delegate);
if (factory != null) {
evt.addCapability(KEY, new Provider(factory.apply(stack)));
}
}
}
@@ -43,12 +43,13 @@ 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.BaseCurio;
import vazkii.botania.common.lib.LibItemNames;
import java.awt.Color;
import java.util.List;
public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBrewItem, IManaUsingItem, IBaubleRender {
public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBrewItem, IManaUsingItem {
private static final String TAG_BREW_KEY = "brewKey";
@@ -91,33 +92,63 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
}
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.AMULET;
}
*/
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
Brew brew = 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);
@Override
public void onCurioTick(String identifier, 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);
}
if(!doRand || Math.random() < cost)
ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), true);
}
}
@Override
public boolean hasRender(String identifier, EntityLivingBase entityLivingBase) {
return true;
}
@Override
public void doRender(String identifier, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
IBaubleRender.Helper.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);
Color color = new Color(Minecraft.getInstance().getItemColors().getColor(stack, 1));
GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY);
}
GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
}
}
@Override
@@ -154,33 +185,4 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
return getBrew(stack) != BotaniaAPI.fallbackBrew;
}
@Override
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Helper.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);
Color color = new Color(Minecraft.getInstance().getItemColors().getColor(stack, 1));
GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
int light = 15728880;
int lightmapX = light % 65536;
int lightmapY = light / 65536;
OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY);
}
GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
}
}
}
@@ -18,6 +18,7 @@ import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
@@ -30,12 +31,15 @@ import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.server.ServerLifecycleHooks;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.api.item.IBaubleRender;
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.ModSounds;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibObfuscation;
import vazkii.botania.common.network.PacketBotaniaEffect;
@@ -43,7 +47,7 @@ import vazkii.botania.common.network.PacketHandler;
import java.util.List;
public class ItemDivaCharm extends ItemBauble implements IManaUsingItem, IBaubleRender {
public class ItemDivaCharm extends ItemBauble implements IManaUsingItem {
public ItemDivaCharm(Properties props) {
super(props);
@@ -55,9 +59,10 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem, IBauble
Runnable lambda = () -> {
EntityLiving target = (EntityLiving) event.getEntityLiving();
EntityPlayer player = (EntityPlayer) event.getSource().getImmediateSource();
ItemStack amulet = ItemStack.EMPTY; // todo 1.13 BaublesApi.getBaublesHandler(player).getStackInSlot(6);
CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(ModItems.divaCharm, player);
if(!amulet.isEmpty() && amulet.getItem() == this) {
if(result != null) {
ItemStack amulet = result.getStack();
final int cost = 250;
if(ManaItemHandler.requestManaExact(amulet, player, cost, false)) {
final int range = 20;
@@ -66,7 +71,7 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem, IBauble
if(mobs.size() > 1) {
if(SubTileHeiseiDream.brainwashEntity(target, (List<IMob>) mobs)) {
target.heal(target.getMaxHealth());
target.removed = false;
target.revive();
if(target instanceof EntityCreeper)
((EntityCreeper) event.getEntityLiving()).timeSinceIgnited = 2;
@@ -88,30 +93,31 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem, IBauble
}
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.CHARM;
}
*/
@Override
public boolean usesMana(ItemStack stack) {
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.HEAD) {
Helper.translateToHeadLevel(player);
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public boolean hasRender(String identifier, EntityLivingBase living) {
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
IBaubleRender.Helper.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(new ItemStack(this), ItemCameraTransforms.TransformType.GROUND);
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND);
}
}
}
@@ -23,9 +23,11 @@ import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandler;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.client.core.handler.ClientTickHandler;
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.item.ModItems;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
@@ -50,12 +52,11 @@ public class ItemDodgeRing extends ItemBauble {
public static void onKeyDown(InputEvent.KeyInputEvent event) {
Minecraft mc = Minecraft.getInstance();
IItemHandler baublesInv = null; // BaublesApi.getBaublesHandler(mc.player);
int slot = -1; // todo 1.13 BaublesApi.isBaubleEquipped(mc.player, ModItems.dodgeRing);
if(slot < 0) {
CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(ModItems.dodgeRing, mc.player);
if(result == null) {
return;
}
ItemStack ringStack = baublesInv.getStackInSlot(slot);
ItemStack ringStack = result.getStack();
if(ItemNBTHelper.getInt(ringStack, TAG_DODGE_COOLDOWN, 0) > 0)
return;
@@ -78,11 +79,17 @@ public class ItemDodgeRing extends ItemBauble {
oldRightDown = mc.gameSettings.keyBindRight.isKeyDown();
}
@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);
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onCurioTick(String identifier, 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(EntityPlayer player, boolean left) {
@@ -120,12 +127,4 @@ public class ItemDodgeRing extends ItemBauble {
GlStateManager.enableAlphaTest();
GlStateManager.color4f(1F, 1F, 1F, 1F);
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.RING;
}
*/
}
@@ -13,6 +13,7 @@ package vazkii.botania.common.item.equipment.bauble;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.AxisAlignedBB;
@@ -24,16 +25,19 @@ 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.IBaubleRender;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
import java.util.List;
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
public class ItemGoddessCharm extends ItemBauble implements IManaUsingItem, IBaubleRender {
public class ItemGoddessCharm extends ItemBauble implements IManaUsingItem {
public static final int COST = 1000;
@@ -48,31 +52,31 @@ public class ItemGoddessCharm extends ItemBauble implements IManaUsingItem, IBau
List<EntityPlayer> players = event.getWorld().getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(vec.x, vec.y, vec.z, vec.x, vec.y, vec.z).grow(8));
for(EntityPlayer player : players) {
/* todo 1.13
ItemStack charm = BaublesApi.getBaublesHandler(player).getStackInSlot(6);
if(!charm.isEmpty() && charm.getItem() instanceof ItemGoddessCharm && ManaItemHandler.requestManaExact(charm, player, COST, true)) {
CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(ModItems.goddessCharm, player);
if(result != null && ManaItemHandler.requestManaExact(result.getStack(), player, COST, true)) {
event.getAffectedBlocks().clear();
return;
}
*/
}
}
/*
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.CHARM;
}
*/
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if (type == RenderType.HEAD) {
@Override
public boolean hasRender(String identifier, EntityLivingBase living) {
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
GlStateManager.pushMatrix();
Helper.translateToHeadLevel(player);
Helper.translateToFace();
Helper.defaultTransforms();
IBaubleRender.Helper.translateToHeadLevel(player);
IBaubleRender.Helper.translateToFace();
IBaubleRender.Helper.defaultTransforms();
GlStateManager.rotatef(-90F, 0F, 1F, 0F);
GlStateManager.translatef(0.5F, 0.2F, 0.45F);
Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.NONE);
@@ -23,15 +23,17 @@ 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 vazkii.botania.api.item.IBaubleRender;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.client.model.ModelCloak;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.lib.LibItemNames;
public class ItemHolyCloak extends ItemBauble implements IBaubleRender {
public class ItemHolyCloak extends ItemBauble {
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_HOLY_CLOAK);
private static final ResourceLocation textureGlow = new ResourceLocation(LibResources.MODEL_HOLY_CLOAK_GLOW);
@@ -50,8 +52,10 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender {
private void onPlayerDamage(LivingHurtEvent event) {
if(event.getEntityLiving() instanceof EntityPlayer && !event.getSource().canHarmInCreative()) {
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
ItemStack belt = ItemStack.EMPTY; // todo 1.13 BaublesApi.getBaublesHandler(player).getStackInSlot(5);
if(!belt.isEmpty() && belt.getItem() instanceof ItemHolyCloak && !isInEffect(belt)) {
CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(s -> s.getItem() instanceof ItemHolyCloak, player);
if(result != null && !isInEffect(result.getStack())) {
ItemStack belt = result.getStack();
ItemHolyCloak cloak = (ItemHolyCloak) belt.getItem();
int cooldown = getCooldown(belt);
@@ -64,11 +68,49 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender {
}
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
int cooldown = getCooldown(stack);
if(cooldown > 0)
setCooldown(stack, cooldown - 1);
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onCurioTick(String identifier, EntityLivingBase living) {
int cooldown = getCooldown(stack);
if(cooldown > 0)
setCooldown(stack, cooldown - 1);
}
@Override
public boolean hasRender(String identifier, EntityLivingBase living) {
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
ItemHolyCloak item = ((ItemHolyCloak) stack.getItem());
IBaubleRender.Helper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.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();
GlStateManager.enableLighting();
GlStateManager.enableRescaleNormal();
Minecraft.getInstance().textureManager.bindTexture(item.getCloakTexture());
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, EntityPlayer player, ItemStack stack) {
@@ -92,13 +134,6 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender {
return 200;
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.BODY;
}
*/
public static int getCooldown(ItemStack stack) {
return ItemNBTHelper.getInt(stack, TAG_COOLDOWN, 0);
}
@@ -124,34 +159,5 @@ public class ItemHolyCloak extends ItemBauble implements IBaubleRender {
ResourceLocation getCloakGlowTexture() {
return textureGlow;
}
@Override
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
Helper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.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();
GlStateManager.enableLighting();
GlStateManager.enableRescaleNormal();
Minecraft.getInstance().textureManager.bindTexture(getCloakTexture());
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(getCloakGlowTexture());
model.render(1F);
}
}
}
@@ -17,6 +17,7 @@ import net.minecraft.item.ItemStack;
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.lib.LibItemNames;
public class ItemInvisibilityCloak extends ItemBauble implements IManaUsingItem {
@@ -25,36 +26,32 @@ public class ItemInvisibilityCloak extends ItemBauble implements IManaUsingItem
super(props);
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.BODY;
}
*/
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, EntityLivingBase player) {
PotionEffect effect = player.getActivePotionEffect(MobEffects.INVISIBILITY);
if(effect != null && player instanceof EntityPlayer && effect.getAmplifier() == -42)
player.removePotionEffect(MobEffects.INVISIBILITY);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
super.onWornTick(stack, player);
@Override
public void onCurioTick(String identifier, EntityLivingBase player) {
if(player instanceof EntityPlayer && !player.world.isRemote) {
int manaCost = 2;
boolean hasMana = ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, false);
if(!hasMana)
onUnequipped(identifier, player);
else {
if(player.getActivePotionEffect(MobEffects.INVISIBILITY) != null)
player.removePotionEffect(MobEffects.INVISIBILITY);
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);
player.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, Integer.MAX_VALUE, -42, true, true));
player.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, Integer.MAX_VALUE, -42, true, true));
}
}
}
}
@@ -62,5 +59,4 @@ public class ItemInvisibilityCloak extends ItemBauble implements IManaUsingItem
public boolean usesMana(ItemStack stack) {
return true;
}
}
@@ -24,9 +24,10 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.item.IBaubleRender;
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.lib.LibItemNames;
public class ItemLavaPendant extends ItemBauble implements IBaubleRender {
public class ItemLavaPendant extends ItemBauble {
public ItemLavaPendant(Properties props) {
super(props);
@@ -38,19 +39,20 @@ public class ItemLavaPendant extends ItemBauble implements IBaubleRender {
player.extinguish();
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack itemstack) {
return BaubleType.AMULET;
}
*/
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
@Override
public boolean hasRender(String identifier, EntityLivingBase living) {
return true;
}
@Override
public void doRender(String identifier, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Helper.rotateIfSneaking(player);
IBaubleRender.Helper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.scalef(0.5F, 0.5F, 0.5F);
GlStateManager.rotatef(180, 0, 0, 1);
@@ -64,5 +66,4 @@ public class ItemLavaPendant extends ItemBauble implements IBaubleRender {
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F);
}
}
}
@@ -24,6 +24,7 @@ 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;
@@ -33,6 +34,7 @@ import vazkii.botania.common.core.handler.ConfigHandler;
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.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
@@ -59,52 +61,51 @@ public class ItemMagnetRing extends ItemBauble {
}
private void onTossItem(ItemTossEvent event) {
/* todo 1.13
IItemHandler inv = BaublesApi.getBaublesHandler(event.getPlayer());
for(int i = 0; i < inv.getSlots(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if(!stack.isEmpty() && stack.getItem() instanceof ItemMagnetRing) {
setCooldown(stack, 100);
BotaniaAPI.internalHandler.sendBaubleUpdatePacket(event.getPlayer(), i);
}
CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(this, event.getPlayer());
if(result != null) {
setCooldown(result.getStack(), 100);
}
*/
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
super.onWornTick(stack, player);
int cooldown = getCooldown(stack);
if(SubTileSolegnolia.hasSolegnoliaAround(player)) {
if(cooldown < 0)
setCooldown(stack, 2);
return;
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(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;
@Override
public void onCurioTick(String identifier, EntityLivingBase player) {
int cooldown = getCooldown(stack);
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(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++;
}
if(SubTileSolegnolia.hasSolegnoliaAround(player)) {
if(cooldown < 0)
setCooldown(stack, 2);
return;
}
} else setCooldown(stack, cooldown - 1);
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<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;
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++;
}
}
} else setCooldown(stack, cooldown - 1);
}
}
private boolean canPullItem(EntityItem item) {
@@ -133,13 +134,4 @@ public class ItemMagnetRing extends ItemBauble {
public static void setCooldown(ItemStack stack, int cooldown) {
ItemNBTHelper.setInt(stack, TAG_COOLDOWN, cooldown);
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.RING;
}
*/
}
@@ -35,13 +35,6 @@ public class ItemManaRing extends ItemBauble implements IManaItem, IManaTooltipD
super(props);
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack itemstack) {
return BaubleType.RING;
}
*/
@Override
public void fillItemGroup(@Nonnull ItemGroup tab, @Nonnull NonNullList<ItemStack> stacks) {
if(isInGroup(tab)) {
@@ -19,6 +19,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@@ -30,9 +31,13 @@ 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.IBaubleRender;
import vazkii.botania.api.item.IBurstViewerBauble;
import vazkii.botania.api.item.ICosmeticAttachable;
import vazkii.botania.api.item.ICosmeticBauble;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibItemNames;
public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosmeticBauble {
@@ -41,23 +46,24 @@ public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosm
super(props);
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.CHARM;
}
*/
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.HEAD) {
@Override
public boolean hasRender(String identifier, EntityLivingBase living) {
return true;
}
@Override
public void doRender(String identifier, 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);
Helper.translateToHeadLevel(player);
Helper.translateToFace();
Helper.defaultTransforms();
IBaubleRender.Helper.translateToHeadLevel(player);
IBaubleRender.Helper.translateToFace();
IBaubleRender.Helper.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);
@@ -103,8 +109,9 @@ public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosm
}
public static boolean hasMonocle(EntityPlayer player) {
for(int i = 0; i < 7; i++) {
ItemStack stack = ItemStack.EMPTY; // todo 1.13 BaublesApi.getBaublesHandler(player).getStackInSlot(i);
CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(ModItems.monocle, player);
if(result != null) {
ItemStack stack = result.getStack();
if(!stack.isEmpty()) {
Item item = stack.getItem();
if(item instanceof IBurstViewerBauble)
@@ -20,13 +20,6 @@ public class ItemPixieRing extends ItemBauble implements IPixieSpawner {
super(props);
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.RING;
}
*/
@Override
public float getPixieChance(ItemStack stack) {
return 0.25F;
@@ -25,37 +25,40 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.item.IBaubleRender;
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.lib.LibItemNames;
public class ItemSuperLavaPendant extends ItemBauble implements IBaubleRender {
public class ItemSuperLavaPendant extends ItemBauble {
public ItemSuperLavaPendant(Properties props) {
super(props);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase living) {
living.isImmuneToFire = true;
}
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase living) {
living.isImmuneToFire = false;
}
@Override
public void onCurioTick(String identifier, EntityLivingBase living) {
living.isImmuneToFire = true;
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack itemstack) {
return BaubleType.AMULET;
}
*/
@Override
public void onUnequipped(String identifier, EntityLivingBase living) {
living.isImmuneToFire = false;
}
@Override
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
@Override
public boolean hasRender(String identifier, EntityLivingBase entityLivingBase) {
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Helper.rotateIfSneaking(player);
IBaubleRender.Helper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.scaled(0.5, 0.5, 0.5);
GlStateManager.rotatef(180, 0, 0, 1);
@@ -19,6 +19,7 @@ import net.minecraft.util.EnumHand;
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;
@@ -28,66 +29,64 @@ public class ItemSwapRing extends ItemBauble {
super(props);
}
@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;
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
if(typeToFind == null)
return;
@Override
public void onCurioTick(String identifier, EntityLivingBase entity) {
if(!(entity instanceof EntityPlayer))
return;
ItemStack bestTool = currentStack;
int bestToolPriority = tool.getSortingType(currentStack) == typeToFind ? tool.getSortingPriority(currentStack) : -1;
int bestSlot = -1;
EntityPlayer player = (EntityPlayer) entity;
ItemStack currentStack = player.getHeldItemMainhand();
if(currentStack.isEmpty() || !(currentStack.getItem() instanceof ISortableTool))
return;
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;
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;
}
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;
}
}
}
}
}
if(bestSlot != -1) {
player.setHeldItem(EnumHand.MAIN_HAND, bestTool);
player.inventory.setInventorySlotContents(bestSlot, currentStack);
if(bestSlot != -1) {
player.setHeldItem(EnumHand.MAIN_HAND, bestTool);
player.inventory.setInventorySlotContents(bestSlot, currentStack);
}
}
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.RING;
}
*/
}
@@ -29,11 +29,12 @@ import vazkii.botania.api.item.IBaubleRender;
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.BaseCurio;
import vazkii.botania.common.lib.LibItemNames;
import java.util.List;
public class ItemTinyPlanet extends ItemBauble implements IBaubleRender {
public class ItemTinyPlanet extends ItemBauble {
public static final String TAG_ORBIT = "orbit";
@@ -41,24 +42,33 @@ public class ItemTinyPlanet extends ItemBauble implements IBaubleRender {
super(props);
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack itemstack) {
return BaubleType.CHARM;
}
*/
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
super.onWornTick(stack, player);
@Override
public void onCurioTick(String identifier, EntityLivingBase player) {
double x = player.posX;
double y = player.posY + player.getEyeHeight();
double z = player.posZ;
double x = player.posX;
double y = player.posY + 1.2F;
double z = player.posZ;
if(player.world.isRemote)
y -= 1.62F;
applyEffect(player.world, x, y, z);
}
applyEffect(player.world, x, y, z);
@Override
public boolean hasRender(String identifier, EntityLivingBase living) {
return true;
}
@Override
@OnlyIn(Dist.CLIENT)
public void doRender(String identifier, 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) {
@@ -104,15 +114,4 @@ public class ItemTinyPlanet extends ItemBauble implements IBaubleRender {
cmp.putInt(TAG_ORBIT, time + 1);
}
@Override
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.HEAD) {
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);
}
}
}
@@ -1,6 +1,10 @@
{
"replace": false,
"values": [
"botania:third_eye"
"botania:balance_cloak",
"botania:holy_cloak",
"botania:invisibility_cloak",
"botania:third_eye",
"botania:unholy_cloak"
]
}
@@ -1,6 +1,13 @@
{
"replace": false,
"values": [
"botania:ice_pendant"
"botania:blood_pendant",
"botania:diva_charm",
"botania:goddess_charm",
"botania:ice_pendant",
"botania:lava_pendant",
"botania:monocle",
"botania:super_lava_pendant",
"botania:tiny_planet"
]
}
@@ -1,12 +1,19 @@
{
"replace": false,
"values": [
"botania:water_ring",
"botania:odin_ring",
"botania:loki_ring",
"botania:reach_ring",
"botania:aura_ring",
"botania:aura_ring_greater",
"botania:mining_ring"
"botania:dodge_ring",
"botania:loki_ring",
"botania:magnet_ring",
"botania:magnet_ring_greater",
"botania:mana_ring",
"botania:mana_ring_greater",
"botania:mining_ring",
"botania:odin_ring",
"botania:pixie_ring",
"botania:reach_ring",
"botania:swap_ring",
"botania:water_ring"
]
}