mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 19:05:16 +00:00
Some helpers, advancements, potions
This commit is contained in:
1 parent
6f20d51b04
commit
cc7d00f578
20 files changed
+104
-124
No files matched your search
@@ -5,8 +5,8 @@ import com.google.gson.JsonObject;
|
||||
import net.minecraft.advancements.ICriterionInstance;
|
||||
import net.minecraft.advancements.ICriterionTrigger;
|
||||
import net.minecraft.advancements.PlayerAdvancements;
|
||||
import net.minecraft.advancements.critereon.ItemPredicate;
|
||||
import net.minecraft.advancements.critereon.LocationPredicate;
|
||||
import net.minecraft.advancements.criterion.ItemPredicate;
|
||||
import net.minecraft.advancements.criterion.LocationPredicate;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -5,8 +5,8 @@ import com.google.gson.JsonObject;
|
||||
import net.minecraft.advancements.ICriterionInstance;
|
||||
import net.minecraft.advancements.ICriterionTrigger;
|
||||
import net.minecraft.advancements.PlayerAdvancements;
|
||||
import net.minecraft.advancements.critereon.LocationPredicate;
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
import net.minecraft.advancements.criterion.LocationPredicate;
|
||||
import net.minecraft.advancements.criterion.MinMaxBounds;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -55,7 +55,7 @@ public class CorporeaRequestTrigger implements ICriterionTrigger<CorporeaRequest
|
||||
@Nonnull
|
||||
@Override
|
||||
public Instance deserializeInstance(@Nonnull JsonObject json, @Nonnull JsonDeserializationContext context) {
|
||||
return new Instance(MinMaxBounds.deserialize(json.get("extracted")), LocationPredicate.deserialize(json.get("location")));
|
||||
return new Instance(MinMaxBounds.IntBound.fromJson(json.get("extracted")), LocationPredicate.deserialize(json.get("location")));
|
||||
}
|
||||
|
||||
static class PlayerTracker {
|
||||
@@ -89,10 +89,10 @@ public class CorporeaRequestTrigger implements ICriterionTrigger<CorporeaRequest
|
||||
}
|
||||
|
||||
static class Instance implements ICriterionInstance {
|
||||
private final MinMaxBounds count;
|
||||
private final MinMaxBounds.IntBound count;
|
||||
private final LocationPredicate indexPos;
|
||||
|
||||
Instance(MinMaxBounds count, LocationPredicate indexPos) {
|
||||
Instance(MinMaxBounds.IntBound count, LocationPredicate indexPos) {
|
||||
this.count = count;
|
||||
this.indexPos = indexPos;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ import com.google.gson.JsonObject;
|
||||
import net.minecraft.advancements.ICriterionInstance;
|
||||
import net.minecraft.advancements.ICriterionTrigger;
|
||||
import net.minecraft.advancements.PlayerAdvancements;
|
||||
import net.minecraft.advancements.critereon.*;
|
||||
import net.minecraft.advancements.criterion.DamageSourcePredicate;
|
||||
import net.minecraft.advancements.criterion.EntityPredicate;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.google.gson.JsonObject;
|
||||
import net.minecraft.advancements.ICriterionInstance;
|
||||
import net.minecraft.advancements.ICriterionTrigger;
|
||||
import net.minecraft.advancements.PlayerAdvancements;
|
||||
import net.minecraft.advancements.critereon.ItemPredicate;
|
||||
import net.minecraft.advancements.criterion.ItemPredicate;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -5,8 +5,8 @@ import com.google.gson.JsonObject;
|
||||
import net.minecraft.advancements.ICriterionInstance;
|
||||
import net.minecraft.advancements.ICriterionTrigger;
|
||||
import net.minecraft.advancements.PlayerAdvancements;
|
||||
import net.minecraft.advancements.critereon.ItemPredicate;
|
||||
import net.minecraft.advancements.critereon.LocationPredicate;
|
||||
import net.minecraft.advancements.criterion.ItemPredicate;
|
||||
import net.minecraft.advancements.criterion.LocationPredicate;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@@ -21,16 +21,17 @@ import vazkii.botania.common.brew.potion.PotionEmptiness;
|
||||
import vazkii.botania.common.brew.potion.PotionFeatherfeet;
|
||||
import vazkii.botania.common.brew.potion.PotionSoulCross;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
import vazkii.botania.common.lib.LibPotionNames;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class ModPotions {
|
||||
|
||||
public static final Potion soulCross = new PotionSoulCross();
|
||||
public static final Potion featherfeet = new PotionFeatherfeet();
|
||||
public static final Potion emptiness = new PotionEmptiness();
|
||||
public static final Potion bloodthrst = new PotionBloodthirst();
|
||||
public static final Potion allure = new PotionAllure();
|
||||
public static final Potion clear = new PotionClear();
|
||||
public static final Potion soulCross = new PotionSoulCross().setRegistryName(LibMisc.MOD_ID, LibPotionNames.SOUL_CROSS);
|
||||
public static final Potion featherfeet = new PotionFeatherfeet().setRegistryName(LibMisc.MOD_ID, LibPotionNames.FEATHER_FEET);
|
||||
public static final Potion emptiness = new PotionEmptiness().setRegistryName(LibMisc.MOD_ID, LibPotionNames.EMPTINESS);
|
||||
public static final Potion bloodthrst = new PotionBloodthirst().setRegistryName(LibMisc.MOD_ID, LibPotionNames.BLOODTHIRST);
|
||||
public static final Potion allure = new PotionAllure().setRegistryName(LibMisc.MOD_ID, LibPotionNames.ALLURE);
|
||||
public static final Potion clear = new PotionClear().setRegistryName(LibMisc.MOD_ID, LibPotionNames.CLEAR);
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerPotions(RegistryEvent.Register<Potion> evt)
|
||||
|
||||
@@ -20,7 +20,7 @@ import javax.annotation.Nonnull;
|
||||
public class PotionAllure extends PotionMod {
|
||||
|
||||
public PotionAllure() {
|
||||
super(LibPotionNames.ALLURE, false, 0x0034E4, 5);
|
||||
super(false, 0x0034E4, 5);
|
||||
setBeneficial();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class PotionAllure extends PotionMod {
|
||||
if(living instanceof EntityPlayer) {
|
||||
EntityFishHook hook = ((EntityPlayer) living).fishEntity;
|
||||
if(hook != null)
|
||||
hook.onUpdate();
|
||||
hook.tick();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,30 +13,30 @@ package vazkii.botania.common.brew.potion;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import vazkii.botania.common.brew.ModPotions;
|
||||
import vazkii.botania.common.lib.LibPotionNames;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
|
||||
public class PotionBloodthirst extends PotionMod {
|
||||
|
||||
private static final int RANGE = 64;
|
||||
|
||||
public PotionBloodthirst() {
|
||||
super(LibPotionNames.BLOODTHIRST, false, 0xC30000, 3);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
super(false, 0xC30000, 3);
|
||||
setBeneficial();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onSpawn(LivingSpawnEvent.CheckSpawn event) {
|
||||
if(event.getResult() != Result.ALLOW && event.getEntityLiving() instanceof IMob) {
|
||||
public static void onSpawn(LivingSpawnEvent.CheckSpawn event) {
|
||||
if(event.getResult() != Event.Result.ALLOW && event.getEntityLiving() instanceof IMob) {
|
||||
AxisAlignedBB aabb = new AxisAlignedBB(event.getX() - RANGE, event.getY() - RANGE, event.getZ() - RANGE, event.getX() + RANGE, event.getY() + RANGE, event.getZ() + RANGE);
|
||||
for(EntityPlayer player : event.getWorld().playerEntities) {
|
||||
if(hasEffect(player) && !hasEffect(player, ModPotions.emptiness) && player.getEntityBoundingBox().intersects(aabb)) {
|
||||
event.setResult(Result.ALLOW);
|
||||
for(EntityPlayer player : event.getWorld().getWorld().playerEntities) {
|
||||
if(player.isPotionActive(ModPotions.bloodthrst) && !player.isPotionActive(ModPotions.emptiness) && player.getBoundingBox().intersects(aabb)) {
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,14 +14,13 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.common.lib.LibPotionNames;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class PotionClear extends PotionMod {
|
||||
|
||||
public PotionClear() {
|
||||
super(LibPotionNames.CLEAR, false, 0xFFFFFF, 0);
|
||||
super(false, 0xFFFFFF, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,29 +13,27 @@ package vazkii.botania.common.brew.potion;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import vazkii.botania.common.lib.LibPotionNames;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import vazkii.botania.common.brew.ModPotions;
|
||||
|
||||
public class PotionEmptiness extends PotionMod {
|
||||
|
||||
private static final int RANGE = 128;
|
||||
|
||||
public PotionEmptiness() {
|
||||
super(LibPotionNames.EMPTINESS, false, 0xFACFFF, 2);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
super(false, 0xFACFFF, 2);
|
||||
setBeneficial();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onSpawn(LivingSpawnEvent.CheckSpawn event) {
|
||||
if(event.getResult() != Result.ALLOW && event.getEntityLiving() instanceof IMob) {
|
||||
public static void onSpawn(LivingSpawnEvent.CheckSpawn event) {
|
||||
if(event.getResult() != Event.Result.ALLOW && event.getEntityLiving() instanceof IMob) {
|
||||
AxisAlignedBB aabb = new AxisAlignedBB(event.getX() - RANGE, event.getY() - RANGE, event.getZ() - RANGE, event.getX() + RANGE, event.getY() + RANGE, event.getZ() + RANGE);
|
||||
for(EntityPlayer player : event.getWorld().playerEntities) {
|
||||
if(hasEffect(player) && player.getEntityBoundingBox().intersects(aabb)) {
|
||||
event.setResult(Result.DENY);
|
||||
for(EntityPlayer player : event.getWorld().getWorld().playerEntities) {
|
||||
if(player.isPotionActive(ModPotions.emptiness) && player.getBoundingBox().intersects(aabb)) {
|
||||
event.setResult(Event.Result.DENY);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,14 +11,13 @@
|
||||
package vazkii.botania.common.brew.potion;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import vazkii.botania.common.lib.LibPotionNames;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class PotionFeatherfeet extends PotionMod {
|
||||
|
||||
public PotionFeatherfeet() {
|
||||
super(LibPotionNames.FEATHER_FEET, false, 0x26ADFF, 1);
|
||||
super(false, 0x26ADFF, 1);
|
||||
setBeneficial();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package vazkii.botania.common.brew.potion;
|
||||
|
||||
import javafx.geometry.Side;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
@@ -19,50 +20,39 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
public class PotionMod extends Potion {
|
||||
|
||||
private static final ResourceLocation resource = new ResourceLocation(LibResources.GUI_POTIONS);
|
||||
private final int iconIndex;
|
||||
|
||||
public PotionMod(String name, boolean badEffect, int color, int iconIndex) {
|
||||
public PotionMod(boolean badEffect, int color, int iconIndex) {
|
||||
super(badEffect, color);
|
||||
setRegistryName(new ResourceLocation(LibMisc.MOD_ID, name));
|
||||
setPotionName("botania.potion." + name);
|
||||
this.iconIndex = iconIndex;
|
||||
}
|
||||
|
||||
public boolean hasEffect(EntityLivingBase entity) {
|
||||
return hasEffect(entity, this);
|
||||
}
|
||||
|
||||
public boolean hasEffect(EntityLivingBase entity, Potion potion) {
|
||||
return entity.getActivePotionEffect(potion) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void renderInventoryEffect(int x, int y, PotionEffect effect, Minecraft mc) {
|
||||
render(x + 6, y + 7, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void renderHUDEffect(int x, int y, PotionEffect effect, Minecraft mc, float alpha) {
|
||||
render(x + 3, y + 3, alpha);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private void render(int x, int y, float alpha) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(resource);
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(resource);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buf = tessellator.getBuffer();
|
||||
buf.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
GlStateManager.color(1, 1, 1, alpha);
|
||||
GlStateManager.color4f(1, 1, 1, alpha);
|
||||
|
||||
int textureX = iconIndex % 8 * 18;
|
||||
int textureY = 198 + iconIndex / 8 * 18;
|
||||
|
||||
@@ -12,25 +12,26 @@ package vazkii.botania.common.brew.potion;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import vazkii.botania.common.lib.LibPotionNames;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import vazkii.botania.common.brew.ModPotions;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
|
||||
public class PotionSoulCross extends PotionMod {
|
||||
|
||||
public PotionSoulCross() {
|
||||
super(LibPotionNames.SOUL_CROSS, false, 0x47453d, 0);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
super(false, 0x47453d, 0);
|
||||
setBeneficial();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityKill(LivingDeathEvent event) {
|
||||
public static void onEntityKill(LivingDeathEvent event) {
|
||||
Entity killer = event.getSource().getTrueSource();
|
||||
if(killer != null && killer instanceof EntityLivingBase) {
|
||||
if(killer instanceof EntityLivingBase) {
|
||||
EntityLivingBase living = (EntityLivingBase) killer;
|
||||
if(hasEffect(living))
|
||||
if(living.isPotionActive(ModPotions.soulCross))
|
||||
living.heal(event.getEntityLiving().getMaxHealth() / 20);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ package vazkii.botania.common.core.handler;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import vazkii.botania.api.internal.IManaNetwork;
|
||||
import vazkii.botania.api.mana.ManaNetworkEvent;
|
||||
import vazkii.botania.api.mana.ManaNetworkEvent.Action;
|
||||
@@ -79,7 +79,7 @@ public final class ManaNetworkHandler implements IManaNetwork {
|
||||
return tiles.stream()
|
||||
.filter(ts -> ts.isRemote() == remoteCheck)
|
||||
.map(TileSignature::getTile)
|
||||
.filter(t -> !t.isInvalid())
|
||||
.filter(t -> !t.isRemoved())
|
||||
.filter(t -> t.getPos().distanceSq(pos) <= limit * limit)
|
||||
.reduce(BinaryOperator.minBy(Comparator.comparing(t -> t.getPos().distanceSq(pos), Double::compare)))
|
||||
.orElse(null);
|
||||
|
||||
@@ -9,8 +9,8 @@ import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import vazkii.botania.api.item.IPixieSpawner;
|
||||
import vazkii.botania.common.core.helper.PlayerHelper;
|
||||
@@ -58,7 +58,7 @@ public final class PixieHandler {
|
||||
dmg += 2;
|
||||
|
||||
pixie.setProps((EntityLivingBase) event.getSource().getTrueSource(), player, 0, dmg);
|
||||
pixie.onInitialSpawn(player.world.getDifficultyForLocation(new BlockPos(pixie)), null);
|
||||
pixie.onInitialSpawn(player.world.getDifficultyForLocation(new BlockPos(pixie)), null, null);
|
||||
player.world.spawnEntity(pixie);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import net.minecraftforge.items.VanillaDoubleChestItemHandler;
|
||||
import vazkii.botania.api.corporea.InvWithLocation;
|
||||
import vazkii.botania.common.block.tile.TileSimpleInventory;
|
||||
|
||||
@@ -40,13 +40,10 @@ public class InventoryHelper {
|
||||
if(te == null)
|
||||
return null;
|
||||
|
||||
IItemHandler ret = te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) ?
|
||||
te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side) : null;
|
||||
|
||||
if(ret == null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
|
||||
ret = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||
|
||||
return ret;
|
||||
LazyOptional<IItemHandler> ret = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
|
||||
if (!ret.isPresent())
|
||||
ret = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
|
||||
return ret.orElse(null);
|
||||
}
|
||||
|
||||
public static void dropInventory(TileSimpleInventory inv, World world, IBlockState state, BlockPos pos) {
|
||||
|
||||
@@ -21,115 +21,107 @@ public final class ItemNBTHelper {
|
||||
|
||||
private static final int[] EMPTY_INT_ARRAY = new int[0];
|
||||
|
||||
/** Gets the NBTTagCompound in an ItemStack. Tries to init it
|
||||
* previously in case there isn't one present **/
|
||||
public static NBTTagCompound getNBT(ItemStack stack) {
|
||||
if(!stack.hasTagCompound())
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
return stack.getTagCompound();
|
||||
}
|
||||
|
||||
// SETTERS ///////////////////////////////////////////////////////////////////
|
||||
|
||||
public static void setBoolean(ItemStack stack, String tag, boolean b) {
|
||||
getNBT(stack).setBoolean(tag, b);
|
||||
stack.getOrCreateTag().setBoolean(tag, b);
|
||||
}
|
||||
|
||||
public static void setByte(ItemStack stack, String tag, byte b) {
|
||||
getNBT(stack).setByte(tag, b);
|
||||
stack.getOrCreateTag().setByte(tag, b);
|
||||
}
|
||||
|
||||
public static void setShort(ItemStack stack, String tag, short s) {
|
||||
getNBT(stack).setShort(tag, s);
|
||||
stack.getOrCreateTag().setShort(tag, s);
|
||||
}
|
||||
|
||||
public static void setInt(ItemStack stack, String tag, int i) {
|
||||
getNBT(stack).setInteger(tag, i);
|
||||
stack.getOrCreateTag().setInt(tag, i);
|
||||
}
|
||||
|
||||
public static void setIntArray(ItemStack stack, String tag, int[] val) {
|
||||
getNBT(stack).setIntArray(tag, val);
|
||||
stack.getOrCreateTag().setIntArray(tag, val);
|
||||
}
|
||||
|
||||
public static void setLong(ItemStack stack, String tag, long l) {
|
||||
getNBT(stack).setLong(tag, l);
|
||||
stack.getOrCreateTag().setLong(tag, l);
|
||||
}
|
||||
|
||||
public static void setFloat(ItemStack stack, String tag, float f) {
|
||||
getNBT(stack).setFloat(tag, f);
|
||||
stack.getOrCreateTag().setFloat(tag, f);
|
||||
}
|
||||
|
||||
public static void setDouble(ItemStack stack, String tag, double d) {
|
||||
getNBT(stack).setDouble(tag, d);
|
||||
stack.getOrCreateTag().setDouble(tag, d);
|
||||
}
|
||||
|
||||
public static void setCompound(ItemStack stack, String tag, NBTTagCompound cmp) {
|
||||
if(!tag.equalsIgnoreCase("ench")) // not override the enchantments
|
||||
getNBT(stack).setTag(tag, cmp);
|
||||
stack.getOrCreateTag().setTag(tag, cmp);
|
||||
}
|
||||
|
||||
public static void setString(ItemStack stack, String tag, String s) {
|
||||
getNBT(stack).setString(tag, s);
|
||||
stack.getOrCreateTag().setString(tag, s);
|
||||
}
|
||||
|
||||
public static void setList(ItemStack stack, String tag, NBTTagList list) {
|
||||
getNBT(stack).setTag(tag, list);
|
||||
stack.getOrCreateTag().setTag(tag, list);
|
||||
}
|
||||
|
||||
public static void removeEntry(ItemStack stack, String tag) {
|
||||
getNBT(stack).removeTag(tag);
|
||||
stack.getOrCreateTag().removeTag(tag);
|
||||
}
|
||||
|
||||
// GETTERS ///////////////////////////////////////////////////////////////////
|
||||
|
||||
public static boolean verifyExistance(ItemStack stack, String tag) {
|
||||
return !stack.isEmpty() && getNBT(stack).hasKey(tag);
|
||||
return !stack.isEmpty() && stack.getOrCreateTag().hasKey(tag);
|
||||
}
|
||||
|
||||
public static boolean getBoolean(ItemStack stack, String tag, boolean defaultExpected) {
|
||||
return verifyExistance(stack, tag) ? getNBT(stack).getBoolean(tag) : defaultExpected;
|
||||
return verifyExistance(stack, tag) ? stack.getOrCreateTag().getBoolean(tag) : defaultExpected;
|
||||
}
|
||||
|
||||
public static byte getByte(ItemStack stack, String tag, byte defaultExpected) {
|
||||
return verifyExistance(stack, tag) ? getNBT(stack).getByte(tag) : defaultExpected;
|
||||
return verifyExistance(stack, tag) ? stack.getOrCreateTag().getByte(tag) : defaultExpected;
|
||||
}
|
||||
|
||||
public static short getShort(ItemStack stack, String tag, short defaultExpected) {
|
||||
return verifyExistance(stack, tag) ? getNBT(stack).getShort(tag) : defaultExpected;
|
||||
return verifyExistance(stack, tag) ? stack.getOrCreateTag().getShort(tag) : defaultExpected;
|
||||
}
|
||||
|
||||
public static int getInt(ItemStack stack, String tag, int defaultExpected) {
|
||||
return verifyExistance(stack, tag) ? getNBT(stack).getInteger(tag) : defaultExpected;
|
||||
return verifyExistance(stack, tag) ? stack.getOrCreateTag().getInt(tag) : defaultExpected;
|
||||
}
|
||||
|
||||
public static int[] getIntArray(ItemStack stack, String tag) {
|
||||
return verifyExistance(stack, tag) ? getNBT(stack).getIntArray(tag) : EMPTY_INT_ARRAY;
|
||||
return verifyExistance(stack, tag) ? stack.getOrCreateTag().getIntArray(tag) : EMPTY_INT_ARRAY;
|
||||
}
|
||||
|
||||
public static long getLong(ItemStack stack, String tag, long defaultExpected) {
|
||||
return verifyExistance(stack, tag) ? getNBT(stack).getLong(tag) : defaultExpected;
|
||||
return verifyExistance(stack, tag) ? stack.getOrCreateTag().getLong(tag) : defaultExpected;
|
||||
}
|
||||
|
||||
public static float getFloat(ItemStack stack, String tag, float defaultExpected) {
|
||||
return verifyExistance(stack, tag) ? getNBT(stack).getFloat(tag) : defaultExpected;
|
||||
return verifyExistance(stack, tag) ? stack.getOrCreateTag().getFloat(tag) : defaultExpected;
|
||||
}
|
||||
|
||||
public static double getDouble(ItemStack stack, String tag, double defaultExpected) {
|
||||
return verifyExistance(stack, tag) ? getNBT(stack).getDouble(tag) : defaultExpected;
|
||||
return verifyExistance(stack, tag) ? stack.getOrCreateTag().getDouble(tag) : defaultExpected;
|
||||
}
|
||||
|
||||
/** If nullifyOnFail is true it'll return null if it doesn't find any
|
||||
* compounds, otherwise it'll return a new one. **/
|
||||
public static NBTTagCompound getCompound(ItemStack stack, String tag, boolean nullifyOnFail) {
|
||||
return verifyExistance(stack, tag) ? getNBT(stack).getCompoundTag(tag) : nullifyOnFail ? null : new NBTTagCompound();
|
||||
return verifyExistance(stack, tag) ? stack.getOrCreateTag().getCompound(tag) : nullifyOnFail ? null : new NBTTagCompound();
|
||||
}
|
||||
|
||||
public static String getString(ItemStack stack, String tag, String defaultExpected) {
|
||||
return verifyExistance(stack, tag) ? getNBT(stack).getString(tag) : defaultExpected;
|
||||
return verifyExistance(stack, tag) ? stack.getOrCreateTag().getString(tag) : defaultExpected;
|
||||
}
|
||||
|
||||
public static NBTTagList getList(ItemStack stack, String tag, int objtype, boolean nullifyOnFail) {
|
||||
return verifyExistance(stack, tag) ? getNBT(stack).getTagList(tag, objtype) : nullifyOnFail ? null : new NBTTagList();
|
||||
return verifyExistance(stack, tag) ? stack.getOrCreateTag().getList(tag, objtype) : nullifyOnFail ? null : new NBTTagList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public final class PlayerHelper {
|
||||
|
||||
public static void grantCriterion(EntityPlayerMP player, ResourceLocation advancementId, String criterion) {
|
||||
PlayerAdvancements advancements = player.getAdvancements();
|
||||
AdvancementManager manager = player.getServerWorld().getAdvancementManager();
|
||||
AdvancementManager manager = player.getServerWorld().getServer().getAdvancementManager();
|
||||
Advancement advancement = manager.getAdvancement(advancementId);
|
||||
if(advancement != null) {
|
||||
advancements.grantCriterion(advancement, criterion);
|
||||
|
||||
@@ -10,16 +10,16 @@
|
||||
*/
|
||||
package vazkii.botania.common.core.helper;
|
||||
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.Vector4f;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
import org.lwjgl.util.vector.Vector4f;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
@@ -181,15 +181,17 @@ public class Vector3
|
||||
return x == 0 ? y == 0 || z == 0 : y == 0 && z == 0;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public Vector3f vector3f() {
|
||||
return new Vector3f((float)x, (float)y, (float)z);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public Vector4f vector4f() {
|
||||
return new Vector4f((float)x, (float)y, (float)z, 1);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void glVertex() {
|
||||
GL11.glVertex3d(x, y, z);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ package vazkii.botania.common.lib;
|
||||
|
||||
public final class LibPotionNames {
|
||||
|
||||
public static final String SOUL_CROSS = "soulCross";
|
||||
public static final String FEATHER_FEET = "featherFeet";
|
||||
public static final String SOUL_CROSS = "soul_cross";
|
||||
public static final String FEATHER_FEET = "feather_feet";
|
||||
public static final String EMPTINESS = "emptiness";
|
||||
public static final String BLOODTHIRST = "bloodthirst";
|
||||
public static final String ALLURE = "allure";
|
||||
|
||||
Reference in new issue
Block a user