mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 11:49:37 +00:00
Added the Starcaller.
This commit is contained in:
1 parent
148926490d
commit
fb8e92677d
11 files changed
+192
-1
No files matched your search
@@ -124,7 +124,7 @@ public class EntityBabylonWeapon extends EntityThrowableCopy {
|
||||
AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ).expand(2, 2, 2);
|
||||
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis);
|
||||
for(EntityLivingBase living : entities) {
|
||||
if(living != thrower)
|
||||
if(living == thrower)
|
||||
continue;
|
||||
|
||||
if(living.hurtTime == 0) {
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Aug 17, 2015, 4:19:52 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.entity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
|
||||
public class EntityFallingStar extends EntityThrowableCopy {
|
||||
|
||||
public EntityFallingStar(World world) {
|
||||
super(world);
|
||||
setSize(0F, 0F);
|
||||
}
|
||||
|
||||
public EntityFallingStar(World world, EntityLivingBase e) {
|
||||
super(world, e);
|
||||
setSize(0F, 0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
|
||||
float dist = 1.5F;
|
||||
for(int i = 0; i < 10; i++) {
|
||||
float xs = (float) (Math.random() - 0.5) * dist;
|
||||
float ys = (float) (Math.random() - 0.5) * dist;
|
||||
float zs = (float) (Math.random() - 0.5) * dist;
|
||||
Botania.proxy.sparkleFX(worldObj, posX + xs, posY + ys, posZ + zs, 1F, 0.4F, 1F, 2F, 6);
|
||||
}
|
||||
|
||||
EntityLivingBase thrower = getThrower();
|
||||
if(!worldObj.isRemote && thrower != null) {
|
||||
AxisAlignedBB axis = AxisAlignedBB.getBoundingBox(posX, posY, posZ, lastTickPosX, lastTickPosY, lastTickPosZ).expand(2, 2, 2);
|
||||
List<EntityLivingBase> entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axis);
|
||||
for(EntityLivingBase living : entities) {
|
||||
if(living == thrower)
|
||||
continue;
|
||||
|
||||
if(living.hurtTime == 0) {
|
||||
onImpact(new MovingObjectPosition(living));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(ticksExisted > 200)
|
||||
setDead();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(MovingObjectPosition pos) {
|
||||
EntityLivingBase thrower = getThrower();
|
||||
if(pos.entityHit != null && thrower != null && pos.entityHit != thrower && !pos.entityHit.isDead) {
|
||||
if(thrower instanceof EntityPlayer)
|
||||
pos.entityHit.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) thrower), 7);
|
||||
else pos.entityHit.attackEntityFrom(DamageSource.generic, 7);
|
||||
}
|
||||
|
||||
Block block = worldObj.getBlock(pos.blockX, pos.blockY, pos.blockZ);
|
||||
if(ConfigHandler.blockBreakParticles && !block.isAir(worldObj, pos.blockX, pos.blockY, pos.blockZ))
|
||||
worldObj.playAuxSFX(2001, pos.blockX, pos.blockY, pos.blockZ, Block.getIdFromBlock(block) + (worldObj.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) << 12));
|
||||
|
||||
setDead();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public final class ModEntities {
|
||||
EntityRegistry.registerModEntity(EntityPlayerMover.class, LibEntityNames.PLAYER_MOVER, id++, Botania.instance, 40, 3, true);
|
||||
EntityRegistry.registerModEntity(EntityManaStorm.class, LibEntityNames.MANA_STORM, id++, Botania.instance, 64, 10, false);
|
||||
EntityRegistry.registerModEntity(EntityBabylonWeapon.class, LibEntityNames.BABYLON_WEAPON, id++, Botania.instance, 64, 10, true);
|
||||
EntityRegistry.registerModEntity(EntityFallingStar.class, LibEntityNames.FALLING_STAR, id++, Botania.instance, 64, 10, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -59,6 +59,7 @@ import vazkii.botania.common.item.equipment.bauble.ItemUnholyCloak;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemWaterRing;
|
||||
import vazkii.botania.common.item.equipment.tool.ItemEnderDagger;
|
||||
import vazkii.botania.common.item.equipment.tool.ItemGlassPick;
|
||||
import vazkii.botania.common.item.equipment.tool.ItemStarSword;
|
||||
import vazkii.botania.common.item.equipment.tool.bow.ItemCrystalBow;
|
||||
import vazkii.botania.common.item.equipment.tool.bow.ItemLivingwoodBow;
|
||||
import vazkii.botania.common.item.equipment.tool.elementium.ItemElementiumAxe;
|
||||
@@ -247,6 +248,7 @@ public final class ModItems {
|
||||
public static Item obedienceStick;
|
||||
public static Item cacophonium;
|
||||
public static Item slimeBottle;
|
||||
public static Item starSword;
|
||||
|
||||
public static void init() {
|
||||
lexicon = new ItemLexicon();
|
||||
@@ -384,6 +386,7 @@ public final class ModItems {
|
||||
obedienceStick = new ItemObedienceStick();
|
||||
cacophonium = new ItemCacophonium();
|
||||
slimeBottle = new ItemSlimeBottle();
|
||||
starSword = new ItemStarSword();
|
||||
|
||||
OreDictionary.registerOre(LibOreDict.LEXICON, lexicon);
|
||||
for(int i = 0; i < 16; i++) {
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Aug 17, 2015, 3:55:52 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.item.equipment.tool;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.internal.IManaBurst;
|
||||
import vazkii.botania.api.mana.BurstProperties;
|
||||
import vazkii.botania.common.achievement.ICraftAchievement;
|
||||
import vazkii.botania.common.achievement.ModAchievements;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.entity.EntityFallingStar;
|
||||
import vazkii.botania.common.entity.EntityManaBurst;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.equipment.tool.manasteel.ItemManasteelSword;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemStarSword extends ItemManasteelSword implements ICraftAchievement {
|
||||
|
||||
private static final String TAG_ATTACKER_USERNAME = "attackerUsername";
|
||||
|
||||
private static final int MANA_PER_DAMAGE = 120;
|
||||
|
||||
public ItemStarSword() {
|
||||
super(BotaniaAPI.terrasteelToolMaterial, LibItemNames.STAR_SWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
|
||||
super.onUpdate(par1ItemStack, par2World, par3Entity, par4, par5);
|
||||
if(par3Entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) par3Entity;
|
||||
PotionEffect haste = player.getActivePotionEffect(Potion.digSpeed);
|
||||
float check = haste == null ? 0.16666667F : haste.getAmplifier() == 1 ? 0.5F : 0.4F;
|
||||
|
||||
if(player.getCurrentEquippedItem() == par1ItemStack && player.swingProgress == check && !par2World.isRemote && par2World.rand.nextInt(2) == 0) {
|
||||
MovingObjectPosition pos = ToolCommons.raytraceFromEntity(par2World, par3Entity, true, 48);
|
||||
if(pos != null) {
|
||||
Vector3 posVec = new Vector3(pos.blockX, pos.blockY, pos.blockZ);
|
||||
Vector3 motVec = new Vector3((Math.random() - 0.5) * 18, 24, (Math.random() - 0.5) * 18);
|
||||
posVec.add(motVec);
|
||||
motVec.normalize().negate().multiply(1.5);
|
||||
|
||||
EntityFallingStar star = new EntityFallingStar(par2World, player);
|
||||
star.setPosition(posVec.x, posVec.y, posVec.z);
|
||||
star.motionX = motVec.x;
|
||||
star.motionY = motVec.y;
|
||||
star.motionZ = motVec.z;
|
||||
par2World.spawnEntityInWorld(star);
|
||||
|
||||
ToolCommons.damageItem(par1ItemStack, 1, player, MANA_PER_DAMAGE);
|
||||
par2World.playSoundAtEntity(player, "botania:starcaller", 0.4F, 1.4F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getManaPerDamage() {
|
||||
return MANA_PER_DAMAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) {
|
||||
return par2ItemStack.getItem() == ModItems.manaResource && par2ItemStack.getItemDamage() == 4 ? true : super.getIsRepairable(par1ItemStack, par2ItemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Achievement getAchievementOnCraft(ItemStack stack, EntityPlayer player, IInventory matrix) {
|
||||
return ModAchievements.terrasteelWeaponCraft;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -32,5 +32,6 @@ public final class LibEntityNames {
|
||||
public static final String PLAYER_MOVER = LibResources.PREFIX_MOD + "playerMover";
|
||||
public static final String MANA_STORM = LibResources.PREFIX_MOD + "manaStorm";
|
||||
public static final String BABYLON_WEAPON = LibResources.PREFIX_MOD + "babylonWeapon";
|
||||
public static final String FALLING_STAR = LibResources.PREFIX_MOD + "fallingStar";
|
||||
|
||||
}
|
||||
@@ -148,6 +148,7 @@ public final class LibItemNames {
|
||||
public static final String OBEDIENCE_STICK = "obedienceStick";
|
||||
public static final String CACOPHONIUM = "cacophonium";
|
||||
public static final String SLIME_BOTTLE = "slimeBottle";
|
||||
public static final String STAR_SWORD = "starSword";
|
||||
|
||||
public static final String[] LENS_NAMES = new String[] {
|
||||
"lensNormal",
|
||||
|
||||
Reference in new issue
Block a user