Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.examplemod;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.item.EntityTNTPrimed;
- import net.minecraft.entity.projectile.EntityArrow;
- import net.minecraft.entity.projectile.EntitySpectralArrow;
- import net.minecraft.item.Item;
- import com.forgeessentials.core.ForgeEssentials;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockDirt;
- import net.minecraft.world.World;
- import com.sun.istack.internal.Nullable;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.EnumFacing;
- import net.minecraft.util.EnumHand;
- import net.minecraft.util.ITickable;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.world.World;
- import net.minecraftforge.common.MinecraftForge;
- import net.minecraftforge.event.AttachCapabilitiesEvent;
- import net.minecraftforge.event.entity.EntityJoinWorldEvent;
- import net.minecraftforge.event.entity.player.PlayerInteractEvent;
- import net.minecraftforge.fml.common.Mod;
- import net.minecraftforge.fml.common.Mod.EventHandler;
- import net.minecraftforge.fml.common.WorldAccessContainer;
- import net.minecraftforge.fml.common.event.FMLInitializationEvent;
- import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
- import net.minecraftforge.fml.common.gameevent.TickEvent;
- import java.util.EnumSet;
- import java.util.List;
- @Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION)
- public class ExampleMod {
- public static final String MODID = "examplemod";
- public static final String VERSION = "1.0";
- public List<Entity> entitylist;
- @EventHandler
- public void init(FMLInitializationEvent event) {
- // some example code
- //System.out.println("DIRT BLOCK >> "+Blocks.DIRT.getUnlocalizedName());
- //MinecraftForge.EVENT_BUS.register(this);
- MinecraftForge.EVENT_BUS.register(this);
- }
- @SubscribeEvent
- public void leftClickBlock(PlayerInteractEvent.LeftClickBlock evt) {
- if (evt.getItemStack() != null) {
- EntityTNTPrimed entity;
- net.minecraft.entity.player.EntityPlayer player;
- net.minecraft.world.World world;
- player = evt.getEntityPlayer();
- world = evt.getWorld();
- entity = new EntityTNTPrimed(world, player.posX, player.posY, player.posZ, player);
- world.spawnEntityInWorld(entity);
- System.out.println(evt.getItemStack().getDisplayName().toString());
- }
- if (evt.getItemStack() == null) {
- System.out.println("You don't have anything in hand");
- }
- // When item use denied, the event will keep firing as long as the left click button is held.
- // This is due to how vanilla calls the left click handling methods to let people not lift their button when mining multiple blocks.
- // Note that when item use is denied, the cool down for the item does not occur. This is good!
- }
- @SubscribeEvent
- public void ArrowJoins(EntityJoinWorldEvent evt) {
- if (evt.getEntity() instanceof EntityArrow) {
- if (!evt.getEntity().onGround) {
- entitylist.add(evt.getEntity());
- }
- }
- }
- @SubscribeEvent
- public void tickupdate(TickEvent evt){
- for (Entity ee : entitylist) {
- boolean ground =false;
- if (ee.onGround ==true) {
- EntityTNTPrimed tntentity;
- net.minecraft.entity.Entity thisarrow;
- net.minecraft.world.World world;
- world = ee.getEntityWorld();
- thisarrow = ee;
- tntentity = new EntityTNTPrimed(world, ee.posX, ee.posY, ee.posZ, world.getClosestPlayer(ee.posX, ee.posY, ee.posZ, 1, false));
- world.spawnEntityInWorld(tntentity);
- entitylist.remove(ee);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement