mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
Split more files into parts
This commit is contained in:
1 parent
e2f0558b6f
commit
5a87c102ea
61 files changed
+1365
-1499
No files matched your search
@@ -0,0 +1,149 @@
|
||||
package tconstruct.world;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.IEntityLivingData;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.entity.boss.IBossDisplayData;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityXPOrb;
|
||||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
import net.minecraft.entity.monster.EntityGhast;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.monster.EntitySpider;
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
|
||||
import net.minecraftforge.event.entity.player.BonemealEvent;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.armor.TinkerArmor;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.TinkerTools;
|
||||
import tconstruct.util.ItemHelper;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
import tconstruct.world.entity.BlueSlime;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class TinkerWorldEvents
|
||||
{
|
||||
@SubscribeEvent
|
||||
public void onLivingSpawn (LivingSpawnEvent.SpecialSpawn event)
|
||||
{
|
||||
EntityLivingBase living = event.entityLiving;
|
||||
if (living.getClass() == EntitySpider.class && TConstruct.random.nextInt(100) == 0)
|
||||
{
|
||||
EntityCreeper creeper = new EntityCreeper(living.worldObj);
|
||||
spawnEntityLiving(living.posX, living.posY + 1, living.posZ, creeper, living.worldObj);
|
||||
if (living.riddenByEntity != null)
|
||||
creeper.mountEntity(living.riddenByEntity);
|
||||
else
|
||||
creeper.mountEntity(living);
|
||||
|
||||
EntityXPOrb orb = new EntityXPOrb(living.worldObj, living.posX, living.posY, living.posZ, TConstruct.random.nextInt(20) + 20);
|
||||
orb.mountEntity(creeper);
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnEntityLiving (double x, double y, double z, EntityLiving entity, World world)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
entity.setPosition(x, y, z);
|
||||
entity.onSpawnWithEgg((IEntityLivingData) null);
|
||||
world.spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/* Bonemeal */
|
||||
@SubscribeEvent
|
||||
public void bonemealEvent (BonemealEvent event)
|
||||
{
|
||||
if (!event.world.isRemote)
|
||||
{
|
||||
if (event.block == TinkerWorld.slimeSapling)
|
||||
{
|
||||
if (TinkerWorld.slimeSapling.boneFertilize(event.world, event.x, event.y, event.z, event.world.rand, event.entityPlayer))
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Damage */
|
||||
@SubscribeEvent
|
||||
public void onHurt (LivingHurtEvent event)
|
||||
{
|
||||
EntityLivingBase reciever = event.entityLiving;
|
||||
if (reciever instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = (EntityPlayer) event.entityLiving;
|
||||
// Cutlass
|
||||
ItemStack stack = player.getCurrentEquippedItem();
|
||||
if (stack != null && player.isUsingItem())
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
if (item == TinkerTools.cutlass)
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 3 * 20, 1));
|
||||
}
|
||||
else if (item == TinkerTools.battlesign)
|
||||
{
|
||||
event.ammount *= 1.5; //Puts battlesign blocking at 3/4 instead of 1/2
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (reciever instanceof EntityCreeper)
|
||||
{
|
||||
Entity attacker = event.source.getEntity();
|
||||
if (attacker instanceof EntityLivingBase)
|
||||
{
|
||||
Entity target = ((EntityCreeper) reciever).getAttackTarget();
|
||||
if (target != null)
|
||||
{
|
||||
float d1 = reciever.getDistanceToEntity(((EntityCreeper) reciever).getAttackTarget());
|
||||
float d2 = reciever.getDistanceToEntity(attacker);
|
||||
if (d2 < d1)
|
||||
{
|
||||
((EntityCreeper) event.entityLiving).setAttackTarget((EntityLivingBase) event.source.getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLivingDrop (LivingDropsEvent event)
|
||||
{
|
||||
if (event.entityLiving == null)
|
||||
return;
|
||||
|
||||
if (event.entityLiving.getClass() == EntityGhast.class)
|
||||
{
|
||||
if (PHConstruct.uhcGhastDrops)
|
||||
{
|
||||
for (EntityItem o : event.drops)
|
||||
{
|
||||
if (o.getEntityItem().getItem() == Items.ghast_tear)
|
||||
{
|
||||
o.setEntityItemStack(new ItemStack(Items.gold_ingot, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemHelper.addDrops(event, new ItemStack(Items.ghast_tear, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user