use of net.minecraft.entity.EntityLivingBase in project ArsMagica2 by Mithion.
the class SpellScrollRenderer method renderEffect.
public void renderEffect(Affinity affinity, boolean includeArm, Object... data) {
if (!setupIcons) {
setupAffinityIcons();
setupIcons = true;
}
RenderBlocks renderer = (RenderBlocks) data[0];
EntityLivingBase entity = (EntityLivingBase) data[1];
GL11.glPushMatrix();
GL11.glEnable(32826);
GL11.glEnable(3042);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
float scale = 3f;
if (entity == mc.thePlayer && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0) {
GL11.glPushMatrix();
if (((EntityPlayer) entity).getItemInUseCount() > 0) {
GL11.glRotatef(120, 1, 0, 1);
GL11.glRotatef(-10, 0, 1, 0);
GL11.glTranslatef(2f, 0f, 0.8f);
} else {
GL11.glTranslatef(3f, -1.2f, -2.5f);
GL11.glScalef(scale, scale, scale);
GL11.glRotatef(-45, 0, 1, 0);
}
RenderHelper.disableStandardItemLighting();
GL11.glTranslatef(0.6f, 0.0f, -0.4f);
RenderByAffinity(affinity);
RenderHelper.enableStandardItemLighting();
GL11.glPopMatrix();
if (includeArm) {
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).getItemInUseCount() > 0) {
GL11.glRotatef(-130, 0, 1, 0);
GL11.glTranslatef(-1f, 0.2f, -2.5f);
}
GL11.glScalef(scale, scale, scale);
GL11.glTranslatef(0f, 0.6f, 1.1f);
Minecraft.getMinecraft().renderEngine.bindTexture(mc.thePlayer.getLocationSkin());
renderFirstPersonArm(mc.thePlayer);
}
} else {
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).getItemInUseCount() > 0) {
GL11.glTranslatef(0.0f, 0.0f, 1.0f);
} else {
GL11.glTranslatef(0.0f, 0.0f, 1.6f);
}
scale = 1.5f;
GL11.glScalef(scale, scale, scale);
GL11.glRotatef(45, 0, 1, 0);
RenderByAffinity(affinity);
}
GL11.glDisable(32826);
GL11.glDisable(GL11.GL_BLEND);
GL11.glDisable(3042);
GL11.glPopMatrix();
}
use of net.minecraft.entity.EntityLivingBase in project ArsMagica2 by Mithion.
the class Recall method applyEffectEntity.
@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
if (!(target instanceof EntityLivingBase)) {
return false;
}
if (caster.isPotionActive(BuffList.astralDistortion.id) || ((EntityLivingBase) target).isPotionActive(BuffList.astralDistortion.id)) {
if (caster instanceof EntityPlayer)
((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.cantTeleport")));
return false;
}
int x = (int) Math.floor(target.posX);
int y = (int) Math.floor(target.posY);
int z = (int) Math.floor(target.posZ);
ItemStack[] ritualRunes = RitualShapeHelper.instance.checkForRitual(this, world, x, y, z, false);
if (ritualRunes != null) {
return handleRitualReagents(ritualRunes, world, x, y, z, caster, target);
}
ExtendedProperties casterProperties = ExtendedProperties.For(caster);
if (!casterProperties.getMarkSet()) {
if (caster instanceof EntityPlayer && !world.isRemote)
((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.noMark")));
return false;
} else if (casterProperties.getMarkDimension() != caster.dimension) {
if (caster instanceof EntityPlayer && !world.isRemote)
((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.diffDimMark")));
return false;
}
if (!world.isRemote) {
((EntityLivingBase) target).setPositionAndUpdate(casterProperties.getMarkX(), casterProperties.getMarkY(), casterProperties.getMarkZ());
}
return true;
}
use of net.minecraft.entity.EntityLivingBase in project ArsMagica2 by Mithion.
the class ManaDrain method applyEffectEntity.
@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
if (!(target instanceof EntityLivingBase))
return false;
double manaStolen = 250;
ExtendedProperties targetProperties = ExtendedProperties.For((EntityLivingBase) target);
if (manaStolen > targetProperties.getCurrentMana()) {
manaStolen = targetProperties.getCurrentMana();
}
targetProperties.setCurrentMana((float) (targetProperties.getCurrentMana() - manaStolen));
targetProperties.forceSync();
ExtendedProperties casterProperties = ExtendedProperties.For(caster);
casterProperties.setCurrentMana((float) (casterProperties.getCurrentMana() + manaStolen));
casterProperties.forceSync();
return true;
}
use of net.minecraft.entity.EntityLivingBase in project VoodooCraft by Mod-DevCafeTeam.
the class HexHandler method hurtEvent.
/**
* Protection Hex
*/
@SubscribeEvent
public static void hurtEvent(LivingHurtEvent event) {
EntityLivingBase entity = event.getEntityLiving();
ItemStack stack;
//Protection - Absorbs some damage, with a 10s cooldown
if (event.getSource().getSourceOfDamage() != null && (stack = getDollWithHex(entity, "protection")) != null) {
UUID uuid = entity.getUniqueID();
Long cooldownStart = protectionCooldowns.get(uuid);
long worldTime = entity.world.getTotalWorldTime();
//Check if hex is ready to protect
if (//200 ticks == 10 seconds
cooldownStart == null || (worldTime - cooldownStart) >= 200) {
//Protect from up to 5 hearts of damage
float protection = 10f;
float damage = event.getAmount();
event.setAmount(damage <= protection ? 0 : damage - protection);
//Sets the new cooldown start
protectionCooldowns.put(uuid, worldTime);
//Damage the doll
stack.damageItem(1, entity);
}
}
}
use of net.minecraft.entity.EntityLivingBase in project ImmersiveEngineering by BluSunrize.
the class TileEntityConveyorVertical method onEntityCollision.
@Override
public void onEntityCollision(World world, Entity entity) {
if (entity != null && !entity.isDead) {
if (world.isBlockIndirectlyGettingPowered(pos) > 0)
return;
double vBase = entity instanceof EntityLivingBase ? 1.5 : 1.15;
double distY = Math.abs(getPos().add(0, 1, 0).getY() + .5 - entity.posY);
double treshold = .9;
boolean contact = distY < treshold;
double vX = entity.motionX;
double vY = 0.1 * vBase;
double vZ = entity.motionZ;
if (entity.motionY < 0)
vY += entity.motionY * .9;
if (!(entity instanceof EntityPlayer)) {
vX = 0.05 * this.facing.getFrontOffsetX();
vZ = 0.05 * this.facing.getFrontOffsetZ();
if (facing == EnumFacing.WEST || facing == EnumFacing.EAST) {
if (entity.posZ > getPos().getZ() + 0.65D)
vZ = -0.1D * vBase;
else if (entity.posZ < getPos().getZ() + 0.35D)
vZ = 0.1D * vBase;
} else if (facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH) {
if (entity.posX > getPos().getX() + 0.65D)
vX = -0.1D * vBase;
else if (entity.posX < getPos().getX() + 0.35D)
vX = 0.1D * vBase;
}
}
//Little boost at the top of a conveyor to help players and minecarts to get off
if (contact && !(world.getTileEntity(getPos().add(0, 1, 0)) instanceof TileEntityConveyorVertical))
vY *= 2.25;
entity.onGround = false;
if (entity.fallDistance < 3)
entity.fallDistance = 0;
else
entity.fallDistance *= .9;
entity.motionX = vX;
entity.motionY = vY;
entity.motionZ = vZ;
if (entity instanceof EntityItem) {
((EntityItem) entity).setNoDespawn();
TileEntity inventoryTile;
inventoryTile = world.getTileEntity(getPos().add(0, 1, 0));
if (!world.isRemote) {
if (contact && inventoryTile != null && !(inventoryTile instanceof TileEntityConveyorBelt)) {
ItemStack stack = ((EntityItem) entity).getEntityItem();
if (stack != null) {
ItemStack ret = Utils.insertStackIntoInventory(inventoryTile, stack, EnumFacing.DOWN);
if (ret == null)
entity.setDead();
else if (ret.stackSize < stack.stackSize)
((EntityItem) entity).setEntityItemStack(ret);
}
}
}
}
}
}
Aggregations