Guest User

ModItemEntity Class

a guest
Oct 13th, 2020
54
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ModItemEntity extends ProjectileItemEntity {
  2.  
  3. private ItemStack currentItem = new ItemStack(getDefaultItem(), 1);
  4. private int tickCount = 0;
  5. private boolean tickCheck = true;
  6.  
  7. public ModItemEntity(EntityType<? extends ModItemEntity> type, World worldIn) {
  8. super(type, worldIn);
  9. }
  10.  
  11. public ModItemEntity(LivingEntity livingEntityIn, World worldIn, ItemStack stack) {
  12. super(ModEntities.MOD_ITEM, livingEntityIn, worldIn);
  13. this.currentItem = stack;
  14. this.setItem(stack);
  15. }
  16.  
  17. @Override
  18. protected Item getDefaultItem() { return ModItems.MOD_ITEM; }
  19.  
  20. private void updateTag(int offset) {
  21. ModItem.setTag(this.currentItem, ModItem.LAYER_KEY, offset);
  22. }
  23.  
  24. @Override
  25. public IPacket<?> createSpawnPacket() {
  26. return NetworkHooks.getEntitySpawningPacket(this);
  27. }
  28.  
  29. @Override
  30. public void tick() {
  31. if (this.tickCheck) {
  32. if (this.tickCount == 5) {
  33. this.setVelocity(0, 0, 0);
  34. this.velocityChanged = true;
  35. this.setNoGravity(true);
  36. } else if (this.tickCount == 20) {
  37. updateTag(8);
  38. } else if (this.tickCount == 40) {
  39. updateTag(-8);
  40. this.tickCheck = false;
  41. }
  42. this.tickCount++;
  43. }
  44. super.tick();
  45. }
  46. }
RAW Paste Data Copied