Advertisement
Guest User

Explosion_arrows

a guest
May 28th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.96 KB | None | 0 0
  1. package com.example.examplemod;
  2.  
  3. import net.minecraft.entity.Entity;
  4. import net.minecraft.entity.item.EntityTNTPrimed;
  5. import net.minecraft.entity.projectile.EntityArrow;
  6. import net.minecraft.entity.projectile.EntitySpectralArrow;
  7. import net.minecraft.item.Item;
  8. import com.forgeessentials.core.ForgeEssentials;
  9. import net.minecraft.block.Block;
  10. import net.minecraft.block.BlockDirt;
  11. import net.minecraft.world.World;
  12. import com.sun.istack.internal.Nullable;
  13. import net.minecraft.block.state.IBlockState;
  14. import net.minecraft.entity.player.EntityPlayer;
  15. import net.minecraft.item.ItemStack;
  16. import net.minecraft.util.EnumFacing;
  17. import net.minecraft.util.EnumHand;
  18. import net.minecraft.util.ITickable;
  19. import net.minecraft.util.math.BlockPos;
  20. import net.minecraft.world.World;
  21. import net.minecraftforge.common.MinecraftForge;
  22. import net.minecraftforge.event.AttachCapabilitiesEvent;
  23. import net.minecraftforge.event.entity.EntityJoinWorldEvent;
  24. import net.minecraftforge.event.entity.player.PlayerInteractEvent;
  25. import net.minecraftforge.fml.common.Mod;
  26. import net.minecraftforge.fml.common.Mod.EventHandler;
  27. import net.minecraftforge.fml.common.WorldAccessContainer;
  28. import net.minecraftforge.fml.common.event.FMLInitializationEvent;
  29. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  30. import net.minecraftforge.fml.common.gameevent.TickEvent;
  31.  
  32. import java.util.EnumSet;
  33. import java.util.List;
  34.  
  35. @Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION)
  36. public class ExampleMod {
  37.     public static final String MODID = "examplemod";
  38.     public static final String VERSION = "1.0";
  39.     public List<Entity> entitylist;
  40.  
  41.     @EventHandler
  42.     public void init(FMLInitializationEvent event) {
  43.         // some example code
  44.         //System.out.println("DIRT BLOCK >> "+Blocks.DIRT.getUnlocalizedName());
  45.         //MinecraftForge.EVENT_BUS.register(this);
  46.         MinecraftForge.EVENT_BUS.register(this);
  47.     }
  48.  
  49.  
  50.     @SubscribeEvent
  51.     public void leftClickBlock(PlayerInteractEvent.LeftClickBlock evt) {
  52.  
  53.         if (evt.getItemStack() != null) {
  54.             EntityTNTPrimed entity;
  55.             net.minecraft.entity.player.EntityPlayer player;
  56.             net.minecraft.world.World world;
  57.             player = evt.getEntityPlayer();
  58.             world = evt.getWorld();
  59.  
  60.             entity = new EntityTNTPrimed(world, player.posX, player.posY, player.posZ, player);
  61.             world.spawnEntityInWorld(entity);
  62.  
  63.             System.out.println(evt.getItemStack().getDisplayName().toString());
  64.         }
  65.  
  66.         if (evt.getItemStack() == null) {
  67.             System.out.println("You don't have anything in hand");
  68.  
  69.         }
  70.  
  71.         // When item use denied, the event will keep firing as long as the left click button is held.
  72.         // This is due to how vanilla calls the left click handling methods to let people not lift their button when mining multiple blocks.
  73.         // Note that when item use is denied, the cool down for the item does not occur. This is good!
  74.     }
  75.  
  76.     @SubscribeEvent
  77.     public void ArrowJoins(EntityJoinWorldEvent evt) {
  78.  
  79.         if (evt.getEntity() instanceof EntityArrow) {
  80.             if (!evt.getEntity().onGround) {
  81.                 entitylist.add(evt.getEntity());
  82.  
  83.  
  84.             }
  85.         }
  86.  
  87.     }
  88.  
  89.     @SubscribeEvent
  90.     public void tickupdate(TickEvent evt){
  91.        
  92.  
  93.         for (Entity ee : entitylist) {
  94.             boolean ground =false;
  95.  
  96.            if (ee.onGround ==true) {
  97.  
  98.  
  99.                EntityTNTPrimed tntentity;
  100.                net.minecraft.entity.Entity thisarrow;
  101.                net.minecraft.world.World world;
  102.                world =   ee.getEntityWorld();
  103.                thisarrow = ee;
  104.  
  105.                tntentity = new EntityTNTPrimed(world, ee.posX, ee.posY, ee.posZ, world.getClosestPlayer(ee.posX, ee.posY, ee.posZ, 1, false));
  106.                world.spawnEntityInWorld(tntentity);
  107.                entitylist.remove(ee);
  108.            }
  109.  
  110.  
  111.         }
  112.     }
  113.  
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement