forked from TAIGA/TAIGA
New traits!
This commit is contained in:
@@ -2,15 +2,9 @@ package com.sosnitzka.ztic_addon.generic;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BasicBlock extends Block {
|
||||
public static final PropertyBool ISSUN = PropertyBool.create("issun");
|
||||
private String oreDictPrefix;
|
||||
private int lVal;
|
||||
|
||||
public BasicBlock(String name, Material material, float hardness, float resistance, int harvest, float lightLevel, String oreDictPrefix) {
|
||||
super(material);
|
||||
@@ -21,12 +15,6 @@ public class BasicBlock extends Block {
|
||||
setHarvestLevel("pickaxe", harvest);
|
||||
setLightLevel(lightLevel);
|
||||
this.oreDictPrefix = oreDictPrefix;
|
||||
|
||||
}
|
||||
|
||||
public BasicBlock(String name, Material material, float hardness, float resistance, int harvest, float lightLevel, String oreDictPrefix, int activatedLL) {
|
||||
this(name, material, hardness, resistance, harvest, lightLevel, oreDictPrefix);
|
||||
this.lVal = activatedLL;
|
||||
}
|
||||
|
||||
public BasicBlock(String name, Material material, float hardness, float resistance, int harvest) {
|
||||
@@ -49,13 +37,4 @@ public class BasicBlock extends Block {
|
||||
return this.oreDictPrefix;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
if (state.getValue(ISSUN)) {
|
||||
return lVal;
|
||||
} else {
|
||||
return this.lightValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -69,11 +69,12 @@ public class TraitGarishly extends AbstractTrait {
|
||||
public void blockHarvestDrops(ItemStack tool, BlockEvent.HarvestDropsEvent event) {
|
||||
int i = random.nextInt(10);
|
||||
if (i == 9) event.getDrops().clear();
|
||||
else if (i == 2 || i == 1 || i == 3) {
|
||||
else if (i == 1 || i == 2 || i == 3) {
|
||||
ItemStack stack = new ItemStack(Item.getItemFromBlock(event.getWorld().getBlockState(event.getPos()).getBlock()), i);
|
||||
event.getDrops().add(0, stack);
|
||||
ToolHelper.damageTool(tool, i * 2, event.getHarvester());
|
||||
} else if (i == 0) event.getWorld().setBlockState(event.getPos(), Blocks.LAVA.getDefaultState());
|
||||
} else if (i == 0 && random.nextBoolean())
|
||||
event.getWorld().setBlockState(event.getPos(), Blocks.LAVA.getDefaultState());
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,16 +1,37 @@
|
||||
package com.sosnitzka.ztic_addon.traits;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import slimeknights.tconstruct.library.traits.AbstractTrait;
|
||||
import slimeknights.tconstruct.library.utils.TagUtil;
|
||||
import slimeknights.tconstruct.library.utils.TinkerUtil;
|
||||
|
||||
/**
|
||||
* Created by Robert on 03.06.2016.
|
||||
*/
|
||||
public class TraitGlimmer extends AbstractTrait {
|
||||
|
||||
|
||||
public TraitGlimmer() {
|
||||
super("glimmer", TextFormatting.DARK_GRAY);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack item, World world, Entity entity, int i, boolean b) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer e = (EntityPlayer) entity;
|
||||
if (TinkerUtil.hasTrait(TagUtil.getTagSafe(e.getHeldItemMainhand()), identifier)) {
|
||||
e.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 100));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -3,12 +3,20 @@ package com.sosnitzka.ztic_addon.traits;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.EntityMob;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
||||
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;
|
||||
import slimeknights.tconstruct.library.utils.ToolHelper;
|
||||
|
||||
|
||||
@@ -17,11 +25,12 @@ public class TraitInstable extends AbstractTrait {
|
||||
|
||||
public TraitInstable() {
|
||||
super("instable", TextFormatting.DARK_RED);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterBlockBreak(ItemStack tool, World world, IBlockState state, BlockPos pos, EntityLivingBase player, boolean wasEffective) {
|
||||
if (MathHelper.getRandomIntegerInRange(random, 0, 100) > 2) {
|
||||
if (random.nextFloat() <= 0.03) {
|
||||
if (!world.isRemote) {
|
||||
if (random.nextBoolean()) {
|
||||
explode(world, player, pos.getX(), pos.getY(), pos.getZ());
|
||||
@@ -34,7 +43,7 @@ public class TraitInstable extends AbstractTrait {
|
||||
@Override
|
||||
public void afterHit(ItemStack tool, EntityLivingBase player, EntityLivingBase target, float damage, boolean wasCritical, boolean wasHit) {
|
||||
BlockPos pos = target.getPosition();
|
||||
if (MathHelper.getRandomIntegerInRange(random, 0, 100) > 2) {
|
||||
if (random.nextFloat() <= 0.04) {
|
||||
if (!player.getEntityWorld().isRemote) {
|
||||
if (random.nextBoolean()) {
|
||||
explode(player.getEntityWorld(), player, pos.getX(), pos.getY(), pos.getZ());
|
||||
@@ -44,7 +53,18 @@ public class TraitInstable extends AbstractTrait {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMobDrops(LivingDropsEvent event) {
|
||||
World w = event.getEntity().getEntityWorld();
|
||||
if (event.getSource().getEntity() instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.getSource().getEntity();
|
||||
if (!w.isRemote && event.getEntity() instanceof EntityMob && TinkerUtil.hasTrait(TagUtil.getTagSafe(player.getHeldItemMainhand()), identifier)) {
|
||||
ItemStack i = new ItemStack(Items.GUNPOWDER, random.nextInt(4));
|
||||
event.getDrops().add(0, new EntityItem(w, event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
private void explode(World w, Entity e, double x, double y, double z) {
|
||||
w.newExplosion(e, x, y, z, 1.2f + random.nextFloat() * 5, random.nextBoolean(), true);
|
||||
w.newExplosion(e, x, y, z, 1.2f + random.nextFloat() * 35, random.nextBoolean(), true);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user