change: increased visibility and removed gravity from dragon sinew item
package se.mickelus.tetra.items.loot;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.ItemEntity;
+import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootPool;
import net.minecraft.loot.TableLootEntry;
+import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.ResourceLocation;
+import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.LootTableLoadEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@@ -11,6 +16,8 @@ import se.mickelus.tetra.TetraMod;
import se.mickelus.tetra.items.TetraItem;
import se.mickelus.tetra.items.TetraItemGroup;
+import javax.annotation.Nullable;
+
public class DragonSinewItem extends TetraItem {
private static final String unlocalizedName = "dragon_sinew";
@ObjectHolder(TetraMod.MOD_ID + ":" + unlocalizedName)
@@ -26,6 +33,29 @@ public class DragonSinewItem extends TetraItem {
MinecraftForge.EVENT_BUS.register(new LootTableHandler());
}
+ @Override
+ public boolean hasCustomEntity(ItemStack stack) {
+ return true;
+ }
+
+ @Nullable
+ @Override
+ public Entity createEntity(World world, Entity entity, ItemStack itemstack) {
+ entity.setNoGravity(true);
+
+ return null;
+ }
+
+ @Override
+ public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) {
+ entity.setMotion(entity.getMotion().scale(0.8f));
+ if (entity.world.isRemote && entity.getAge() % 20 == 0) {
+ entity.world.addParticle(ParticleTypes.DRAGON_BREATH, entity.getPosXRandom(.2d), entity.getPosYRandom() + 0.2, entity.getPosZRandom(0.2),
+ entity.world.getRandom().nextFloat() * 0.02f - 0.01f, -0.01f -entity.world.getRandom().nextFloat() * 0.01f, entity.world.getRandom().nextFloat() * 0.02f - 0.01f);
+ }
+ return false;
+ }
+
public static class LootTableHandler {
@SubscribeEvent
public void onLootTableLoad(final LootTableLoadEvent event) {
