mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-13 16:54:06 +00:00
Added the Thorn Chakram.
This commit is contained in:
1 parent
39b8e9bb9c
commit
7f1303cc30
10 files changed
+175
-1
No files matched your search
@@ -110,6 +110,7 @@ import vazkii.botania.common.core.version.VersionChecker;
|
||||
import vazkii.botania.common.entity.EntityDoppleganger;
|
||||
import vazkii.botania.common.entity.EntityPixie;
|
||||
import vazkii.botania.common.entity.EntitySpark;
|
||||
import vazkii.botania.common.entity.EntityThornChakram;
|
||||
import vazkii.botania.common.entity.EntityVineBall;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibObfuscation;
|
||||
@@ -207,6 +208,7 @@ public class ClientProxy extends CommonProxy {
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityVineBall.class, new RenderSnowball(ModItems.vineBall));
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityDoppleganger.class, new RenderDoppleganger());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntitySpark.class, new RenderSpark());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityThornChakram.class, new RenderSnowball(ModItems.thornChakram));
|
||||
|
||||
ShaderHelper.initShaders();
|
||||
}
|
||||
|
||||
@@ -166,7 +166,8 @@ public class EntitySpark extends Entity implements ISparkEntity {
|
||||
if(upgrade_ == 0 && spark.getAttachedTile() instanceof IManaPool)
|
||||
validSparks.add(spark);
|
||||
}
|
||||
validSparks.get(worldObj.rand.nextInt(validSparks.size())).registerTransfer(this);
|
||||
if(validSparks.size() > 0)
|
||||
validSparks.get(worldObj.rand.nextInt(validSparks.size())).registerTransfer(this);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* 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 a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Jan 25, 2015, 6:47:35 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.entity;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import vazkii.botania.common.core.helper.MathHelper;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
|
||||
public class EntityThornChakram extends EntityThrowable {
|
||||
|
||||
private static final int MAX_BOUNCES = 8;
|
||||
boolean bounced = false;
|
||||
|
||||
public EntityThornChakram(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityThornChakram(World world, EntityLivingBase e) {
|
||||
super(world, e);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
dataWatcher.addObject(30, 0);
|
||||
dataWatcher.setObjectWatched(30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
double mx = motionX;
|
||||
double my = motionY;
|
||||
double mz = motionZ;
|
||||
|
||||
super.onUpdate();
|
||||
int bounces = getTimesBounced();
|
||||
if(bounces >= MAX_BOUNCES || ticksExisted > 60) {
|
||||
EntityLivingBase thrower = getThrower();
|
||||
noClip = true;
|
||||
if(thrower == null)
|
||||
dropAndKill();
|
||||
else {
|
||||
Vector3 motion = Vector3.fromEntityCenter(thrower).sub(Vector3.fromEntityCenter(this)).normalize();
|
||||
motionX = motion.x;
|
||||
motionY = motion.y;
|
||||
motionZ = motion.z;
|
||||
if(MathHelper.pointDistanceSpace(posX, posY, posZ, thrower.posX, thrower.posY, thrower.posZ) < 1)
|
||||
if(!(thrower instanceof EntityPlayer && (((EntityPlayer) thrower).capabilities.isCreativeMode || ((EntityPlayer) thrower).inventory.addItemStackToInventory(new ItemStack(ModItems.thornChakram)))))
|
||||
dropAndKill();
|
||||
else if(!worldObj.isRemote)
|
||||
setDead();
|
||||
}
|
||||
} else {
|
||||
if(!bounced) {
|
||||
motionX = mx;
|
||||
motionY = my;
|
||||
motionZ = mz;
|
||||
}
|
||||
bounced = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void dropAndKill() {
|
||||
if(!worldObj.isRemote) {
|
||||
ItemStack stack = new ItemStack(ModItems.thornChakram);
|
||||
EntityItem item = new EntityItem(worldObj, posX, posY, posZ, stack);
|
||||
worldObj.spawnEntityInWorld(item);
|
||||
setDead();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(MovingObjectPosition pos) {
|
||||
if(noClip)
|
||||
return;
|
||||
|
||||
EntityLivingBase thrower = getThrower();
|
||||
if(pos.entityHit != null && pos.entityHit instanceof EntityLivingBase && pos.entityHit != thrower)
|
||||
((EntityLivingBase) pos.entityHit).attackEntityFrom(thrower != null ? thrower instanceof EntityPlayer ? DamageSource.causePlayerDamage((EntityPlayer) thrower) : DamageSource.causeMobDamage(thrower) : DamageSource.generic, 6);
|
||||
else {
|
||||
int bounces = getTimesBounced();
|
||||
if(bounces < MAX_BOUNCES) {
|
||||
Vector3 currentMovementVec = new Vector3(motionX, motionY, motionZ);
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(pos.sideHit);
|
||||
Vector3 normalVector = new Vector3(dir.offsetX, dir.offsetY, dir.offsetZ).normalize();
|
||||
Vector3 movementVec = normalVector.multiply(-2 * currentMovementVec.dotProduct(normalVector)).add(currentMovementVec);
|
||||
|
||||
motionX = movementVec.x;
|
||||
motionY = movementVec.y;
|
||||
motionZ = movementVec.z;
|
||||
bounced = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getGravityVelocity() {
|
||||
return 0F;
|
||||
}
|
||||
|
||||
int getTimesBounced() {
|
||||
return dataWatcher.getWatchableObjectInt(30);
|
||||
}
|
||||
|
||||
void setTimesBounced(int times) {
|
||||
dataWatcher.updateObject(30, times);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,6 +30,7 @@ public final class ModEntities {
|
||||
EntityRegistry.registerModEntity(EntitySpark.class, LibEntityNames.SPARK, id++, Botania.instance, 64, 10, false);
|
||||
EntityRegistry.registerModEntity(EntityThrownItem.class, LibEntityNames.THROWN_ITEM, id++, Botania.instance, 64, 20, true);
|
||||
EntityRegistry.registerModEntity(EntityMagicMissile.class, LibEntityNames.MAGIC_MISSILE, id++, Botania.instance, 64, 10, true);
|
||||
EntityRegistry.registerModEntity(EntityThornChakram.class, LibEntityNames.THORN_CHAKRAM, id++, Botania.instance, 64, 10, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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 a
|
||||
* Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License
|
||||
* (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB)
|
||||
*
|
||||
* File Created @ [Jan 25, 2015, 6:42:47 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.item;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.common.entity.EntityThornChakram;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemThornChakram extends ItemMod {
|
||||
|
||||
public ItemThornChakram() {
|
||||
setUnlocalizedName(LibItemNames.THORN_CHAKRAM);
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) {
|
||||
--p_77659_1_.stackSize;
|
||||
|
||||
p_77659_2_.playSoundAtEntity(p_77659_3_, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
if(!p_77659_2_.isRemote)
|
||||
p_77659_2_.spawnEntityInWorld(new EntityThornChakram(p_77659_2_, p_77659_3_));
|
||||
|
||||
return p_77659_1_;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -198,6 +198,7 @@ public final class ModItems {
|
||||
public static Item smeltRod;
|
||||
public static Item worldSeed;
|
||||
public static Item spellCloth;
|
||||
public static Item thornChakram;
|
||||
|
||||
public static void init() {
|
||||
lexicon = new ItemLexicon();
|
||||
@@ -303,6 +304,7 @@ public final class ModItems {
|
||||
smeltRod = new ItemSmeltRod();
|
||||
worldSeed = new ItemWorldSeed();
|
||||
spellCloth = new ItemSpellCloth();
|
||||
thornChakram = new ItemThornChakram();
|
||||
|
||||
OreDictionary.registerOre(LibOreDict.LEXICON, lexicon);
|
||||
for(int i = 0; i < 16; i++) {
|
||||
|
||||
@@ -25,5 +25,6 @@ public final class LibEntityNames {
|
||||
public static final String SPARK = LibResources.PREFIX_MOD + "spark";
|
||||
public static final String THROWN_ITEM = LibResources.PREFIX_MOD + "thrownItem";
|
||||
public static final String MAGIC_MISSILE = LibResources.PREFIX_MOD + "magicMissile";
|
||||
public static final String THORN_CHAKRAM = LibResources.PREFIX_MOD + "thornChakram";
|
||||
|
||||
}
|
||||
@@ -117,6 +117,7 @@ public final class LibItemNames {
|
||||
public static final String SMELT_ROD = "smeltRod";
|
||||
public static final String WORLD_SEED = "worldSeed";
|
||||
public static final String SPELL_CLOTH = "spellCloth";
|
||||
public static final String THORN_CHAKRAM = "thornChakram";
|
||||
|
||||
public static final String[] LENS_NAMES = new String[] {
|
||||
"lensNormal",
|
||||
|
||||
Reference in new issue
Block a user