pass through entities

This commit is contained in:
Vincent Lee committed 2019-02-03 21:11:05 -06:00
1 parent cc7d00f578
commit f8313ad928
29 files changed
+535 -576

No files matched your search

@@ -10,8 +10,8 @@
*/
package vazkii.botania.common.core.handler;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
import net.minecraftforge.fml.common.gameevent.TickEvent.WorldTickEvent;
import vazkii.botania.api.corporea.CorporeaHelper;
@@ -11,18 +11,17 @@
package vazkii.botania.common.core.handler;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.EntityEntry;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.registries.ForgeRegistries;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lexicon.page.PageShedding;
import vazkii.botania.common.lib.LibMisc;
@@ -30,7 +29,6 @@ import vazkii.botania.common.lib.LibMisc;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
@Mod.EventBusSubscriber(modid = LibMisc.MOD_ID)
public final class SheddingHandler {
@@ -55,7 +53,7 @@ public final class SheddingHandler {
private static ShedPattern getShedPattern(Entity entity) {
for(ShedPattern pattern : patterns)
if(pattern.EntityClass.isInstance(entity))
if(pattern.type.getEntityClass().isInstance(entity))
return pattern;
return null;
@@ -71,7 +69,7 @@ public final class SheddingHandler {
int i = 1;
for(ShedPattern pattern : patterns) {
PageShedding page = new PageShedding(String.valueOf(i), Objects.toString(EntityList.getKey(pattern.EntityClass)), pattern.lexiconSize, pattern.getItemStack());
PageShedding page = new PageShedding(String.valueOf(i), pattern.getEntityString(), pattern.lexiconSize, pattern.getItemStack());
LexiconData.shedding.addPage(page);
}
}
@@ -93,7 +91,7 @@ public final class SheddingHandler {
defaultNames.add(pattern.getEntityString());
}
for(Entry<ResourceLocation, EntityEntry> entry : ForgeRegistries.ENTITIES.getEntries()) {
for(Entry<ResourceLocation, EntityType<?>> entry : ForgeRegistries.ENTITIES.getEntries()) {
if(EntityLiving.class.isAssignableFrom(entry.getValue().getEntityClass())) {
String name = entry.getKey().toString();
if(!defaultNames.contains(name))
@@ -104,13 +102,11 @@ public final class SheddingHandler {
private static void loadFromConfig(Configuration config, String key, ShedPattern defaultPattern) {
String itemName = "";
int metadata = 0;
int rate = -1;
int lexiconSize = 40;
if(defaultPattern != null) {
itemName = Item.REGISTRY.getNameForObject(defaultPattern.getItemStack().getItem()).toString();
metadata = defaultPattern.getItemStack().getItemDamage();
itemName = defaultPattern.getItemStack().getItem().getRegistryName().toString();
rate = defaultPattern.rate;
lexiconSize = defaultPattern.lexiconSize;
}
@@ -119,22 +115,21 @@ public final class SheddingHandler {
prop.setComment("Configuration of Shedding for "+key);
itemName = prop.getString();
rate = config.get("Shedding", key + ".rate", rate).getInt();
metadata = config.get("Shedding", key + ".metadata", metadata).getInt();
lexiconSize = config.get("Shedding", key + ".lexiconDisplaySize", lexiconSize).getInt();
if(itemName != null && Item.REGISTRY.getObject(new ResourceLocation(itemName)) != null && rate != -1)
patterns.add(new ShedPattern(EntityList.getClass(new ResourceLocation(key)), new ItemStack(Item.REGISTRY.getObject(new ResourceLocation(itemName)), 1, metadata), rate, lexiconSize));
patterns.add(new ShedPattern(EntityList.getClass(new ResourceLocation(key)), new ItemStack(Item.REGISTRY.getObject(new ResourceLocation(itemName))), rate, lexiconSize));
}
private static class ShedPattern {
private final Class EntityClass;
private final EntityType<?> type;
private final ItemStack itemStack;
private final int rate;
private final int lexiconSize;
public ShedPattern(Class EntityClass, ItemStack itemStack, int rate, int lexiconSize) {
this.EntityClass = EntityClass;
public ShedPattern(EntityType<?> type, ItemStack itemStack, int rate, int lexiconSize) {
this.type = type;
this.itemStack = itemStack;
this.rate = rate;
this.lexiconSize = lexiconSize;
@@ -148,7 +143,7 @@ public final class SheddingHandler {
}
public String getEntityString() {
return Objects.toString(EntityList.getKey(EntityClass));
return type.getRegistryName().toString();
}
}
@@ -10,15 +10,16 @@ package vazkii.botania.common.crafting;
import com.google.gson.JsonObject;
import net.minecraft.util.JsonUtils;
import net.minecraftforge.common.crafting.IConditionFactory;
import net.minecraftforge.common.crafting.JsonContext;
import net.minecraftforge.common.crafting.IConditionSerializer;
import vazkii.botania.common.core.handler.ConfigHandler;
import javax.annotation.Nonnull;
import java.util.function.BooleanSupplier;
public class FluxfieldConditionFactory implements IConditionFactory {
public class FluxfieldConditionFactory implements IConditionSerializer {
@Nonnull
@Override
public BooleanSupplier parse(JsonContext context, JsonObject json) {
public BooleanSupplier parse(@Nonnull JsonObject json) {
boolean value = JsonUtils.getBoolean(json , "value", true);
return () -> ConfigHandler.fluxfieldEnabled == value;
}
@@ -51,7 +51,7 @@ public class ModBrewRecipes {
speedBrew = BotaniaAPI.registerBrewRecipe(ModBrews.speed, new ItemStack(Items.NETHER_WART), new ItemStack(Items.SUGAR), new ItemStack(Items.REDSTONE));
strengthBrew = BotaniaAPI.registerBrewRecipe(ModBrews.strength, new ItemStack(Items.NETHER_WART), new ItemStack(Items.BLAZE_POWDER), new ItemStack(Items.GLOWSTONE_DUST));
hasteBrew = BotaniaAPI.registerBrewRecipe(ModBrews.haste, new ItemStack(Items.NETHER_WART), new ItemStack(Items.SUGAR), new ItemStack(Items.GOLD_NUGGET));
healingBrew = BotaniaAPI.registerBrewRecipe(ModBrews.healing, new ItemStack(Items.NETHER_WART), new ItemStack(Items.SPECKLED_MELON), new ItemStack(Items.POTATO));
healingBrew = BotaniaAPI.registerBrewRecipe(ModBrews.healing, new ItemStack(Items.NETHER_WART), new ItemStack(Items.GLISTERING_MELON_SLICE), new ItemStack(Items.POTATO));
jumpBoostBrew = BotaniaAPI.registerBrewRecipe(ModBrews.jumpBoost, new ItemStack(Items.NETHER_WART), new ItemStack(Items.FEATHER), new ItemStack(Items.CARROT));
regenerationBrew = BotaniaAPI.registerBrewRecipe(ModBrews.regen, new ItemStack(Items.NETHER_WART), new ItemStack(Items.GHAST_TEAR), new ItemStack(Items.GLOWSTONE_DUST));
weakRegenerationBrew = BotaniaAPI.registerBrewRecipe(ModBrews.regenWeak, new ItemStack(Items.NETHER_WART), new ItemStack(Items.GHAST_TEAR), new ItemStack(Items.REDSTONE));
@@ -66,15 +66,15 @@ public class ModBrewRecipes {
soulCrossBrew = BotaniaAPI.registerBrewRecipe(ModBrews.soulCross, new ItemStack(Items.NETHER_WART), new ItemStack(Blocks.SOUL_SAND), new ItemStack(Items.PAPER), new ItemStack(Items.APPLE), new ItemStack(Items.BONE));
featherFeetBrew = BotaniaAPI.registerBrewRecipe(ModBrews.featherfeet, new ItemStack(Items.NETHER_WART), new ItemStack(Items.FEATHER), new ItemStack(Items.LEATHER), new ItemStack(Blocks.WOOL, 1, -1));
emptinessBrew = BotaniaAPI.registerBrewRecipe(ModBrews.emptiness, new ItemStack(Items.NETHER_WART), new ItemStack(Items.GUNPOWDER), new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.BONE), new ItemStack(Items.STRING), new ItemStack(Items.ENDER_PEARL));
bloodthirstBrew = BotaniaAPI.registerBrewRecipe(ModBrews.bloodthirst, new ItemStack(Items.NETHER_WART), new ItemStack(Items.FERMENTED_SPIDER_EYE), new ItemStack(Items.DYE, 1, 4), new ItemStack(Items.FIRE_CHARGE), new ItemStack(Items.IRON_INGOT));
allureBrew = BotaniaAPI.registerBrewRecipe(ModBrews.allure, new ItemStack(Items.NETHER_WART), new ItemStack(Items.FISH), new ItemStack(Items.QUARTZ), new ItemStack(Items.GOLDEN_CARROT));
clearBrew = BotaniaAPI.registerBrewRecipe(ModBrews.clear, new ItemStack(Items.NETHER_WART), new ItemStack(Items.QUARTZ), new ItemStack(Items.EMERALD), new ItemStack(Items.MELON));
bloodthirstBrew = BotaniaAPI.registerBrewRecipe(ModBrews.bloodthirst, new ItemStack(Items.NETHER_WART), new ItemStack(Items.FERMENTED_SPIDER_EYE), new ItemStack(Items.LAPIS_LAZULI), new ItemStack(Items.FIRE_CHARGE), new ItemStack(Items.IRON_INGOT));
allureBrew = BotaniaAPI.registerBrewRecipe(ModBrews.allure, new ItemStack(Items.NETHER_WART), new ItemStack(Items.COD), new ItemStack(Items.QUARTZ), new ItemStack(Items.GOLDEN_CARROT));
clearBrew = BotaniaAPI.registerBrewRecipe(ModBrews.clear, new ItemStack(Items.NETHER_WART), new ItemStack(Items.QUARTZ), new ItemStack(Items.EMERALD), new ItemStack(Items.MELON_SLICE));
}
public static void initTC() {
Item salisMundus = Item.REGISTRY.getObject(new ResourceLocation("thaumcraft", "salis_mundus"));
Item bathSalts = Item.REGISTRY.getObject(new ResourceLocation("thaumcraft", "bath_salts"));
Item amber = Item.REGISTRY.getObject(new ResourceLocation("thaumcraft", "amber"));
Item salisMundus = Item.REGISTRY.get(new ResourceLocation("thaumcraft", "salis_mundus"));
Item bathSalts = Item.REGISTRY.get(new ResourceLocation("thaumcraft", "bath_salts"));
Item amber = Item.REGISTRY.get(new ResourceLocation("thaumcraft", "amber"));
warpWardBrew = BotaniaAPI.registerBrewRecipe(ModBrews.warpWard, new ItemStack(Items.NETHER_WART), new ItemStack(salisMundus), new ItemStack(bathSalts), new ItemStack(amber));
}
@@ -83,7 +83,7 @@ public final class ModManaInfusionRecipes {
manaStringRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaString), new ItemStack(Items.STRING), 5000);
if(Botania.gardenOfGlassLoaded)
sugarCaneRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(Items.REEDS), new ItemStack(Blocks.HAY_BLOCK), 2000);
sugarCaneRecipe = BotaniaAPI.registerManaInfusionRecipe(new ItemStack(Blocks.SUGAR_CANE), new ItemStack(Blocks.HAY_BLOCK), 2000);
BotaniaAPI.registerManaInfusionRecipe(new ItemStack(ModItems.manaBottle), new ItemStack(Items.GLASS_BOTTLE), 5000);
}
@@ -129,7 +129,7 @@ public final class ModPetalRecipes {
solegnoliaRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_SOLEGNOLIA), brown, brown, red, blue, redstoneRoot);
bergamuteRecipe = BotaniaAPI.registerPetalRecipe(ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_BERGAMUTE), orange, green, green, redstoneRoot);
ItemStack stack = new ItemStack(Items.SKULL, 1, 3);
ItemStack stack = new ItemStack(Items.PLAYER_HEAD);
ItemNBTHelper.setString(stack, "SkullOwner", "Vazkii");
Object[] inputs = new Object[16];
Arrays.fill(inputs, pink);
@@ -48,7 +48,7 @@ public final class ModRuneRecipes {
final int costTier2 = 8000;
final int costTier3 = 12000;
recipeWaterRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeWater, 2), costTier1, LibOreDict.MANA_POWDER, LibOreDict.MANA_STEEL, new ItemStack(Items.DYE, 1, 15), "sugarcane", new ItemStack(Items.FISHING_ROD));
recipeWaterRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeWater, 2), costTier1, LibOreDict.MANA_POWDER, LibOreDict.MANA_STEEL, new ItemStack(Items.BONE_MEAL), "sugarcane", new ItemStack(Items.FISHING_ROD));
recipeFireRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeFire, 2), costTier1, LibOreDict.MANA_POWDER, LibOreDict.MANA_STEEL, "ingotBrickNether", "gunpowder", "cropNetherWart");
recipesEarthRune = new ArrayList<>();
@@ -60,7 +60,7 @@ public final class ModRuneRecipes {
recipesAirRune.add(BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeAir, 2), costTier1, LibOreDict.MANA_POWDER, LibOreDict.MANA_STEEL, new ItemStack(Blocks.CARPET, 1, i), "feather", "string"));
recipeSpringRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeSpring), costTier2, LibOreDict.RUNE[0], LibOreDict.RUNE[1], "treeSapling", "treeSapling", "treeSapling", "cropWheat");
recipeSummerRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeSummer), costTier2, LibOreDict.RUNE[2], LibOreDict.RUNE[3], new ItemStack(Blocks.SAND), new ItemStack(Blocks.SAND), "slimeball", new ItemStack(Items.MELON));
recipeSummerRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeSummer), costTier2, LibOreDict.RUNE[2], LibOreDict.RUNE[3], new ItemStack(Blocks.SAND), new ItemStack(Blocks.SAND), "slimeball", new ItemStack(Items.MELON_SLICE));
recipeAutumnRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeAutumn), costTier2, LibOreDict.RUNE[1], LibOreDict.RUNE[3], "treeLeaves", "treeLeaves", "treeLeaves", new ItemStack(Items.SPIDER_EYE));
recipesWinterRune = new ArrayList<>();
@@ -77,7 +77,7 @@ public final class ModRuneRecipes {
recipeEnvyRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runeEnvy), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[7], LibOreDict.RUNE[0]);
recipePrideRune = BotaniaAPI.registerRuneAltarRecipe(new ItemStack(ModItems.runePride), costTier3, LibOreDict.MANA_DIAMOND, LibOreDict.MANA_DIAMOND, LibOreDict.RUNE[5], LibOreDict.RUNE[1]);
recipeHead = new HeadRecipe(new ItemStack(Items.SKULL, 1, 3), 22500, new ItemStack(Items.SKULL), LibOreDict.PIXIE_DUST, "gemPrismarine", new ItemStack(Items.NAME_TAG), new ItemStack(Items.GOLDEN_APPLE));
recipeHead = new HeadRecipe(new ItemStack(Items.PLAYER_HEAD), 22500, new ItemStack(Items.SKULL), LibOreDict.PIXIE_DUST, "gemPrismarine", new ItemStack(Items.NAME_TAG), new ItemStack(Items.GOLDEN_APPLE));
BotaniaAPI.runeAltarRecipes.add(recipeHead);
}
}
@@ -11,6 +11,7 @@
package vazkii.botania.common.entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -24,6 +25,7 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.core.helper.PlayerHelper;
@@ -36,11 +38,14 @@ import javax.annotation.Nonnull;
import elucent.albedo.lighting.ILightProvider;
import elucent.albedo.lighting.Light;
import vazkii.botania.common.lib.LibMisc;
import java.util.List;
@Optional.Interface(iface="elucent.albedo.lighting.ILightProvider", modid="albedo")
public class EntityBabylonWeapon extends EntityThrowableCopy implements ILightProvider {
@ObjectHolder(LibMisc.MOD_ID + ":babylon_weapon")
public static EntityType<?> TYPE;
private static final String TAG_CHARGING = "charging";
private static final String TAG_VARIETY = "variety";
@@ -57,16 +62,16 @@ public class EntityBabylonWeapon extends EntityThrowableCopy implements ILightPr
private static final DataParameter<Float> ROTATION = EntityDataManager.createKey(EntityBabylonWeapon.class, DataSerializers.FLOAT);
public EntityBabylonWeapon(World world) {
super(world);
super(TYPE, world);
}
public EntityBabylonWeapon(World world, EntityLivingBase thrower) {
super(world, thrower);
public EntityBabylonWeapon(EntityLivingBase thrower, World world) {
super(TYPE, thrower, world);
}
@Override
protected void entityInit() {
super.entityInit();
protected void registerData() {
super.registerData();
setSize(0F, 0F);
dataManager.register(CHARGING, false);
@@ -83,10 +88,10 @@ public class EntityBabylonWeapon extends EntityThrowableCopy implements ILightPr
}
@Override
public void onUpdate() {
public void tick() {
EntityLivingBase thrower = getThrower();
if(!world.isRemote && (thrower == null || !(thrower instanceof EntityPlayer) || thrower.isDead)) {
setDead();
if(!world.isRemote && (thrower == null || !(thrower instanceof EntityPlayer) || thrower.removed)) {
remove();
return;
}
EntityPlayer player = (EntityPlayer) thrower;
@@ -158,7 +163,7 @@ public class EntityBabylonWeapon extends EntityThrowableCopy implements ILightPr
}
}
super.onUpdate();
super.tick();
motionX = x;
motionY = y;
@@ -168,37 +173,37 @@ public class EntityBabylonWeapon extends EntityThrowableCopy implements ILightPr
Botania.proxy.wispFX(posX, posY, posZ, 1F, 1F, 0F, 0.3F, 0F);
if(liveTime > 200 + delay)
setDead();
remove();
}
@Override
protected void onImpact(RayTraceResult pos) {
EntityLivingBase thrower = getThrower();
if(pos.entityHit == null || pos.entityHit != thrower) {
if(pos.entity == null || pos.entity != thrower) {
world.createExplosion(this, posX, posY, posZ, 3F, false);
setDead();
remove();
}
}
@Override
public void writeEntityToNBT(@Nonnull NBTTagCompound cmp) {
super.writeEntityToNBT(cmp);
public void writeAdditional(@Nonnull NBTTagCompound cmp) {
super.writeAdditional(cmp);
cmp.setBoolean(TAG_CHARGING, isCharging());
cmp.setInteger(TAG_VARIETY, getVariety());
cmp.setInteger(TAG_CHARGE_TICKS, getChargeTicks());
cmp.setInteger(TAG_LIVE_TICKS, getLiveTicks());
cmp.setInteger(TAG_DELAY, getDelay());
cmp.setInt(TAG_VARIETY, getVariety());
cmp.setInt(TAG_CHARGE_TICKS, getChargeTicks());
cmp.setInt(TAG_LIVE_TICKS, getLiveTicks());
cmp.setInt(TAG_DELAY, getDelay());
cmp.setFloat(TAG_ROTATION, getRotation());
}
@Override
public void readEntityFromNBT(@Nonnull NBTTagCompound cmp) {
super.readEntityFromNBT(cmp);
public void readAdditional(@Nonnull NBTTagCompound cmp) {
super.readAdditional(cmp);
setCharging(cmp.getBoolean(TAG_CHARGING));
setVariety(cmp.getInteger(TAG_VARIETY));
setChargeTicks(cmp.getInteger(TAG_CHARGE_TICKS));
setLiveTicks(cmp.getInteger(TAG_LIVE_TICKS));
setDelay(cmp.getInteger(TAG_DELAY));
setVariety(cmp.getInt(TAG_VARIETY));
setChargeTicks(cmp.getInt(TAG_CHARGE_TICKS));
setLiveTicks(cmp.getInt(TAG_LIVE_TICKS));
setDelay(cmp.getInt(TAG_DELAY));
setRotation(cmp.getFloat(TAG_ROTATION));
}
@@ -12,6 +12,7 @@ package vazkii.botania.common.entity;
import com.google.common.base.Predicates;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
@@ -26,17 +27,21 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.api.corporea.ICorporeaSpark;
import vazkii.botania.api.corporea.InvWithLocation;
import vazkii.botania.common.core.helper.InventoryHelper;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.material.ItemDye;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
@ObjectHolder(LibMisc.MOD_ID + ":corporea_spark")
public static EntityType<?> TYPE;
private static final int SCAN_RANGE = 8;
@@ -55,12 +60,12 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
private boolean firstTick = true;
public EntityCorporeaSpark(World world) {
super(world);
super(TYPE, world);
isImmuneToFire = true;
}
@Override
protected void entityInit() {
protected void registerData() {
setSize(0.1F, 0.5F);
dataManager.register(MASTER, false);
dataManager.register(NETWORK, 0);
@@ -80,8 +85,8 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
}
@Override
public void onUpdate() {
super.onUpdate();
public void tick() {
super.tick();
if(world.isRemote)
return;
@@ -103,7 +108,7 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
firstTick = false;
}
if(master != null && (((Entity) master).isDead || master.getNetwork() != getNetwork()))
if(master != null && (((Entity) master).removed || master.getNetwork() != getNetwork()))
master = null;
int displayTicks = getItemDisplayTicks();
@@ -115,12 +120,12 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
private void dropAndKill() {
entityDropItem(new ItemStack(isMaster() ? ModItems.corporeaSparkMaster : ModItems.corporeaSpark), 0F);
setDead();
remove();
}
@Override
public void setDead() {
super.setDead();
public void remove() {
super.remove();
connections.remove(this);
restartNetwork();
}
@@ -129,7 +134,7 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
public void registerConnections(ICorporeaSpark master, ICorporeaSpark referrer, List<ICorporeaSpark> connections) {
relatives.clear();
for(ICorporeaSpark spark : getNearbySparks()) {
if(spark == null || connections.contains(spark) || spark.getNetwork() != getNetwork() || spark.isMaster() || ((Entity) spark).isDead)
if(spark == null || connections.contains(spark) || spark.getNetwork() != getNetwork() || spark.isMaster() || ((Entity) spark).removed)
continue;
connections.add(spark);
@@ -159,7 +164,7 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
private void findNetwork() {
for(ICorporeaSpark spark : getNearbySparks())
if(spark.getNetwork() == getNetwork() && !((Entity) spark).isDead) {
if(spark.getNetwork() == getNetwork() && !((Entity) spark).removed) {
ICorporeaSpark master = spark.getMaster();
if(master != null) {
this.master = master;
@@ -233,12 +238,12 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
}
public void setNetwork(EnumDyeColor network) {
dataManager.set(NETWORK, network.getMetadata());
dataManager.set(NETWORK, network.getId());
}
@Override
public EnumDyeColor getNetwork() {
return EnumDyeColor.byMetadata(dataManager.get(NETWORK));
return EnumDyeColor.byId(dataManager.get(NETWORK));
}
public int getItemDisplayTicks() {
@@ -260,7 +265,7 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
@Override
public boolean processInitialInteract(EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(!isDead && !stack.isEmpty()) {
if(!removed && !stack.isEmpty()) {
if(player.world.isRemote) {
boolean valid = stack.getItem() == ModItems.twigWand || stack.getItem() instanceof ItemDye || stack.getItem() == ModItems.phantomInk;
if(valid)
@@ -299,17 +304,17 @@ public class EntityCorporeaSpark extends Entity implements ICorporeaSpark {
}
@Override
protected void readEntityFromNBT(@Nonnull NBTTagCompound cmp) {
protected void readAdditional(@Nonnull NBTTagCompound cmp) {
setMaster(cmp.getBoolean(TAG_MASTER));
setNetwork(EnumDyeColor.byMetadata(cmp.getInteger(TAG_NETWORK)));
setInvisible(cmp.getInteger(TAG_INVIS) == 1);
setNetwork(EnumDyeColor.byId(cmp.getInt(TAG_NETWORK)));
setInvisible(cmp.getInt(TAG_INVIS) == 1);
}
@Override
protected void writeEntityToNBT(@Nonnull NBTTagCompound cmp) {
protected void writeAdditional(@Nonnull NBTTagCompound cmp) {
cmp.setBoolean(TAG_MASTER, isMaster());
cmp.setInteger(TAG_NETWORK, getNetwork().getMetadata());
cmp.setInteger(TAG_INVIS, isInvisible() ? 1 : 0);
cmp.setInt(TAG_NETWORK, getNetwork().getId());
cmp.setInt(TAG_INVIS, isInvisible() ? 1 : 0);
}
}
@@ -18,10 +18,7 @@ import net.minecraft.client.audio.MovingSound;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
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.SharedMonsterAttributes;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntitySkeleton;
@@ -30,13 +27,11 @@ import net.minecraft.entity.monster.EntityWitherSkeleton;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.init.*;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
@@ -53,6 +48,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
@@ -61,10 +57,13 @@ import net.minecraft.world.BossInfoServer;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.registries.ObjectHolder;
import org.lwjgl.opengl.ARBShaderObjects;
import vazkii.botania.api.boss.IBotaniaBoss;
import vazkii.botania.api.internal.ShaderCallback;
@@ -86,6 +85,7 @@ import vazkii.botania.common.network.PacketBotaniaEffect;
import vazkii.botania.common.network.PacketHandler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Arrays;
@@ -96,6 +96,8 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IEntityAdditionalSpawnData {
@ObjectHolder(LibMisc.MOD_ID + ":doppleganger")
public static EntityType<?> TYPE;
public static final float ARENA_RANGE = 12F;
private static final int SPAWN_TICKS = 160;
@@ -146,7 +148,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
public EntityPlayer trueKiller = null;
public EntityDoppleganger(World world) {
super(world);
super(TYPE, world);
setSize(0.6F, 1.8F);
isImmuneToFire = true;
experienceValue = 825;
@@ -225,8 +227,8 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
if (hard)
e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ARMOR).setBaseValue(15);
e.playSound(SoundEvents.ENTITY_ENDERDRAGON_GROWL, 10F, 0.1F);
e.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(e)), null);
e.playSound(SoundEvents.ENTITY_ENDER_DRAGON_GROWL, 10F, 0.1F);
e.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(e)), null, null);
world.spawnEntity(e);
return true;
}
@@ -312,35 +314,35 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
}
@Override
public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) {
super.writeEntityToNBT(par1nbtTagCompound);
par1nbtTagCompound.setInteger(TAG_INVUL_TIME, getInvulTime());
public void writeAdditional(NBTTagCompound par1nbtTagCompound) {
super.writeAdditional(par1nbtTagCompound);
par1nbtTagCompound.setInt(TAG_INVUL_TIME, getInvulTime());
par1nbtTagCompound.setBoolean(TAG_AGGRO, aggro);
par1nbtTagCompound.setInteger(TAG_MOB_SPAWN_TICKS, mobSpawnTicks);
par1nbtTagCompound.setInt(TAG_MOB_SPAWN_TICKS, mobSpawnTicks);
par1nbtTagCompound.setInteger(TAG_SOURCE_X, source.getX());
par1nbtTagCompound.setInteger(TAG_SOURCE_Y, source.getY());
par1nbtTagCompound.setInteger(TAG_SOURCE_Z, source.getZ());
par1nbtTagCompound.setInt(TAG_SOURCE_X, source.getX());
par1nbtTagCompound.setInt(TAG_SOURCE_Y, source.getY());
par1nbtTagCompound.setInt(TAG_SOURCE_Z, source.getZ());
par1nbtTagCompound.setBoolean(TAG_HARD_MODE, hardMode);
par1nbtTagCompound.setInteger(TAG_PLAYER_COUNT, playerCount);
par1nbtTagCompound.setInt(TAG_PLAYER_COUNT, playerCount);
}
@Override
public void readEntityFromNBT(NBTTagCompound par1nbtTagCompound) {
super.readEntityFromNBT(par1nbtTagCompound);
setInvulTime(par1nbtTagCompound.getInteger(TAG_INVUL_TIME));
public void readAdditional(NBTTagCompound par1nbtTagCompound) {
super.readAdditional(par1nbtTagCompound);
setInvulTime(par1nbtTagCompound.getInt(TAG_INVUL_TIME));
aggro = par1nbtTagCompound.getBoolean(TAG_AGGRO);
mobSpawnTicks = par1nbtTagCompound.getInteger(TAG_MOB_SPAWN_TICKS);
mobSpawnTicks = par1nbtTagCompound.getInt(TAG_MOB_SPAWN_TICKS);
int x = par1nbtTagCompound.getInteger(TAG_SOURCE_X);
int y = par1nbtTagCompound.getInteger(TAG_SOURCE_Y);
int z = par1nbtTagCompound.getInteger(TAG_SOURCE_Z);
int x = par1nbtTagCompound.getInt(TAG_SOURCE_X);
int y = par1nbtTagCompound.getInt(TAG_SOURCE_Y);
int z = par1nbtTagCompound.getInt(TAG_SOURCE_Z);
source = new BlockPos(x, y, z);
hardMode = par1nbtTagCompound.getBoolean(TAG_HARD_MODE);
if(par1nbtTagCompound.hasKey(TAG_PLAYER_COUNT))
playerCount = par1nbtTagCompound.getInteger(TAG_PLAYER_COUNT);
playerCount = par1nbtTagCompound.getInt(TAG_PLAYER_COUNT);
else playerCount = 1;
if (this.hasCustomName()) {
@@ -349,8 +351,8 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
}
@Override
public void setCustomNameTag(@Nonnull String name) {
super.setCustomNameTag(name);
public void setCustomName(@Nullable ITextComponent name) {
super.setCustomName(name);
this.bossInfo.setName(this.getDisplayName());
}
@@ -389,7 +391,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
EntityPlayer player = (EntityPlayer) e;
String name = player.getName();
String name = player.getName().getUnformattedComponentText();
return !(player instanceof FakePlayer || FAKE_PLAYER_PATTERN.matcher(name).matches());
}
@@ -424,15 +426,15 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
}
playSound(SoundEvents.ENTITY_GENERIC_EXPLODE, 20F, (1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F) * 0.7F);
world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, posX, posY, posZ, 1D, 0D, 0D);
world.spawnParticle(Particles.EXPLOSION_EMITTER, posX, posY, posZ, 1D, 0D, 0D);
}
@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.4);
getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(MAX_HP);
getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(1.0);
protected void registerAttributes() {
super.registerAttributes();
getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.4);
getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(MAX_HP);
getAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(1.0);
}
@Override
@@ -486,11 +488,11 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
}
@Override
public void setDead() {
public void remove() {
if(world.isRemote) {
Botania.proxy.removeBoss(this);
}
super.setDead();
super.remove();
}
private List<EntityPlayer> getPlayersAround() {
@@ -567,7 +569,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
int posZInt = MathHelper.floor(posZ);
List<Potion> potionsToRemove = player.getActivePotionEffects().stream()
.filter(effect -> effect.getDuration() < 160 && effect.getIsAmbient() && !effect.getPotion().isBadEffect())
.filter(effect -> effect.getDuration() < 160 && effect.isAmbient() && !effect.getPotion().isBadEffect())
.map(PotionEffect::getPotion)
.distinct()
.collect(Collectors.toList());
@@ -616,7 +618,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
EntityPixie pixie = new EntityPixie(world);
pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8);
pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2);
pixie.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(pixie)), null);
pixie.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(pixie)), null, null);
world.spawnEntity(pixie);
}
}
@@ -629,7 +631,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
entity.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 600, 0));
float range = 6F;
entity.setPosition(posX + 0.5 + Math.random() * range - range / 2, posY - 1, posZ + 0.5 + Math.random() * range - range / 2);
entity.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(entity)), null);
entity.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(entity)), null, null);
if(entity instanceof EntityWitherSkeleton && hardMode) {
entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(ModItems.elementiumSword));
}
@@ -640,8 +642,8 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
}
@Override
public void onLivingUpdate() {
super.onLivingUpdate();
public void livingTick() {
super.livingTick();
int invul = getInvulTime();
@@ -649,14 +651,14 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
particles();
EntityPlayer player = Botania.proxy.getClientPlayer();
if(getPlayersAround().contains(player))
player.capabilities.isFlying = player.capabilities.isFlying && player.capabilities.isCreativeMode;
player.abilities.isFlying = player.abilities.isFlying && player.abilities.isCreativeMode;
return;
}
bossInfo.setPercent(getHealth() / getMaxHealth());
if(!getPassengers().isEmpty())
dismountRidingEntity();
stopRiding();
if(world.getDifficulty() == EnumDifficulty.PEACEFUL)
setDead();
@@ -678,11 +680,11 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
clearPotions(player);
keepInsideArena(player);
player.capabilities.isFlying = player.capabilities.isFlying && player.capabilities.isCreativeMode;
player.abilities.isFlying = player.abilities.isFlying && player.abilities.isCreativeMode;
}
}
if(isDead)
if(removed)
return;
boolean spawnMissiles = hardMode && ticksExisted % 15 < 4;
@@ -757,7 +759,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
EntityPixie pixie = new EntityPixie(world);
pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8);
pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2);
pixie.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(pixie)), null);
pixie.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(pixie)), null, null);
world.spawnEntity(pixie);
}
@@ -818,7 +820,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
private static boolean isCheatyBlock(World world, BlockPos pos) {
Block block = world.getBlockState(pos).getBlock();
return CHEATY_BLOCKS.contains(Block.REGISTRY.getNameForObject(block));
return CHEATY_BLOCKS.contains(block.getRegistryName());
}
// [VanillaCopy] EntityEnderman.teleportRandomly, edits noted.
@@ -941,18 +943,18 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
}
@Override
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public ResourceLocation getBossBarTexture() {
return BossBarHandler.defaultBossBar;
}
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
private static Rectangle barRect;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
private static Rectangle hpBarRect;
@Override
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public Rectangle getBossBarTextureRect() {
if(barRect == null)
barRect = new Rectangle(0, 0, 185, 15);
@@ -960,7 +962,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
}
@Override
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public Rectangle getBossBarHPTextureRect() {
if(hpBarRect == null)
hpBarRect = new Rectangle(0, barRect.y + barRect.height, 181, 7);
@@ -968,18 +970,18 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
}
@Override
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public int bossBarRenderCallback(ScaledResolution res, int x, int y) {
GlStateManager.pushMatrix();
int px = x + 160;
int py = y + 12;
Minecraft mc = Minecraft.getMinecraft();
ItemStack stack = new ItemStack(Items.SKULL, 1, 3);
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Minecraft mc = Minecraft.getInstance();
ItemStack stack = new ItemStack(Items.PLAYER_HEAD);
mc.textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
GlStateManager.enableRescaleNormal();
mc.getRenderItem().renderItemIntoGUI(stack, px, py);
mc.getItemRenderer().renderItemIntoGUI(stack, px, py);
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
boolean unicode = mc.fontRenderer.getUnicodeFlag();
@@ -997,16 +999,16 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
}
@Override
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public int getBossBarShaderProgram(boolean background) {
return background ? 0 : ShaderHelper.dopplegangerBar;
}
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
private ShaderCallback shaderCallback;
@Override
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public ShaderCallback getBossBarShaderCallback(boolean background, int shader) {
if(shaderCallback == null)
shaderCallback = shader1 -> {
@@ -1033,33 +1035,33 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
}
@Override
@SideOnly(Side.CLIENT)
public void readSpawnData(ByteBuf additionalData) {
@OnlyIn(Dist.CLIENT)
public void readSpawnData(PacketBuffer additionalData) {
playerCount = additionalData.readInt();
hardMode = additionalData.readBoolean();
source = BlockPos.fromLong(additionalData.readLong());
long msb = additionalData.readLong();
long lsb = additionalData.readLong();
bossInfoUUID = new UUID(msb, lsb);
Minecraft.getMinecraft().getSoundHandler().playSound(new DopplegangerMusic(this));
Minecraft.getInstance().getSoundHandler().play(new DopplegangerMusic(this));
}
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
private static class DopplegangerMusic extends MovingSound {
private final EntityDoppleganger guardian;
public DopplegangerMusic(EntityDoppleganger guardian) {
super(guardian.hardMode ? ModSounds.gaiaMusic2 : ModSounds.gaiaMusic1, SoundCategory.RECORDS);
this.guardian = guardian;
this.xPosF = guardian.getSource().getX();
this.yPosF = guardian.getSource().getY();
this.zPosF = guardian.getSource().getZ();
this.x = guardian.getSource().getX();
this.y = guardian.getSource().getY();
this.z = guardian.getSource().getZ();
this.repeat = true;
}
@Override
public void update() {
if (!guardian.isEntityAlive()) {
public void tick() {
if (!guardian.isAlive()) {
donePlaying = true;
}
}
@@ -14,11 +14,14 @@ import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.state.pattern.BlockStateMatcher;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.util.ArrayList;
@@ -27,13 +30,15 @@ import java.util.List;
import java.util.stream.Collectors;
public class EntityEnderAirBottle extends EntityThrowable {
@ObjectHolder(LibMisc.MOD_ID + ":ender_air_bottle")
public static EntityType<?> TYPE;
public EntityEnderAirBottle(World world) {
super(world);
super(TYPE, world);
}
public EntityEnderAirBottle(World world, EntityLivingBase entity) {
super(world, entity);
public EntityEnderAirBottle(EntityLivingBase entity, World world) {
super(TYPE, entity, world);
}
@Override
@@ -47,7 +52,7 @@ public class EntityEnderAirBottle extends EntityThrowable {
if(Math.random() < 0.1)
world.playEvent(2001, coords, Block.getStateId(Blocks.END_STONE.getDefaultState()));
}
setDead();
remove();
}
}
@@ -13,12 +13,14 @@ package vazkii.botania.common.entity;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.ConfigHandler;
@@ -26,23 +28,26 @@ import java.util.List;
import elucent.albedo.lighting.ILightProvider;
import elucent.albedo.lighting.Light;
import vazkii.botania.common.lib.LibMisc;
@Optional.Interface(iface="elucent.albedo.lighting.ILightProvider", modid="albedo")
public class EntityFallingStar extends EntityThrowableCopy implements ILightProvider {
@ObjectHolder(LibMisc.MOD_ID + ":falling_star")
public static EntityType<?> TYPE;
public EntityFallingStar(World world) {
super(world);
super(TYPE, world);
setSize(0F, 0F);
}
public EntityFallingStar(World world, EntityLivingBase e) {
super(world, e);
public EntityFallingStar(EntityLivingBase e, World world) {
super(TYPE, e, world);
setSize(0F, 0F);
}
@Override
public void onUpdate() {
super.onUpdate();
public void tick() {
super.tick();
float dist = 1.5F;
for(int i = 0; i < 10; i++) {
@@ -68,7 +73,7 @@ public class EntityFallingStar extends EntityThrowableCopy implements ILightProv
}
if(ticksExisted > 200)
setDead();
remove();
}
@Override
@@ -77,10 +82,10 @@ public class EntityFallingStar extends EntityThrowableCopy implements ILightProv
return;
EntityLivingBase thrower = getThrower();
if(pos.entityHit != null && thrower != null && pos.entityHit != thrower && !pos.entityHit.isDead) {
if(pos.entity != null && thrower != null && pos.entity != thrower && !pos.entity.removed) {
if(thrower instanceof EntityPlayer)
pos.entityHit.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) thrower), Math.random() < 0.25 ? 10 : 5);
else pos.entityHit.attackEntityFrom(DamageSource.GENERIC, Math.random() < 0.25 ? 10 : 5);
pos.entity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) thrower), Math.random() < 0.25 ? 10 : 5);
else pos.entity.attackEntityFrom(DamageSource.GENERIC, Math.random() < 0.25 ? 10 : 5);
}
if (pos.getBlockPos() != null) {
@@ -89,7 +94,7 @@ public class EntityFallingStar extends EntityThrowableCopy implements ILightProv
world.playEvent(2001, pos.getBlockPos(), Block.getStateId(state));
}
setDead();
remove();
}
@Override
@@ -12,6 +12,7 @@ package vazkii.botania.common.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityType;
import net.minecraft.init.SoundEvents;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
@@ -19,6 +20,7 @@ import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.helper.MathHelper;
@@ -26,24 +28,26 @@ import javax.annotation.Nonnull;
import elucent.albedo.lighting.ILightProvider;
import elucent.albedo.lighting.Light;
import vazkii.botania.common.lib.LibMisc;
import java.util.List;
@Optional.Interface(iface="elucent.albedo.lighting.ILightProvider", modid="albedo")
public class EntityFlameRing extends Entity implements ILightProvider {
@ObjectHolder(LibMisc.MOD_ID + ":flame_ring")
public static EntityType<?> TYPE;
public EntityFlameRing(World world) {
super(world);
}
@Override
protected void entityInit() {
super(TYPE, world);
setSize(0F, 0F);
}
@Override
public void onEntityUpdate() {
super.onEntityUpdate();
protected void registerData() {}
@Override
public void baseTick() {
super.baseTick();
float radius = 5F;
float renderRadius = (float) (radius - Math.random());
@@ -75,7 +79,7 @@ public class EntityFlameRing extends Entity implements ILightProvider {
return;
if(ticksExisted >= 300) {
setDead();
remove();
return;
}
@@ -101,10 +105,10 @@ public class EntityFlameRing extends Entity implements ILightProvider {
}
@Override
protected void readEntityFromNBT(@Nonnull NBTTagCompound var1) {}
protected void readAdditional(@Nonnull NBTTagCompound var1) {}
@Override
protected void writeEntityToNBT(@Nonnull NBTTagCompound var1) {}
protected void writeAdditional(@Nonnull NBTTagCompound var1) {}
@Override
@Optional.Method(modid="albedo")
@@ -11,6 +11,7 @@
package vazkii.botania.common.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.nbt.NBTTagCompound;
@@ -20,6 +21,7 @@ import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.handler.ModSounds;
@@ -27,25 +29,28 @@ import javax.annotation.Nonnull;
import elucent.albedo.lighting.ILightProvider;
import elucent.albedo.lighting.Light;
import vazkii.botania.common.lib.LibMisc;
import java.util.List;
@Optional.Interface(iface="elucent.albedo.lighting.ILightProvider", modid="albedo")
public class EntityMagicLandmine extends Entity implements ILightProvider {
@ObjectHolder(LibMisc.MOD_ID + ":magic_landmine")
public static EntityType<?> TYPE;
public EntityDoppleganger summoner;
public EntityMagicLandmine(World world) {
super(world);
super(TYPE, world);
setSize(0F, 0F);
}
@Override
public void onUpdate() {
public void tick() {
motionX = 0;
motionY = 0;
motionZ = 0;
super.onUpdate();
super.tick();
float range = 2.5F;
@@ -76,20 +81,20 @@ public class EntityMagicLandmine extends Entity implements ILightProvider {
}
}
setDead();
remove();
}
}
@Override
protected void entityInit() {
protected void registerData() {
}
@Override
protected void readEntityFromNBT(@Nonnull NBTTagCompound var1) {
protected void readAdditional(@Nonnull NBTTagCompound var1) {
}
@Override
protected void writeEntityToNBT(@Nonnull NBTTagCompound var1) {
protected void writeAdditional(@Nonnull NBTTagCompound var1) {
}
@Override
@@ -16,6 +16,7 @@ import net.minecraft.block.BlockBush;
import net.minecraft.block.BlockLeaves;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityThrowable;
@@ -28,14 +29,18 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.Botania;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.lib.LibMisc;
import vazkii.botania.common.lib.LibObfuscation;
import javax.annotation.Nonnull;
import java.util.List;
public class EntityMagicMissile extends EntityThrowable {
@ObjectHolder(LibMisc.MOD_ID + ":magic_missile")
public static EntityType<?> TYPE;
private static final String TAG_TIME = "time";
private static final DataParameter<Boolean> EVIL = EntityDataManager.createKey(EntityMagicMissile.class, DataSerializers.BOOLEAN);
@@ -45,18 +50,18 @@ public class EntityMagicMissile extends EntityThrowable {
int time = 0;
public EntityMagicMissile(World world) {
super(world);
super(TYPE, world);
setSize(0F, 0F);
}
public EntityMagicMissile(EntityLivingBase thrower, boolean evil) {
super(thrower.world, thrower);
super(TYPE, thrower, thrower.world);
setSize(0F, 0F);
setEvil(evil);
}
@Override
protected void entityInit() {
protected void registerData() {
dataManager.register(EVIL, false);
dataManager.register(TARGET, 0);
}
@@ -83,15 +88,15 @@ public class EntityMagicMissile extends EntityThrowable {
}
@Override
public void onUpdate() {
public void tick() {
double lastTickPosX = this.lastTickPosX;
double lastTickPosY = this.lastTickPosY;
double lastTickPosZ = this.lastTickPosZ;
super.onUpdate();
super.tick();
if(!world.isRemote && (!findTarget() || time > 40)) {
setDead();
remove();
return;
}
@@ -138,32 +143,32 @@ public class EntityMagicMissile extends EntityThrowable {
target.attackEntityFrom(player == null ? DamageSource.causeMobDamage(thrower) : DamageSource.causePlayerDamage(player), evil ? 12 : 7);
} else target.attackEntityFrom(DamageSource.GENERIC, evil ? 12 : 7);
setDead();
remove();
}
if(evil && diffVec.mag() < 1)
setDead();
remove();
}
time++;
}
@Override
public void writeEntityToNBT(NBTTagCompound cmp) {
super.writeEntityToNBT(cmp);
cmp.setInteger(TAG_TIME, time);
public void writeAdditional(NBTTagCompound cmp) {
super.writeAdditional(cmp);
cmp.setInt(TAG_TIME, time);
}
@Override
public void readEntityFromNBT(NBTTagCompound cmp) {
super.readEntityFromNBT(cmp);
time = cmp.getInteger(TAG_TIME);
public void readAdditional(NBTTagCompound cmp) {
super.readAdditional(cmp);
time = cmp.getInt(TAG_TIME);
}
public boolean findTarget() {
EntityLivingBase target = getTargetEntity();
if(target != null && target.getHealth() > 0 && !target.isDead && world.loadedEntityList.contains(target))
if(target != null && target.getHealth() > 0 && !target.removed && world.loadedEntityList.contains(target))
return true;
if(target != null)
setTarget(null);
@@ -178,7 +183,7 @@ public class EntityMagicMissile extends EntityThrowable {
}
while(entities.size() > 0) {
Entity e = (Entity) entities.get(world.rand.nextInt(entities.size()));
if(!(e instanceof EntityLivingBase) || e.isDead) { // Just in case...
if(!(e instanceof EntityLivingBase) || e.removed) { // Just in case...
entities.remove(e);
continue;
}
@@ -193,20 +198,20 @@ public class EntityMagicMissile extends EntityThrowable {
@Override
protected void onImpact(@Nonnull RayTraceResult pos) {
switch (pos.typeOfHit) {
switch (pos.type) {
case BLOCK: {
Block block = world.getBlockState(pos.getBlockPos()).getBlock();
if(!(block instanceof BlockBush) && !(block instanceof BlockLeaves))
setDead();
remove();
break;
}
case ENTITY: {
if (pos.entityHit == getTargetEntity())
setDead();
if (pos.entity == getTargetEntity())
remove();
break;
}
default: {
setDead();
remove();
break;
}
}
@@ -11,16 +11,21 @@
package vazkii.botania.common.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.lens.ItemLens;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class EntityManaStorm extends Entity {
@ObjectHolder(LibMisc.MOD_ID + ":mana_storm")
public static EntityType<?> TYPE;
private static final String TAG_TIME = "time";
private static final String TAG_BURSTS_FIRED = "burstsFired";
@@ -34,15 +39,15 @@ public class EntityManaStorm extends Entity {
public int deathTime;
public EntityManaStorm(World world) {
super(world);
super(TYPE, world);
}
@Override
protected void entityInit() {}
protected void registerData() {}
@Override
public void onUpdate() {
super.onUpdate();
public void tick() {
super.tick();
liveTime++;
int diffTime = Math.max(1, 30 - (int) (liveTime / 45f));
@@ -55,7 +60,7 @@ public class EntityManaStorm extends Entity {
if(burstsFired >= TOTAL_BURSTS) {
deathTime++;
if(deathTime >= DEATH_TIME) {
setDead();
remove();
world.newExplosion(this, posX, posY, posZ, 8F, true, true);
}
}
@@ -81,17 +86,17 @@ public class EntityManaStorm extends Entity {
}
@Override
protected void readEntityFromNBT(@Nonnull NBTTagCompound cmp) {
liveTime = cmp.getInteger(TAG_TIME);
burstsFired = cmp.getInteger(TAG_BURSTS_FIRED);
deathTime = cmp.getInteger(TAG_DEATH_TIME);
protected void readAdditional(@Nonnull NBTTagCompound cmp) {
liveTime = cmp.getInt(TAG_TIME);
burstsFired = cmp.getInt(TAG_BURSTS_FIRED);
deathTime = cmp.getInt(TAG_DEATH_TIME);
}
@Override
protected void writeEntityToNBT(@Nonnull NBTTagCompound cmp) {
cmp.setInteger(TAG_TIME, liveTime);
cmp.setInteger(TAG_BURSTS_FIRED, burstsFired);
cmp.setInteger(TAG_DEATH_TIME, deathTime);
protected void writeAdditional(@Nonnull NBTTagCompound cmp) {
cmp.setInt(TAG_TIME, liveTime);
cmp.setInt(TAG_BURSTS_FIRED, burstsFired);
cmp.setInt(TAG_DEATH_TIME, deathTime);
}
}
@@ -10,20 +10,25 @@
*/
package vazkii.botania.common.entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.EntityAIAttackRanged;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.boss.EntityWither;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Particles;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class EntityPinkWither extends EntityWither {
@ObjectHolder(LibMisc.MOD_ID + ":pink_wither")
public static EntityType<?> TYPE;
public EntityPinkWither(World world) {
super(world);
@@ -34,16 +39,22 @@ public class EntityPinkWither extends EntityWither {
|| entry.action instanceof EntityAINearestAttackableTarget); // Remove revenge and aggro
}
@Nonnull
@Override
public void onLivingUpdate() {
super.onLivingUpdate();
public EntityType<?> getType() {
return TYPE;
}
@Override
public void livingTick() {
super.livingTick();
if(Math.random() < 0.1)
for(int j = 0; j < 3; ++j) {
double d10 = func_82214_u(j);
double d2 = func_82208_v(j);
double d4 = func_82213_w(j);
world.spawnParticle(EnumParticleTypes.HEART, d10 + rand.nextGaussian() * 0.30000001192092896D, d2 + rand.nextGaussian() * 0.30000001192092896D, d4 + rand.nextGaussian() * 0.30000001192092896D, 0.0D, 0.0D, 0.0D);
double d10 = getHeadX(j);
double d2 = getHeadY(j);
double d4 = getHeadZ(j);
world.spawnParticle(Particles.HEART, d10 + rand.nextGaussian() * 0.30000001192092896D, d2 + rand.nextGaussian() * 0.30000001192092896D, d4 + rand.nextGaussian() * 0.30000001192092896D, 0.0D, 0.0D, 0.0D);
}
}
@@ -68,38 +79,29 @@ public class EntityPinkWither extends EntityWither {
@Override
public void addTrackingPlayer(@Nonnull EntityPlayerMP player) {}
// COPYPASTA
// [VanillaCopy] super
private double func_82214_u(int p_82214_1_)
{
if (p_82214_1_ <= 0)
{
return posX;
}
else
{
float f = (renderYawOffset + 180 * (p_82214_1_ - 1)) / 180.0F * (float)Math.PI;
private double getHeadX(int p_82214_1_) {
if (p_82214_1_ <= 0) {
return this.posX;
} else {
float f = (this.renderYawOffset + (float)(180 * (p_82214_1_ - 1))) * ((float)Math.PI / 180F);
float f1 = MathHelper.cos(f);
return posX + f1 * 1.3D;
return this.posX + (double)f1 * 1.3D;
}
}
private double func_82208_v(int p_82208_1_)
{
return p_82208_1_ <= 0 ? posY + 3.0D : posY + 2.2D;
private double getHeadY(int p_82208_1_) {
return p_82208_1_ <= 0 ? this.posY + 3.0D : this.posY + 2.2D;
}
private double func_82213_w(int p_82213_1_)
{
if (p_82213_1_ <= 0)
{
return posZ;
}
else
{
float f = (renderYawOffset + 180 * (p_82213_1_ - 1)) / 180.0F * (float)Math.PI;
private double getHeadZ(int p_82213_1_) {
if (p_82213_1_ <= 0) {
return this.posZ;
} else {
float f = (this.renderYawOffset + (float)(180 * (p_82213_1_ - 1))) * ((float)Math.PI / 180F);
float f1 = MathHelper.sin(f);
return posZ + f1 * 1.3D;
return this.posZ + (double)f1 * 1.3D;
}
}
}
@@ -12,6 +12,7 @@ package vazkii.botania.common.entity;
import net.minecraft.entity.EntityFlying;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.datasync.DataParameter;
@@ -21,52 +22,55 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Optional;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.Botania;
import javax.annotation.Nonnull;
import elucent.albedo.lighting.ILightProvider;
import elucent.albedo.lighting.Light;
import vazkii.botania.common.lib.LibMisc;
@Optional.Interface(iface="elucent.albedo.lighting.ILightProvider", modid="albedo")
public class EntityPixie extends EntityFlying implements ILightProvider {
private static final DataParameter<Integer> TYPE = EntityDataManager.createKey(EntityPixie.class, DataSerializers.VARINT);
@ObjectHolder(LibMisc.MOD_ID + ":pixie")
public static EntityType<?> TYPE;
private static final DataParameter<Integer> PIXIE_TYPE = EntityDataManager.createKey(EntityPixie.class, DataSerializers.VARINT);
private EntityLivingBase summoner = null;
private float damage = 0;
private PotionEffect effect = null;
public EntityPixie(World world) {
super(world);
super(TYPE, world);
setSize(1.0F, 1.0F);
}
@Override
protected void entityInit() {
super.entityInit();
dataManager.register(TYPE, 0);
protected void registerData() {
super.registerData();
dataManager.register(PIXIE_TYPE, 0);
}
@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(2.0);
protected void registerAttributes() {
super.registerAttributes();
getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(2.0);
}
public void setType(int type) {
dataManager.set(TYPE, type);
public void setPixieType(int type) {
dataManager.set(PIXIE_TYPE, type);
}
public int getType() {
return dataManager.get(TYPE);
public int getPixieType() {
return dataManager.get(PIXIE_TYPE);
}
public void setProps(EntityLivingBase target, EntityLivingBase summoner, int type, float damage) {
setAttackTarget(target);
this.summoner = summoner;
this.damage = damage;
setType(type);
setPixieType(type);
}
public void setApplyPotionEffect(PotionEffect effect) {
@@ -83,7 +87,7 @@ public class EntityPixie extends EntityFlying implements ILightProvider {
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
float mod = 0.45F;
if(getType() == 1)
if(getPixieType() == 1)
mod = 0.1F;
motionX += d0 / d3 * mod;
@@ -109,31 +113,31 @@ public class EntityPixie extends EntityFlying implements ILightProvider {
@Override
public boolean attackEntityFrom(@Nonnull DamageSource par1DamageSource, float par2) {
if(getType() == 0 && par1DamageSource.getTrueSource() != summoner || getType() == 1 && par1DamageSource.getTrueSource() instanceof EntityPlayer)
if(getPixieType() == 0 && par1DamageSource.getTrueSource() != summoner || getPixieType() == 1 && par1DamageSource.getTrueSource() instanceof EntityPlayer)
return super.attackEntityFrom(par1DamageSource, par2);
return false;
}
@Override
public void onEntityUpdate() {
super.onEntityUpdate();
public void baseTick() {
super.baseTick();
if(!world.isRemote
&& (getAttackTarget() == null || ticksExisted > 200))
setDead();
boolean dark = getType() == 1;
boolean dark = getPixieType() == 1;
if(world.isRemote)
for(int i = 0; i < 4; i++)
Botania.proxy.sparkleFX(posX + (Math.random() - 0.5) * 0.25, posY + 0.5 + (Math.random() - 0.5) * 0.25, posZ + (Math.random() - 0.5) * 0.25, dark ? 0.1F : 1F, dark ? 0.025F : 0.25F, dark ? 0.09F : 0.9F, 0.1F + (float) Math.random() * 0.25F, 12);
}
@Override
public void setDead() {
if(world != null && world.isRemote && getType() == 0)
public void remove() {
if(world != null && world.isRemote && getPixieType() == 0)
for(int i = 0; i < 12; i++)
Botania.proxy.sparkleFX(posX + (Math.random() - 0.5) * 0.25, posY + 0.5 + (Math.random() - 0.5) * 0.25, posZ + (Math.random() - 0.5) * 0.25, 1F, 0.25F, 0.9F, 1F + (float) Math.random() * 0.25F, 5);
super.setDead();
super.remove();
}
@Override
@@ -149,7 +153,7 @@ public class EntityPixie extends EntityFlying implements ILightProvider {
@Override
@Optional.Method(modid="albedo")
public Light provideLight() {
if(getType() == 1)
if(getPixieType() == 1)
return null;
return Light.builder().pos(this).color(1F, 0F, 0.5F).radius(8).build();
@@ -12,6 +12,7 @@ package vazkii.botania.common.entity;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -26,6 +27,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.api.internal.VanillaPacketDispatcher;
import vazkii.botania.api.mana.IManaPool;
import vazkii.botania.api.state.BotaniaStateProps;
@@ -34,27 +36,29 @@ import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.mana.TilePool;
import vazkii.botania.common.block.tile.mana.TilePump;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.awt.Color;
public class EntityPoolMinecart extends EntityMinecart {
@ObjectHolder(LibMisc.MOD_ID + ":pool_minecart")
public static EntityType<?> TYPE;
private static final int TRANSFER_RATE = 10000;
private static final String TAG_MANA = "mana";
private static final DataParameter<Integer> MANA = EntityDataManager.createKey(EntityPoolMinecart.class, DataSerializers.VARINT);
public EntityPoolMinecart(World world) {
super(world);
super(TYPE, world);
}
public EntityPoolMinecart(World world, double x, double y, double z) {
super(world, x, y, z);
super(TYPE, world, x, y, z);
}
@Override
protected void entityInit() {
super.entityInit();
protected void registerData() {
super.registerData();
dataManager.register(MANA, 0);
}
@@ -72,7 +76,7 @@ public class EntityPoolMinecart extends EntityMinecart {
@Nonnull
@Override
public EntityMinecart.Type getType() {
public EntityMinecart.Type getMinecartType() {
return Type.RIDEABLE;
}
@@ -100,7 +104,7 @@ public class EntityPoolMinecart extends EntityMinecart {
@Override
public void killMinecart(DamageSource source) {
super.killMinecart(source);
dropItemWithOffset(Item.getItemFromBlock(ModBlocks.manaPool), 1, 0.0F);
entityDropItem(ModBlocks.manaPool, 0);
}
@Override
@@ -109,8 +113,8 @@ public class EntityPoolMinecart extends EntityMinecart {
}
@Override
public void onUpdate() {
super.onUpdate();
public void tick() {
super.tick();
if(world.isRemote) {
double particleChance = 1F - (double) getMana() / (double) TilePool.MAX_MANA * 0.1;
@@ -127,7 +131,7 @@ public class EntityPoolMinecart extends EntityMinecart {
public void moveMinecartOnRail(BlockPos pos) {
super.moveMinecartOnRail(pos);
for(EnumFacing dir : EnumFacing.HORIZONTALS) {
for(EnumFacing dir : EnumFacing.BY_HORIZONTAL_INDEX) {
BlockPos posP = pos.offset(dir);
Block block = world.getBlockState(posP).getBlock();
if(block == ModBlocks.pump) {
@@ -138,7 +142,7 @@ public class EntityPoolMinecart extends EntityMinecart {
if(tile != null && tile instanceof IManaPool) {
IManaPool pool = (IManaPool) tile;
EnumFacing pumpDir = world.getBlockState(posP).getValue(BotaniaStateProps.CARDINALS);
EnumFacing pumpDir = world.getBlockState(posP).get(BotaniaStateProps.CARDINALS);
boolean did = false;
boolean can = false;
@@ -188,15 +192,15 @@ public class EntityPoolMinecart extends EntityMinecart {
}
@Override
protected void writeEntityToNBT(@Nonnull NBTTagCompound cmp) {
super.writeEntityToNBT(cmp);
cmp.setInteger(TAG_MANA, getMana());
protected void writeAdditional(@Nonnull NBTTagCompound cmp) {
super.writeAdditional(cmp);
cmp.setInt(TAG_MANA, getMana());
}
@Override
protected void readEntityFromNBT(NBTTagCompound cmp) {
super.readEntityFromNBT(cmp);
setMana(cmp.getInteger(TAG_MANA));
protected void readAdditional(NBTTagCompound cmp) {
super.readAdditional(cmp);
setMana(cmp.getInt(TAG_MANA));
}
@Override
@@ -11,6 +11,7 @@
package vazkii.botania.common.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.nbt.NBTTagCompound;
@@ -18,41 +19,44 @@ import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.world.World;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.Botania;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class EntitySignalFlare extends Entity {
@ObjectHolder(LibMisc.MOD_ID + ":signal_flare")
public static EntityType<?> TYPE;
private static final String COLOR_TAG = "color";
private static final String FIRED_Y_TAG = "firedY";
private static final DataParameter<Integer> COLOR = EntityDataManager.createKey(EntitySignalFlare.class, DataSerializers.VARINT);
private static final DataParameter<Integer> FIRED_Y = EntityDataManager.createKey(EntitySignalFlare.class, DataSerializers.VARINT);
public EntitySignalFlare(World world) {
super(world);
super(TYPE, world);
setSize(0F, 0F);
}
@Override
protected void entityInit() {
protected void registerData() {
dataManager.register(COLOR, 0);
dataManager.register(FIRED_Y, 0);
}
@Override
public void onEntityUpdate() {
super.onEntityUpdate();
public void baseTick() {
super.baseTick();
if(ticksExisted++ >= 100)
setDead();
remove();
if(!isDead) {
if(!removed) {
if(ticksExisted % 10 == 0)
playSound(SoundEvents.ENTITY_CREEPER_PRIMED, 1F, 1F);
int color = getColor();
if(color < 16 && color >= 0) {
int hex = EnumDyeColor.byMetadata(color).colorValue;
int hex = EnumDyeColor.byId(color).colorValue;
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = hex & 0xFF;
@@ -69,15 +73,15 @@ public class EntitySignalFlare extends Entity {
}
@Override
protected void readEntityFromNBT(@Nonnull NBTTagCompound nbttagcompound) {
setColor(nbttagcompound.getInteger(COLOR_TAG));
setFiredAt(nbttagcompound.getInteger(FIRED_Y_TAG));
protected void readAdditional(@Nonnull NBTTagCompound nbttagcompound) {
setColor(nbttagcompound.getInt(COLOR_TAG));
setFiredAt(nbttagcompound.getInt(FIRED_Y_TAG));
}
@Override
protected void writeEntityToNBT(@Nonnull NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger(COLOR_TAG, getColor());
nbttagcompound.setInteger(FIRED_Y_TAG, getFiredAt());
protected void writeAdditional(@Nonnull NBTTagCompound nbttagcompound) {
nbttagcompound.setInt(COLOR_TAG, getColor());
nbttagcompound.setInt(FIRED_Y_TAG, getFiredAt());
}
public void setColor(int color) {
@@ -13,6 +13,7 @@ package vazkii.botania.common.entity;
import baubles.api.BaublesApi;
import gnu.trove.map.hash.TObjectIntHashMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
@@ -27,6 +28,7 @@ import net.minecraft.util.math.MathHelper;
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.mana.IManaItem;
import vazkii.botania.api.mana.IManaPool;
import vazkii.botania.api.mana.spark.ISparkAttachable;
@@ -35,6 +37,7 @@ import vazkii.botania.api.mana.spark.SparkHelper;
import vazkii.botania.api.mana.spark.SparkUpgradeType;
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;
@@ -50,7 +53,8 @@ import java.util.Set;
import java.util.WeakHashMap;
public class EntitySpark extends Entity implements ISparkEntity {
@ObjectHolder(LibMisc.MOD_ID + ":spark")
public static EntityType<?> TYPE;
private static final int TRANSFER_RATE = 1000;
private static final String TAG_UPGRADE = "upgrade";
private static final String TAG_INVIS = "invis";
@@ -61,13 +65,13 @@ public class EntitySpark extends Entity implements ISparkEntity {
private int removeTransferants = 2;
public EntitySpark(World world) {
super(world);
super(TYPE, world);
isImmuneToFire = true;
setSize(0.1F, 0.5F);
}
@Override
protected void entityInit() {
setSize(0.1F, 0.5F);
protected void registerData() {
dataManager.register(UPGRADE, 0);
}
@@ -78,8 +82,8 @@ public class EntitySpark extends Entity implements ISparkEntity {
}
@Override
public void onUpdate() {
super.onUpdate();
public void tick() {
super.tick();
if(world.isRemote)
return;
@@ -101,7 +105,7 @@ public class EntitySpark extends Entity implements ISparkEntity {
case DISPERSIVE : {
List<EntityPlayer> players = SparkHelper.getEntitiesAround(EntityPlayer.class, world, posX, posY + (height / 2.0), posZ);
Map<EntityPlayer, TObjectIntHashMap<ItemStack>> receivingPlayers = new HashMap<>();
Map<EntityPlayer, Map<ItemStack, Integer>> receivingPlayers = new HashMap<>();
ItemStack input = new ItemStack(ModItems.spark);
for(EntityPlayer player : players) {
@@ -119,11 +123,11 @@ public class EntitySpark extends Entity implements ISparkEntity {
IManaItem manaItem = (IManaItem) stack.getItem();
if(manaItem.canReceiveManaFromItem(stack, input)) {
TObjectIntHashMap<ItemStack> receivingStacks;
Map<ItemStack, Integer> receivingStacks;
boolean add = false;
if(!receivingPlayers.containsKey(player)) {
add = true;
receivingStacks = new TObjectIntHashMap<>();
receivingStacks = new HashMap<>();
} else receivingStacks = receivingPlayers.get(player);
int recv = Math.min(getAttachedTile().getCurrentMana(), Math.min(TRANSFER_RATE, manaItem.getMaxMana(stack) - manaItem.getMana(stack)));
@@ -141,7 +145,7 @@ public class EntitySpark extends Entity implements ISparkEntity {
Collections.shuffle(keys);
EntityPlayer player = keys.iterator().next();
TObjectIntHashMap<ItemStack> items = receivingPlayers.get(player);
Map<ItemStack, Integer> items = receivingPlayers.get(player);
ItemStack stack = items.keySet().iterator().next();
int cost = items.get(stack);
int manaToPut = Math.min(getAttachedTile().getCurrentMana(), cost);
@@ -229,7 +233,7 @@ public class EntitySpark extends Entity implements ISparkEntity {
entityDropItem(new ItemStack(ModItems.spark), 0F);
if(upgrade != SparkUpgradeType.NONE)
entityDropItem(ItemSparkUpgrade.getByType(upgrade), 0F);
setDead();
remove();
}
@Override
@@ -240,7 +244,7 @@ public class EntitySpark extends Entity implements ISparkEntity {
@Override
public boolean processInitialInteract(EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(!isDead && !stack.isEmpty()) {
if(!removed && !stack.isEmpty()) {
if(world.isRemote) {
boolean valid = stack.getItem() == ModItems.twigWand || stack.getItem() instanceof ItemSparkUpgrade
|| stack.getItem() == ModItems.phantomInk;
@@ -279,15 +283,15 @@ public class EntitySpark extends Entity implements ISparkEntity {
}
@Override
protected void readEntityFromNBT(@Nonnull NBTTagCompound cmp) {
setUpgrade(SparkUpgradeType.values()[cmp.getInteger(TAG_UPGRADE)]);
setInvisible(cmp.getInteger(TAG_INVIS) == 1);
protected void readAdditional(@Nonnull NBTTagCompound cmp) {
setUpgrade(SparkUpgradeType.values()[cmp.getInt(TAG_UPGRADE)]);
setInvisible(cmp.getInt(TAG_INVIS) == 1);
}
@Override
protected void writeEntityToNBT(@Nonnull NBTTagCompound cmp) {
cmp.setInteger(TAG_UPGRADE, getUpgrade().ordinal());
cmp.setInteger(TAG_INVIS, isInvisible() ? 1 : 0);
protected void writeAdditional(@Nonnull NBTTagCompound cmp) {
cmp.setInt(TAG_UPGRADE, getUpgrade().ordinal());
cmp.setInt(TAG_INVIS, isInvisible() ? 1 : 0);
}
@Override
@@ -15,10 +15,12 @@ import net.minecraft.block.BlockBush;
import net.minecraft.block.BlockLeaves;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.MobEffects;
import net.minecraft.init.Particles;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
@@ -27,15 +29,18 @@ import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
public class EntityThornChakram extends EntityThrowable {
@ObjectHolder(LibMisc.MOD_ID + ":thorn_chakram")
public static EntityType<?> TYPE;
private static final DataParameter<Integer> BOUNCES = EntityDataManager.createKey(EntityThornChakram.class, DataSerializers.VARINT);
private static final DataParameter<Boolean> FLARE = EntityDataManager.createKey(EntityThornChakram.class, DataSerializers.BOOLEAN);
@@ -45,17 +50,17 @@ public class EntityThornChakram extends EntityThrowable {
private ItemStack stack = ItemStack.EMPTY;
public EntityThornChakram(World world) {
super(world);
super(TYPE, world);
}
public EntityThornChakram(World world, EntityLivingBase e, ItemStack stack) {
super(world, e);
public EntityThornChakram(EntityLivingBase e, World world, ItemStack stack) {
super(TYPE, e, world);
this.stack = stack.copy();
}
@Override
protected void entityInit() {
super.entityInit();
protected void registerData() {
super.registerData();
dataManager.register(BOUNCES, 0);
dataManager.register(FLARE, false);
dataManager.register(RETURN_TO, -1);
@@ -67,13 +72,13 @@ public class EntityThornChakram extends EntityThrowable {
}
@Override
public void onUpdate() {
public void tick() {
// Standard motion
double mx = motionX;
double my = motionY;
double mz = motionZ;
super.onUpdate();
super.tick();
if(!bounced) {
// Reset the drag applied by super
@@ -100,7 +105,7 @@ public class EntityThornChakram extends EntityThrowable {
double r = 0.1;
double m = 0.1;
for(int i = 0; i < 3; i++)
world.spawnParticle(EnumParticleTypes.FLAME, posX + r * (Math.random() - 0.5), posY + r * (Math.random() - 0.5), posZ + r * (Math.random() - 0.5), m * (Math.random() - 0.5), m * (Math.random() - 0.5), m * (Math.random() - 0.5));
world.spawnParticle(Particles.FLAME, posX + r * (Math.random() - 0.5), posY + r * (Math.random() - 0.5), posZ + r * (Math.random() - 0.5), m * (Math.random() - 0.5), m * (Math.random() - 0.5), m * (Math.random() - 0.5));
}
// Server state control
@@ -120,7 +125,7 @@ public class EntityThornChakram extends EntityThrowable {
ItemStack stack = getItemStack();
EntityItem item = new EntityItem(world, posX, posY, posZ, stack);
world.spawnEntity(item);
setDead();
remove();
}
private ItemStack getItemStack() {
@@ -134,7 +139,7 @@ public class EntityThornChakram extends EntityThrowable {
if(isReturning())
return;
switch (pos.typeOfHit) {
switch (pos.type) {
case BLOCK: {
Block block = world.getBlockState(pos.getBlockPos()).getBlock();
if(block instanceof BlockBush || block instanceof BlockLeaves)
@@ -159,13 +164,13 @@ public class EntityThornChakram extends EntityThrowable {
break;
}
case ENTITY: {
if(!world.isRemote && pos.entityHit != null && pos.entityHit instanceof EntityLivingBase && pos.entityHit != getThrower()) {
if(!world.isRemote && pos.entity != null && pos.entity instanceof EntityLivingBase && pos.entity != getThrower()) {
EntityLivingBase thrower = getThrower();
pos.entityHit.attackEntityFrom(thrower != null ? thrower instanceof EntityPlayer ? DamageSource.causeThrownDamage(this, thrower) : DamageSource.causeMobDamage(thrower) : DamageSource.GENERIC, 12);
pos.entity.attackEntityFrom(thrower != null ? thrower instanceof EntityPlayer ? DamageSource.causeThrownDamage(this, thrower) : DamageSource.causeMobDamage(thrower) : DamageSource.GENERIC, 12);
if(isFire())
pos.entityHit.setFire(5);
pos.entity.setFire(5);
else if(world.rand.nextInt(3) == 0)
((EntityLivingBase) pos.entityHit).addPotionEffect(new PotionEffect(MobEffects.POISON, 60, 0));
((EntityLivingBase) pos.entity).addPotionEffect(new PotionEffect(MobEffects.POISON, 60, 0));
}
break;
@@ -208,19 +213,19 @@ public class EntityThornChakram extends EntityThrowable {
}
@Override
public void writeEntityToNBT(NBTTagCompound compound) {
super.writeEntityToNBT(compound);
public void writeAdditional(NBTTagCompound compound) {
super.writeAdditional(compound);
if(!stack.isEmpty()) {
compound.setTag("fly_stack", stack.writeToNBT(new NBTTagCompound()));
compound.setTag("fly_stack", stack.write(new NBTTagCompound()));
}
compound.setBoolean("flare", isFire());
}
@Override
public void readEntityFromNBT(NBTTagCompound compound) {
super.readEntityFromNBT(compound);
public void readAdditional(NBTTagCompound compound) {
super.readAdditional(compound);
if(compound.hasKey("fly_stack")) {
stack = new ItemStack(compound.getCompoundTag("fly_stack"));
stack = ItemStack.read(compound.getCompound("fly_stack"));
}
setFire(compound.getBoolean("flare"));
}
@@ -3,80 +3,64 @@ package vazkii.botania.common.entity;
import java.util.List;
import java.util.UUID;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Particles;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.datafix.DataFixer;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
// A copy of the vanilla EntityThrowable class
// Doing this because if I didn't do this it'd be an EntityThrowable
// And we all know how much mods like deflecting EntityThrowables
public abstract class EntityThrowableCopy extends Entity implements IProjectile
{
public abstract class EntityThrowableCopy extends Entity implements IProjectile {
private int xTile;
private int yTile;
private int zTile;
private Block inTile;
protected boolean inGround;
public int throwableShake;
/** The entity that threw this throwable item. */
protected EntityLivingBase thrower;
private String throwerName;
private int ticksInGround;
private int ticksInAir;
private UUID field_200218_h;
public Entity ignoreEntity;
private int ignoreTime;
public EntityThrowableCopy(World worldIn)
{
super(worldIn);
protected EntityThrowableCopy(EntityType<?> type, World p_i48540_2_) {
super(type, p_i48540_2_);
this.xTile = -1;
this.yTile = -1;
this.zTile = -1;
this.setSize(0.25F, 0.25F);
}
public EntityThrowableCopy(World worldIn, double x, double y, double z)
{
this(worldIn);
this.setPosition(x, y, z);
protected EntityThrowableCopy(EntityType<?> type, double p_i48541_2_, double p_i48541_4_, double p_i48541_6_, World p_i48541_8_) {
this(type, p_i48541_8_);
this.setPosition(p_i48541_2_, p_i48541_4_, p_i48541_6_);
}
public EntityThrowableCopy(World worldIn, EntityLivingBase throwerIn)
{
this(worldIn, throwerIn.posX, throwerIn.posY + (double)throwerIn.getEyeHeight() - 0.10000000149011612D, throwerIn.posZ);
this.thrower = throwerIn;
protected EntityThrowableCopy(EntityType<?> type, EntityLivingBase p_i48542_2_, World p_i48542_3_) {
this(type, p_i48542_2_.posX, p_i48542_2_.posY + (double)p_i48542_2_.getEyeHeight() - (double)0.1F, p_i48542_2_.posZ, p_i48542_3_);
this.thrower = p_i48542_2_;
this.field_200218_h = p_i48542_2_.getUniqueID();
}
protected void entityInit()
{
protected void registerData() {
}
/**
* Checks if the entity is in range to render.
*/
@SideOnly(Side.CLIENT)
public boolean isInRangeToRenderDist(double distance)
{
double d0 = this.getEntityBoundingBox().getAverageEdgeLength() * 4.0D;
if (Double.isNaN(d0))
{
@OnlyIn(Dist.CLIENT)
public boolean isInRangeToRenderDist(double distance) {
double d0 = this.getBoundingBox().getAverageEdgeLength() * 4.0D;
if (Double.isNaN(d0)) {
d0 = 4.0D;
}
@@ -87,33 +71,30 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
/**
* Sets throwable heading based on an entity that's throwing it
*/
public void shoot(Entity entityThrower, float rotationPitchIn, float rotationYawIn, float pitchOffset, float velocity, float inaccuracy)
{
float f = -MathHelper.sin(rotationYawIn * 0.017453292F) * MathHelper.cos(rotationPitchIn * 0.017453292F);
float f1 = -MathHelper.sin((rotationPitchIn + pitchOffset) * 0.017453292F);
float f2 = MathHelper.cos(rotationYawIn * 0.017453292F) * MathHelper.cos(rotationPitchIn * 0.017453292F);
public void shoot(Entity entityThrower, float rotationPitchIn, float rotationYawIn, float pitchOffset, float velocity, float inaccuracy) {
float f = -MathHelper.sin(rotationYawIn * ((float)Math.PI / 180F)) * MathHelper.cos(rotationPitchIn * ((float)Math.PI / 180F));
float f1 = -MathHelper.sin((rotationPitchIn + pitchOffset) * ((float)Math.PI / 180F));
float f2 = MathHelper.cos(rotationYawIn * ((float)Math.PI / 180F)) * MathHelper.cos(rotationPitchIn * ((float)Math.PI / 180F));
this.shoot((double)f, (double)f1, (double)f2, velocity, inaccuracy);
this.motionX += entityThrower.motionX;
this.motionZ += entityThrower.motionZ;
if (!entityThrower.onGround)
{
if (!entityThrower.onGround) {
this.motionY += entityThrower.motionY;
}
}
/**
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
*/
public void shoot(double x, double y, double z, float velocity, float inaccuracy)
{
public void shoot(double x, double y, double z, float velocity, float inaccuracy) {
float f = MathHelper.sqrt(x * x + y * y + z * z);
x = x / (double)f;
y = y / (double)f;
z = z / (double)f;
x = x + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
y = y + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
z = z + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
x = x + this.rand.nextGaussian() * (double)0.0075F * (double)inaccuracy;
y = y + this.rand.nextGaussian() * (double)0.0075F * (double)inaccuracy;
z = z + this.rand.nextGaussian() * (double)0.0075F * (double)inaccuracy;
x = x * (double)velocity;
y = y * (double)velocity;
z = z * (double)velocity;
@@ -121,72 +102,47 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
this.motionY = y;
this.motionZ = z;
float f1 = MathHelper.sqrt(x * x + z * z);
this.rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI));
this.rotationPitch = (float)(MathHelper.atan2(y, (double)f1) * (180D / Math.PI));
this.rotationYaw = (float)(MathHelper.atan2(x, z) * (double)(180F / (float)Math.PI));
this.rotationPitch = (float)(MathHelper.atan2(y, (double)f1) * (double)(180F / (float)Math.PI));
this.prevRotationYaw = this.rotationYaw;
this.prevRotationPitch = this.rotationPitch;
this.ticksInGround = 0;
}
/**
* Updates the entity motion clientside, called by packets from the server
*/
@SideOnly(Side.CLIENT)
public void setVelocity(double x, double y, double z)
{
@OnlyIn(Dist.CLIENT)
public void setVelocity(double x, double y, double z) {
this.motionX = x;
this.motionY = y;
this.motionZ = z;
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
{
if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt(x * x + z * z);
this.rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI));
this.rotationPitch = (float)(MathHelper.atan2(y, (double)f) * (180D / Math.PI));
this.rotationYaw = (float)(MathHelper.atan2(x, z) * (double)(180F / (float)Math.PI));
this.rotationPitch = (float)(MathHelper.atan2(y, (double)f) * (double)(180F / (float)Math.PI));
this.prevRotationYaw = this.rotationYaw;
this.prevRotationPitch = this.rotationPitch;
}
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
public void tick() {
this.lastTickPosX = this.posX;
this.lastTickPosY = this.posY;
this.lastTickPosZ = this.posZ;
super.onUpdate();
if (this.throwableShake > 0)
{
super.tick();
if (this.throwableShake > 0) {
--this.throwableShake;
}
if (this.inGround)
{
if (this.world.getBlockState(new BlockPos(this.xTile, this.yTile, this.zTile)).getBlock() == this.inTile)
{
++this.ticksInGround;
if (this.ticksInGround == 1200)
{
this.setDead();
}
return;
}
if (this.inGround) {
this.inGround = false;
this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
this.ticksInGround = 0;
this.ticksInAir = 0;
}
else
{
++this.ticksInAir;
}
Vec3d vec3d = new Vec3d(this.posX, this.posY, this.posZ);
@@ -194,44 +150,30 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
RayTraceResult raytraceresult = this.world.rayTraceBlocks(vec3d, vec3d1);
vec3d = new Vec3d(this.posX, this.posY, this.posZ);
vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (raytraceresult != null)
{
if (raytraceresult != null) {
vec3d1 = new Vec3d(raytraceresult.hitVec.x, raytraceresult.hitVec.y, raytraceresult.hitVec.z);
}
Entity entity = null;
List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().expand(this.motionX, this.motionY, this.motionZ).grow(1.0D));
List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, this.getBoundingBox().expand(this.motionX, this.motionY, this.motionZ).grow(1.0D));
double d0 = 0.0D;
boolean flag = false;
for (int i = 0; i < list.size(); ++i)
{
for(int i = 0; i < list.size(); ++i) {
Entity entity1 = list.get(i);
if (entity1.canBeCollidedWith())
{
if (entity1 == this.ignoreEntity)
{
if (entity1.canBeCollidedWith()) {
if (entity1 == this.ignoreEntity) {
flag = true;
}
else if (this.thrower != null && this.ticksExisted < 2 && this.ignoreEntity == null)
{
} else if (this.thrower != null && this.ticksExisted < 2 && this.ignoreEntity == null) {
this.ignoreEntity = entity1;
flag = true;
}
else
{
} else {
flag = false;
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(0.30000001192092896D);
AxisAlignedBB axisalignedbb = entity1.getBoundingBox().grow((double)0.3F);
RayTraceResult raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1);
if (raytraceresult1 != null)
{
if (raytraceresult1 != null) {
double d1 = vec3d.squareDistanceTo(raytraceresult1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
if (d1 < d0 || d0 == 0.0D) {
entity = entity1;
d0 = d1;
}
@@ -240,31 +182,22 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
}
}
if (this.ignoreEntity != null)
{
if (flag)
{
if (this.ignoreEntity != null) {
if (flag) {
this.ignoreTime = 2;
}
else if (this.ignoreTime-- <= 0)
{
} else if (this.ignoreTime-- <= 0) {
this.ignoreEntity = null;
}
}
if (entity != null)
{
if (entity != null) {
raytraceresult = new RayTraceResult(entity);
}
if (raytraceresult != null)
{
if (raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK && this.world.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.PORTAL)
{
if (raytraceresult != null) {
if (raytraceresult.type == RayTraceResult.Type.BLOCK && this.world.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.NETHER_PORTAL) {
this.setPortal(raytraceresult.getBlockPos());
}
else if (!net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult))
{
} else if (!net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)){
this.onImpact(raytraceresult);
}
}
@@ -273,25 +206,21 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
this.posY += this.motionY;
this.posZ += this.motionZ;
float f = MathHelper.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float)(MathHelper.atan2(this.motionX, this.motionZ) * (180D / Math.PI));
this.rotationYaw = (float)(MathHelper.atan2(this.motionX, this.motionZ) * (double)(180F / (float)Math.PI));
for (this.rotationPitch = (float)(MathHelper.atan2(this.motionY, (double)f) * (180D / Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
{
for(this.rotationPitch = (float)(MathHelper.atan2(this.motionY, (double)f) * (double)(180F / (float)Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {
;
}
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
{
while(this.rotationPitch - this.prevRotationPitch >= 180.0F) {
this.prevRotationPitch += 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
{
while(this.rotationYaw - this.prevRotationYaw < -180.0F) {
this.prevRotationYaw -= 360.0F;
}
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
{
while(this.rotationYaw - this.prevRotationYaw >= 180.0F) {
this.prevRotationYaw += 360.0F;
}
@@ -299,13 +228,10 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float f1 = 0.99F;
float f2 = this.getGravityVelocity();
if (this.isInWater())
{
for (int j = 0; j < 4; ++j)
{
if (this.isInWater()) {
for(int j = 0; j < 4; ++j) {
float f3 = 0.25F;
this.world.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * 0.25D, this.posY - this.motionY * 0.25D, this.posZ - this.motionZ * 0.25D, this.motionX, this.motionY, this.motionZ);
this.world.spawnParticle(Particles.BUBBLE, this.posX - this.motionX * 0.25D, this.posY - this.motionY * 0.25D, this.posZ - this.motionZ * 0.25D, this.motionX, this.motionY, this.motionZ);
}
f1 = 0.8F;
@@ -314,9 +240,7 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
this.motionX *= (double)f1;
this.motionY *= (double)f1;
this.motionZ *= (double)f1;
if (!this.hasNoGravity())
{
if (!this.hasNoGravity()) {
this.motionY -= (double)f2;
}
@@ -326,8 +250,7 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
/**
* Gets the amount of gravity to apply to the thrown entity with each tick.
*/
protected float getGravityVelocity()
{
protected float getGravityVelocity() {
return 0.03F;
}
@@ -336,84 +259,46 @@ public abstract class EntityThrowableCopy extends Entity implements IProjectile
*/
protected abstract void onImpact(RayTraceResult result);
public static void registerFixesThrowable(DataFixer fixer, String name)
{
}
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
* Writes the extra NBT data specific to this type of entity. Should <em>not</em> be called from outside this class;
* use {@link #writeUnlessPassenger} or {@link #writeWithoutTypeId} instead.
*/
public void writeEntityToNBT(NBTTagCompound compound)
{
compound.setInteger("xTile", this.xTile);
compound.setInteger("yTile", this.yTile);
compound.setInteger("zTile", this.zTile);
ResourceLocation resourcelocation = Block.REGISTRY.getNameForObject(this.inTile);
compound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
public void writeAdditional(NBTTagCompound compound) {
compound.setInt("xTile", this.xTile);
compound.setInt("yTile", this.yTile);
compound.setInt("zTile", this.zTile);
compound.setByte("shake", (byte)this.throwableShake);
compound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
if ((this.throwerName == null || this.throwerName.isEmpty()) && this.thrower instanceof EntityPlayer)
{
this.throwerName = this.thrower.getName();
if (this.field_200218_h != null) {
compound.setTag("owner", NBTUtil.writeUniqueId(this.field_200218_h));
}
compound.setString("ownerName", this.throwerName == null ? "" : this.throwerName);
}
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound compound)
{
this.xTile = compound.getInteger("xTile");
this.yTile = compound.getInteger("yTile");
this.zTile = compound.getInteger("zTile");
if (compound.hasKey("inTile", 8))
{
this.inTile = Block.getBlockFromName(compound.getString("inTile"));
}
else
{
this.inTile = Block.getBlockById(compound.getByte("inTile") & 255);
}
public void readAdditional(NBTTagCompound compound) {
this.xTile = compound.getInt("xTile");
this.yTile = compound.getInt("yTile");
this.zTile = compound.getInt("zTile");
this.throwableShake = compound.getByte("shake") & 255;
this.inGround = compound.getByte("inGround") == 1;
this.thrower = null;
this.throwerName = compound.getString("ownerName");
if (this.throwerName != null && this.throwerName.isEmpty())
{
this.throwerName = null;
if (compound.contains("owner", 10)) {
this.field_200218_h = NBTUtil.readUniqueId(compound.getCompound("owner"));
}
this.thrower = this.getThrower();
}
@Nullable
public EntityLivingBase getThrower()
{
if (this.thrower == null && this.throwerName != null && !this.throwerName.isEmpty())
{
this.thrower = this.world.getPlayerEntityByName(this.throwerName);
if (this.thrower == null && this.world instanceof WorldServer)
{
try
{
Entity entity = ((WorldServer)this.world).getEntityFromUuid(UUID.fromString(this.throwerName));
if (entity instanceof EntityLivingBase)
{
this.thrower = (EntityLivingBase)entity;
}
}
catch (Throwable var2)
{
this.thrower = null;
}
public EntityLivingBase getThrower() {
if (this.thrower == null && this.field_200218_h != null && this.world instanceof WorldServer) {
Entity entity = ((WorldServer)this.world).getEntityFromUuid(this.field_200218_h);
if (entity instanceof EntityLivingBase) {
this.thrower = (EntityLivingBase)entity;
} else {
this.field_200218_h = null;
}
}
@@ -11,6 +11,7 @@
package vazkii.botania.common.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@@ -19,15 +20,20 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.util.List;
public class EntityThrownItem extends EntityItem {
@ObjectHolder(LibMisc.MOD_ID + ":thrown_item")
public static EntityType<?> TYPE;
public EntityThrownItem(World world) {
super(world);
setInvulnerable(true);
}
public EntityThrownItem(World world, double x,
@@ -37,16 +43,18 @@ public class EntityThrownItem extends EntityItem {
motionX = item.motionX;
motionY = item.motionY;
motionZ = item.motionZ;
setInvulnerable(true);
}
@Nonnull
@Override
public EntityType<?> getType() {
return TYPE;
}
@Override
public boolean isEntityInvulnerable(@Nonnull DamageSource source) {
return true;
}
@Override
public void onUpdate() {
super.onUpdate();
public void tick() {
super.tick();
Vec3d vec3 = new Vec3d(posX, posY, posZ);
Vec3d vec31 = new Vec3d(posX + motionX, posY + motionY, posZ + motionZ);
@@ -56,13 +64,13 @@ public class EntityThrownItem extends EntityItem {
if (!world.isRemote)
{
Entity entity = null;
List<Entity> list = world.getEntitiesWithinAABBExcludingEntity(this, getEntityBoundingBox().offset(motionX*2, motionY*2, motionZ*2).grow(2));
List<Entity> list = world.getEntitiesWithinAABBExcludingEntity(this, getBoundingBox().offset(motionX*2, motionY*2, motionZ*2).grow(2));
double d0 = 0.0D;
for (Entity entity1 : list) {
if (entity1.canBeCollidedWith() && (!(entity1 instanceof EntityPlayer) || pickupDelay == 0)) {
float f = 1.0F;
AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(f);
AxisAlignedBB axisalignedbb = entity1.getBoundingBox().grow(f);
RayTraceResult RayTraceResult1 = axisalignedbb.calculateIntercept(vec3, vec31);
if (RayTraceResult1 != null) {
@@ -84,14 +92,14 @@ public class EntityThrownItem extends EntityItem {
if (RayTraceResult != null)
{
if (RayTraceResult.typeOfHit == net.minecraft.util.math.RayTraceResult.Type.BLOCK && world.getBlockState(RayTraceResult.getBlockPos()).getBlock() == Blocks.PORTAL)
if (RayTraceResult.type == net.minecraft.util.math.RayTraceResult.Type.BLOCK && world.getBlockState(RayTraceResult.getBlockPos()).getBlock() == Blocks.NETHER_PORTAL)
{
setPortal(RayTraceResult.getBlockPos());
}
else
{
if (RayTraceResult.entityHit != null) {
RayTraceResult.entityHit.attackEntityFrom(DamageSource.MAGIC, 2.0F);
if (RayTraceResult.type != null) {
RayTraceResult.entity.attackEntityFrom(DamageSource.MAGIC, 2.0F);
if (!world.isRemote) {
Entity item = getItem().getItem().createEntity(world, this, getItem());
if (item == null) {
@@ -109,7 +117,7 @@ public class EntityThrownItem extends EntityItem {
item.motionZ = motionZ*0.25F;
}
}
setDead();
remove();
}
}
@@ -133,7 +141,7 @@ public class EntityThrownItem extends EntityItem {
item.motionZ = motionZ;
}
}
setDead();
remove();
}
}
}
@@ -13,54 +13,60 @@ package vazkii.botania.common.entity;
import com.google.common.collect.ImmutableMap;
import net.minecraft.block.Block;
import net.minecraft.block.BlockVine;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.item.Item;
import net.minecraft.init.Particles;
import net.minecraft.item.ItemStack;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.particles.ItemParticleData;
import net.minecraft.state.BooleanProperty;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
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 net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.util.Map;
public class EntityVineBall extends EntityThrowable {
@ObjectHolder(LibMisc.MOD_ID + ":vine_ball")
public static EntityType<?> TYPE;
private static final DataParameter<Float> GRAVITY = EntityDataManager.createKey(EntityVineBall.class, DataSerializers.FLOAT);
private static final Map<EnumFacing, PropertyBool> propMap = ImmutableMap.of(EnumFacing.NORTH, BlockVine.NORTH, EnumFacing.SOUTH, BlockVine.SOUTH,
private static final Map<EnumFacing, BooleanProperty> propMap = ImmutableMap.of(EnumFacing.NORTH, BlockVine.NORTH, EnumFacing.SOUTH, BlockVine.SOUTH,
EnumFacing.WEST, BlockVine.WEST, EnumFacing.EAST, BlockVine.EAST);
public EntityVineBall(World world) {
super(world);
super(TYPE, world);
}
public EntityVineBall(EntityLivingBase thrower, boolean gravity) {
super(thrower.world, thrower);
super(TYPE, thrower, thrower.world);
dataManager.set(GRAVITY, gravity ? 0.03F : 0F);
}
@Override
protected void entityInit() {
super.entityInit();
protected void registerData() {
super.registerData();
dataManager.register(GRAVITY, 0F);
}
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
@Override
public void handleStatusUpdate(byte id) {
if(id == 3) {
for(int j = 0; j < 16; j++) {
world.spawnParticle(EnumParticleTypes.ITEM_CRACK, posX, posY, posZ, Math.random() * 0.2 - 0.1, Math.random() * 0.25, Math.random() * 0.2 - 0.1, Item.getIdFromItem(ModItems.vineBall));
world.spawnParticle(new ItemParticleData(Particles.ITEM, new ItemStack(ModItems.vineBall)), posX, posY, posZ, Math.random() * 0.2 - 0.1, Math.random() * 0.25, Math.random() * 0.2 - 0.1);
}
}
}
@@ -77,7 +83,7 @@ public class EntityVineBall extends EntityThrowable {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if(block.isAir(state, world, pos)) {
IBlockState stateSet = ModBlocks.solidVines.getDefaultState().withProperty(propMap.get(dir.getOpposite()), true);
IBlockState stateSet = ModBlocks.solidVines.getDefaultState().with(propMap.get(dir.getOpposite()), true);
world.setBlockState(pos, stateSet, 1 | 2);
world.playEvent(2001, pos, Block.getStateId(stateSet));
pos = pos.down();
@@ -88,7 +94,7 @@ public class EntityVineBall extends EntityThrowable {
}
this.world.setEntityState(this, (byte)3);
setDead();
remove();
}
}
@@ -37,7 +37,7 @@ public class ItemThornChakram extends ItemMod {
if(!world.isRemote) {
ItemStack copy = stack.copy();
copy.setCount(1);
EntityThornChakram c = new EntityThornChakram(world, player, copy);
EntityThornChakram c = new EntityThornChakram(player, world, copy);
c.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
if(stack.getItem() == ModItems.flareChakram)
c.setFire(true);
@@ -52,7 +52,7 @@ public class ItemStarSword extends ItemManasteelSword {
posVec = posVec.add(motVec);
motVec = motVec.normalize().negate().multiply(1.5);
EntityFallingStar star = new EntityFallingStar(world, player);
EntityFallingStar star = new EntityFallingStar(player, world);
star.setPosition(posVec.x, posVec.y, posVec.z);
star.motionX = motVec.x;
star.motionY = motVec.y;
@@ -62,7 +62,7 @@ public class ItemStarSword extends ItemManasteelSword {
if (!world.isRaining()
&& Math.abs(world.getWorldTime() - 18000) < 1800
&& Math.random() < 0.125) {
EntityFallingStar bonusStar = new EntityFallingStar(world, player);
EntityFallingStar bonusStar = new EntityFallingStar(player, world);
bonusStar.setPosition(posVec.x, posVec.y, posVec.z);
bonusStar.motionX = motVec.x + Math.random() - 0.5;
bonusStar.motionY = motVec.y + Math.random() - 0.5;
@@ -95,7 +95,7 @@ public class ItemManaResource extends ItemMod implements IFlowerComponent, IElve
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if(!world.isRemote) {
EntityEnderAirBottle b = new EntityEnderAirBottle(world, player);
EntityEnderAirBottle b = new EntityEnderAirBottle(player, world);
b.shoot(player, player.rotationPitch, player.rotationYaw, 0F, 1.5F, 1F);
world.spawnEntity(b);
}
@@ -90,7 +90,7 @@ public class ItemKingKey extends ItemRelic implements IManaUsingItem {
Vector3 end = pl.add(axis1);
EntityBabylonWeapon weapon = new EntityBabylonWeapon(living.world, living);
EntityBabylonWeapon weapon = new EntityBabylonWeapon(living, living.world);
weapon.posX = end.x;
weapon.posY = end.y;
weapon.posZ = end.z;