Added separate handle and head traits for several materials, to specify them more.

This commit is contained in:
Robert Sosnitzka
2016-06-29 16:47:05 +02:00
parent 7944530375
commit b11e69af7c
9 changed files with 178 additions and 20 deletions

View File

@@ -2,15 +2,16 @@ package com.sosnitzka.ztic_addon;
import net.minecraft.util.text.TextFormatting;
import slimeknights.tconstruct.library.materials.HandleMaterialStats;
import slimeknights.tconstruct.library.materials.HeadMaterialStats;
import slimeknights.tconstruct.library.materials.Material;
import static com.sosnitzka.ztic_addon.ZTiC.*;
public class Materials {
public static Material arcanite = new Material("arcanite", TextFormatting.LIGHT_PURPLE).addTrait(haunted);
public static Material arcanite = new Material("arcanite", TextFormatting.LIGHT_PURPLE).addTrait(arcane, HeadMaterialStats.TYPE).addTrait(dark, HandleMaterialStats.TYPE);
public static Material tiberium = new Material("tiberium", TextFormatting.LIGHT_PURPLE).addTrait(instable);
public static Material prometheum = new Material("prometheum", TextFormatting.LIGHT_PURPLE).addTrait(dark);
public static Material prometheum = new Material("prometheum", TextFormatting.LIGHT_PURPLE).addTrait(haunted, HeadMaterialStats.TYPE).addTrait(dark, HandleMaterialStats.TYPE);
public static Material rubium = new Material("rubium", TextFormatting.LIGHT_PURPLE);
public static Material violium = new Material("violium", TextFormatting.DARK_GREEN).addTrait(analysing);
public static Material bismuth = new Material("bismuth", TextFormatting.DARK_GREEN);
@@ -23,7 +24,7 @@ public class Materials {
public static Material ignitite = new Material("ignitite", TextFormatting.AQUA);
public static Material palladium = new Material("palladium", TextFormatting.AQUA);
public static Material eternite = new Material("eternite", TextFormatting.AQUA);
public static Material mythril = new Material("mythril", TextFormatting.GRAY).addTrait(pulverizing, HeadMaterialStats.TYPE);
public static Material mythril = new Material("mythril", TextFormatting.GRAY).addTrait(pulverizing, HeadMaterialStats.TYPE).addTrait(bentonite, HandleMaterialStats.TYPE);
public static Material astrium = new Material("astrium", TextFormatting.LIGHT_PURPLE);
public static Material nitronite = new Material("nitronite", TextFormatting.LIGHT_PURPLE);
@@ -31,12 +32,12 @@ public class Materials {
public static Material noctunyx = new Material("noctunyx", TextFormatting.LIGHT_PURPLE);
public static Material imperomite = new Material("imperomite", TextFormatting.DARK_GREEN);
public static Material cryptogen = new Material("cryptogen", TextFormatting.DARK_GREEN);
public static Material fractoryte = new Material("fractoryte", TextFormatting.DARK_RED).addTrait(frature, HeadMaterialStats.TYPE);
public static Material seismodium = new Material("seismodium", TextFormatting.DARK_GREEN).addTrait(cascade, HeadMaterialStats.TYPE);
public static Material fractoryte = new Material("fractoryte", TextFormatting.DARK_RED).addTrait(frature, HeadMaterialStats.TYPE).addTrait(fragile, HandleMaterialStats.TYPE);
public static Material seismodium = new Material("seismodium", TextFormatting.DARK_GREEN).addTrait(cascade, HeadMaterialStats.TYPE).addTrait(fragile, HandleMaterialStats.TYPE);
public static Material terramite = new Material("terramite", TextFormatting.GRAY);
public static Material lumixyl = new Material("lumixyl", TextFormatting.YELLOW).addTrait(glimmer);
public static Material solarium = new Material("solarium", TextFormatting.RED).addTrait(garishly);
public static Material dyonite = new Material("dyonite", TextFormatting.GRAY).addTrait(slaughtering, HeadMaterialStats.TYPE);
public static Material dyonite = new Material("dyonite", TextFormatting.GRAY).addTrait(slaughtering, HeadMaterialStats.TYPE).addTrait(dissolving, HandleMaterialStats.TYPE);
public static Material ultranite = new Material("ultranite", TextFormatting.AQUA);
public static Material nucleum = new Material("nucleum", TextFormatting.AQUA);
public static Material aegisalt = new Material("aegisalt", TextFormatting.AQUA);

View File

@@ -47,6 +47,10 @@ public class ZTiC {
public static final AbstractTrait dark = new TraitDark();
public static final AbstractTrait slaughtering = new TraitSlaughtering();
public static final AbstractTrait haunted = new TraitHaunted();
public static final AbstractTrait fragile = new TraitFragile();
public static final AbstractTrait dissolving = new TraitDissolving();
public static final AbstractTrait bentonite = new TraitBentonite();
public static final AbstractTrait arcane = new TraitArcane();
static final String MODID = "ztic_addon";
static final String VERSION = "@VERSION@";

View File

@@ -0,0 +1,45 @@
package com.sosnitzka.ztic_addon.traits;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import slimeknights.tconstruct.library.traits.AbstractTrait;
import slimeknights.tconstruct.library.utils.ToolHelper;
/**
* Created by Robert on 03.06.2016.
*/
public class TraitArcane extends AbstractTrait {
public TraitArcane() {
super("arcane", TextFormatting.DARK_PURPLE);
}
@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.1 && isNight(time)) {
ToolHelper.healTool(tool, random.nextInt(21) + 1, null);
}
}
@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.1 && isNight(time)) {
ToolHelper.healTool(tool, random.nextInt(21) + 1, null);
}
}
public boolean isNight(int time) {
if (time > 12500) {
return true;
} else {
return false;
}
}
}

