本文整理匯總了Java中net.minecraft.util.DamageSource.getTrueSource方法的典型用法代碼示例。如果您正苦於以下問題:Java DamageSource.getTrueSource方法的具體用法?Java DamageSource.getTrueSource怎麽用?Java DamageSource.getTrueSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.util.DamageSource
的用法示例。
在下文中一共展示了DamageSource.getTrueSource方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: attackEntityFrom
import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
@Override
public boolean attackEntityFrom(DamageSource source, float amount)
{
Entity entity = source.getTrueSource();
boolean takenDamage = super.attackEntityFrom(source, amount);
if (takenDamage && entity != null)
{
this.playSound(ModSoundEvents.ENTITY_FAKE_FADE, 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.1F) + 1.0F);
this.spawnExplosionParticle();
this.spawnExplosionParticle(); // TODO - examine why this is being fired twice - twice as many particles?
this.setDead();
}
return takenDamage;
}
示例2: attackEntityFrom
import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
@Override
public boolean attackEntityFrom(DamageSource source, float amount) {
if (this.isEntityInvulnerable(source))
return false;
else if (super.attackEntityFrom(source, amount)) {
if (source == DamageSource.DROWN || source == DamageSource.LAVA) {
this.superJump = true;
this.jump();
}
Entity entity = source.getTrueSource();
if (entity instanceof EntityPlayerMP)
this.bossInfo.addPlayer((EntityPlayerMP) entity);
this.rage += amount / 100f;
if (source instanceof TF2DamageSource && ((TF2DamageSource) source).getCritical() == 2
&& !((TF2DamageSource) source).getWeapon().isEmpty()
&& ((TF2DamageSource) source).getWeapon().getItem() instanceof ItemKnife)
this.playSound(TF2Sounds.MOB_SAXTON_STAB, 2.5F, 1f);
return this.getRidingEntity() != entity && this.getRidingEntity() != entity ? true : true;
} else
return false;
}
示例3: attackEntityFrom
import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
@Override
public boolean attackEntityFrom(DamageSource source, float amount) {
if (source == DamageSource.DROWN || source == DamageSource.LAVA || source == DamageSource.ON_FIRE)
return false;
if (source instanceof TF2DamageSource) {
if (source.getTrueSource()==this)
return false;
if (((TF2DamageSource) source).getCritical() > 0) {
amount *= 0.7f;
}
if (!((TF2DamageSource) source).getWeapon().isEmpty()
&& ((TF2DamageSource) source).getWeapon().getItem() instanceof ItemMinigun)
amount *= 0.36f;
}
if (super.attackEntityFrom(source, amount*damageMult)) {
if (source.getTrueSource() != null && source.getTrueSource() instanceof EntityPlayer)
this.attackers.add((EntityPlayer) source.getTrueSource());
return true;
}
return false;
}
示例4: attackEntityFrom
import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
public boolean attackEntityFrom(DamageSource source, float damage){
if (this.isEntityInvulnerable(source))
{
return false;
}
else if(source.getTrueSource() != null && source.getTrueSource() instanceof EntityLivingBase &&
!TF2Util.isOnSameTeam(source.getTrueSource(), this.shootingEntity)&& !(source.isExplosion() || source.isFireDamage())){
if (source instanceof TF2DamageSource) {
damage *= Math.max(1f,TF2Attribute.getModifier("Destroy Projectiles", ((TF2DamageSource)source).getWeapon(), 0, (EntityLivingBase) source.getTrueSource()));
}
this.health -= damage;
if (this.health <= 0)
this.setDead();
return true;
}
return false;
}
示例5: onEntityDamage
import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityDamage(LivingHurtEvent event) {
DamageSource source = event.getSource();
Entity attacker = source.getTrueSource();
if ((attacker instanceof EntityLivingBase) && ((EntityLivingBase) attacker).getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) {
event.setAmount(event.getAmount() * 0.95F);
}
}
示例6: onHurt
import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
@SubscribeEvent
public void onHurt(LivingHurtEvent ev) {
DamageSource source = ev.getSource();
Entity root = source.getTrueSource();
if (root instanceof EntityLivingBase) {
EntityLivingBase cause = (EntityLivingBase) root;
EntityLivingBase hurt = ev.getEntityLiving();
if (EmpoweredEnchantment.appliedTo(hurt)) {
EmpoweredEnchantment.doArmor(hurt, cause);
}
}
}
示例7: damageEntity
import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
/**
* When a treater is hurt by a player,
* The treater will send a chat message to that player
*/
@Override
protected void damageEntity(DamageSource damageSource, float damageAmount)
{
super.damageEntity(damageSource, damageAmount);
if (damageSource.getTrueSource() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer)damageSource.getTrueSource();
this.chatItUp(player, EnumTreaterMessage.HURTING);
}
}
示例8: onDeath
import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
@Override
public void onDeath(DamageSource s) {
if (s.getTrueSource() != null && s.getTrueSource() instanceof EntityPlayerMP && !TF2Util.isOnSameTeam(this, s.getTrueSource())) {
EntityPlayerMP player=(EntityPlayerMP) s.getTrueSource();
if(s.getTrueSource().getTeam() != null) {
player.addStat(TF2Achievements.KILLED_MERC);
if(player.getStatFile().readStat(TF2Achievements.KILLED_MERC)>=5 && player.getStatFile().readStat(TF2Achievements.CONTRACT_DAY)==0/*player.getCapability(TF2weapons.PLAYER_CAP, null).nextContractDay == -1*/)
player.addStat(TF2Achievements.CONTRACT_DAY, (int) (this.world.getWorldTime()/24000+1));
}
//player.addStat(TF2Achievements.FIRST_ENCOUNTER);
}
super.onDeath(s);
}
示例9: attackEntityFrom
import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
/**
* Called when the entity is attacked.
*/
@Override
public boolean attackEntityFrom(DamageSource source, float amount) {
if (this.recentlyHit > 0 && source == DamageSource.MAGIC)
this.recentlyHit=Math.max(20, this.recentlyHit);
if (this.isEntityInvulnerable(source))
return false;
else if (super.attackEntityFrom(source, amount)) {
Entity entity = source.getTrueSource();
return this.getRidingEntity() != entity && this.getRidingEntity() != entity ? true : true;
} else
return false;
}
示例10: attackEntityFrom
import net.minecraft.util.DamageSource; //導入方法依賴的package包/類
@Override
public boolean attackEntityFrom(DamageSource source, float amount)
{
// if the haunter wasn't damaged by an entity, or was damaged by a mob, do nothing
Entity entity = source.getTrueSource();
if (entity == null || entity instanceof EntityMob)
{
return false;
}
// check if the haunter took damage
boolean takenDamage = super.attackEntityFrom(source, amount);
// if the haunter took damage from a living entity...
if (takenDamage && entity instanceof EntityLivingBase)
{
// spawn explosion particles
this.spawnExplosionParticle();
// if the haunter's run out of health
if (this.getHealth() <= 0.0F)
{
// clear the attack target
this.setAttackTarget(null);
this.setCycleVisibility(51); // this.cycleVisibility = 51;
}
// otherwise (if the haunter hasn't run out of health)
else
{
// set the attack target to the entity which caused it damage
this.setAttackTarget((EntityLivingBase)entity);
// if cycleVisibility is less than 85 (it's maximum), set it to 85
if (this.getCycleVisibility() < 85) // if (this.cycleVisibility < 85)
{
this.setCycleVisibility(85); // this.cycleVisibility = 85;
// this.setTransparencyState(EnumTransparencyState.OPAQUE); // this.transparencyState = EnumTransparencyState.OPAQUE;
}
// strafe left or right randomly
this.setMoveStrafing(this.rand.nextInt(2) == 0 ? 1.5F : -1.5F);
}
}
return takenDamage;
}