forked from TAIGA/TAIGA
More Traits. Problem: @SubscribeEvent runs for every kind of tool ...
This commit is contained in:
@@ -23,7 +23,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.AQUA);
|
||||
public static Material mythril = new Material("mythril", TextFormatting.AQUA).addTrait(pulverizing, HeadMaterialStats.TYPE);
|
||||
|
||||
public static Material astrium = new Material("astrium", TextFormatting.LIGHT_PURPLE);
|
||||
public static Material nitronite = new Material("nitronite", TextFormatting.LIGHT_PURPLE);
|
||||
|
@@ -41,6 +41,7 @@ public class ZTiC {
|
||||
public static final AbstractTrait frature = new TraitFracture();
|
||||
public static final AbstractTrait glimmer = new TraitGlimmer();
|
||||
public static final AbstractTrait garishly = new TraitGarishly();
|
||||
public static final AbstractTrait pulverizing = new TraitPulverizing();
|
||||
|
||||
static final String MODID = "ztic_addon";
|
||||
static final String VERSION = "@VERSION@";
|
||||
|
@@ -0,0 +1,43 @@
|
||||
package com.sosnitzka.ztic_addon.util.traits;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import slimeknights.tconstruct.library.traits.AbstractTrait;
|
||||
import slimeknights.tconstruct.library.utils.ToolHelper;
|
||||
|
||||
/**
|
||||
* Created by Robert on 03.06.2016.
|
||||
*/
|
||||
public class TraitPulverizing extends AbstractTrait {
|
||||
|
||||
public TraitPulverizing() {
|
||||
super("pulverizing", TextFormatting.DARK_GRAY);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void miningSpeed(ItemStack tool, PlayerEvent.BreakSpeed event) {
|
||||
if (ToolHelper.isToolEffective2(tool, event.getState())) {
|
||||
event.setNewSpeed((float) (event.getNewSpeed() + calcBonus(tool)));
|
||||
}
|
||||
}
|
||||
|
||||
private double calcBonus(ItemStack tool) {
|
||||
int durability = ToolHelper.getCurrentDurability(tool);
|
||||
int maxDurability = ToolHelper.getMaxDurability(tool);
|
||||
float speed = ToolHelper.getMiningSpeedStat(tool);
|
||||
return (speed / 3) / (maxDurability - 100) * (durability) + 0.5f;
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBlockBreak(HarvestDropsEvent event) {
|
||||
event.getDrops().clear();
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -4,6 +4,7 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import slimeknights.tconstruct.library.traits.AbstractTrait;
|
||||
|
||||
/**
|
||||
@@ -14,6 +15,7 @@ public class TraitResonance extends AbstractTrait {
|
||||
|
||||
public TraitResonance() {
|
||||
super("resonance", TextFormatting.AQUA);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user