View File

@@ -0,0 +1,27 @@
package com.sosnitzka.ztic_addon.traits;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import slimeknights.tconstruct.library.traits.AbstractTrait;
import slimeknights.tconstruct.library.utils.ToolHelper;
public class TraitBentonite extends AbstractTrait {
private static final float chance = 0.1f;
public TraitBentonite() {
super("bentonite", TextFormatting.RED);
}
@Override
public void afterBlockBreak(ItemStack tool, World world, IBlockState state, BlockPos pos, EntityLivingBase player, boolean wasEffective) {
if (!world.isRemote && (state.getMaterial() == Material.ROCK) && random.nextFloat() < chance) {
ToolHelper.healTool(tool, random.nextInt(15), player);
}
}
}

View File

@@ -9,7 +9,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import slimeknights.tconstruct.library.traits.AbstractTrait;
import slimeknights.tconstruct.library.utils.ToolHelper;
/**
* Created by Robert on 03.06.2016.
@@ -22,20 +21,28 @@ public class TraitDark extends AbstractTrait {
@Override
public void afterBlockBreak(ItemStack tool, World world, IBlockState state, BlockPos pos, EntityLivingBase player, boolean wasEffective) {
if (random.nextFloat() <= 0.1) {
player.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, 300));
player.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 300));
ToolHelper.healTool(tool, random.nextInt(51) + 10, null);
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));
}
}
@Override
public void afterHit(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, boolean wasCritical, boolean wasHit) {
if (random.nextFloat() <= 0.1) {
player.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, 300));
player.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 300));
ToolHelper.healTool(tool, random.nextInt(51) + 10, null);
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) {
if (time > 12500) {
return true;
} else {
return false;
}
}
}

View File

@@ -0,0 +1,29 @@
package com.sosnitzka.ztic_addon.traits;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingExperienceDropEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import slimeknights.tconstruct.library.traits.AbstractTrait;
import slimeknights.tconstruct.library.utils.TagUtil;
import slimeknights.tconstruct.library.utils.TinkerUtil;
/**
* Created by Robert on 09.06.2016.
*/
public class TraitDissolving extends AbstractTrait {
public TraitDissolving() {
super("dissolving", TextFormatting.DARK_AQUA);
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void onXpDrop(LivingExperienceDropEvent event) {
EntityPlayer player = event.getAttackingPlayer();
if (random.nextFloat() < 0.3 && player != null && TinkerUtil.hasTrait(TagUtil.getTagSafe(player.getHeldItemMainhand()), this.identifier)) {
event.setDroppedExperience(0);
}
}
}

View File

@@ -0,0 +1,36 @@
package com.sosnitzka.ztic_addon.traits;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
import slimeknights.tconstruct.library.traits.AbstractTrait;
import slimeknights.tconstruct.library.utils.ToolHelper;
/**
* Created by Robert on 03.06.2016.
*/
public class TraitFragile extends AbstractTrait {
public TraitFragile() {
super("fragile", TextFormatting.DARK_GRAY);
}
@Override
public void afterBlockBreak(ItemStack tool, World world, IBlockState state, BlockPos pos, EntityLivingBase player, boolean wasEffective) {
float f = random.nextFloat();
float b = 0.99F * calcBonus(tool);
if (!world.isRemote && tool.canHarvestBlock(state) && f <= b) {
if (random.nextBoolean()) ToolHelper.damageTool(tool, random.nextInt(5), player);
}
}
private float calcBonus(ItemStack tool) {
int durability = ToolHelper.getCurrentDurability(tool);
int maxDurability = ToolHelper.getMaxDurability(tool);
return (0.4f) / (maxDurability - 50) * (durability) + 0.55f;
}
}

View File

@@ -18,18 +18,27 @@ public class TraitHaunted extends AbstractTrait {
MinecraftForge.EVENT_BUS.register(this);
}
// Just several tested Vanilla-Mobs, e.g. no ghasts, bats or skeletons
@Override
public void onHit(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, boolean isCritical) {
if (random.nextFloat() < 0.1)
int time = (int) player.getEntityWorld().getWorldTime();
if (random.nextFloat() <= 0.1 || (random.nextFloat() <= 0.3 && isNight(time)))
if (target instanceof EntityCow || target instanceof EntityZombie || target instanceof EntityWolf || target instanceof EntityPig || target instanceof EntitySpider ||
target instanceof EntityVillager || target instanceof EntitySheep || target instanceof EntityEnderman || target instanceof EntityEndermite ||
target instanceof EntityBlaze || target instanceof EntitySkeleton || target instanceof EntityWitch || target instanceof EntityHorse) {
target instanceof EntityBlaze || target instanceof EntityWitch || target instanceof EntityHorse) {
((EntityLiving) target).tasks.taskEntries.clear();
((EntityLiving) target).tasks.taskEntries.clear();
((EntityLiving) target).targetTasks.taskEntries.clear();
((EntityLiving) target).targetTasks.taskEntries.clear();
((EntityLiving) target).tasks.addTask(0, new EntityAIPermanentPanic((EntityCreature) target, target.getAIMoveSpeed() + 2.0D));
}
}
public boolean isNight(int time) {
if (time > 12500) {
return true;
} else {
return false;
}
}
}

View File

@@ -20,7 +20,7 @@ public class TraitResonance extends AbstractTrait {
@Override
public void afterHit(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, boolean wasCritical, boolean wasHit) {
if (random.nextFloat() <= .33) {
target.knockBack(target, random.nextFloat() * random.nextFloat() * 10, player.posX - target.posX, player.posZ - target.posZ);
target.knockBack(target, random.nextFloat() * random.nextFloat() * 12, player.posX - target.posX, player.posZ - target.posZ);
}
}