Lot of traits!

This commit is contained in:
Robert Sosnitzka
2016-07-14 15:12:52 +02:00
parent b11e69af7c
commit a13131adc9
11 changed files with 116 additions and 49 deletions

View File

@@ -1,13 +1,8 @@
package com.sosnitzka.ztic_addon.traits;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import slimeknights.tconstruct.library.traits.AbstractTrait;
/**
@@ -20,22 +15,13 @@ public class TraitDark extends AbstractTrait {
}
@Override
public void afterBlockBreak(ItemStack tool, World world, IBlockState state, BlockPos pos, EntityLivingBase player, boolean wasEffective) {
int time = (int) world.getWorldTime();
if (random.nextFloat() <= 0.05 || (random.nextFloat() <= 0.3 && isNight(time))) {
player.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, random.nextInt(400) + 200));
player.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, random.nextInt(400) + 200));
public float damage(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, float newDamage, boolean isCritical) {
int time = (int) target.getEntityWorld().getWorldTime();
if (isNight(time)) {
newDamage += damage / 2f;
}
}
return super.damage(tool, player, target, damage, newDamage, isCritical);
@Override
public void afterHit(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, boolean wasCritical, boolean wasHit) {
int time = (int) player.getEntityWorld().getWorldTime();
if (random.nextFloat() <= 0.05 || (random.nextFloat() <= 0.3 && isNight(time))) {
player.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, random.nextInt(400) + 200));
player.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, random.nextInt(400) + 200));
}
}
public boolean isNight(int time) {