Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.examplemod;
- import java.util.Random;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityCreature;
- import net.minecraft.entity.item.EntityTNTPrimed;
- import net.minecraft.entity.monster.EntityCreeper;
- import net.minecraft.entity.monster.EntitySpider;
- 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.SidedProxy;
- 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.ArrayList;
- 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 = new ArrayList<Entity>();
- public net.minecraft.entity.player.EntityPlayer thisplayer;
- @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());
- thisplayer = player;
- }
- 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) {
- System.out.println("An arrow entered the world");
- if (!evt.getEntity().isDead) {
- entitylist.add(evt.getEntity());
- }
- }
- }
- @SubscribeEvent
- public void tickupdate(TickEvent evt) {
- Random myrandomgen = new Random();
- for (Entity ee : entitylist) {
- boolean ground = false;
- if (!ee.isDead) {
- double lastposx = ee.lastTickPosX;
- double lastposy = ee.lastTickPosY;
- double lastposz = ee.lastTickPosZ;
- double currentx = ee.posX;
- double currenty = ee.posY;
- double currentz = ee.posZ;
- double diffx = 0;
- double diffy = 0;
- double diffz = 0;
- boolean differencemajor = false;
- //Get difference in X since last Tick
- if (lastposx > currentx) {
- diffx = lastposx - currentx;
- }
- if (currentx > lastposx) {
- diffx = currentx - lastposx;
- }
- //Get difference in Y since last Tick
- if (lastposy > currenty) {
- diffy = lastposy - currenty;
- }
- if (currenty > lastposy) {
- diffy = currenty - lastposy;
- }
- //Get difference in Z since last Tick
- if (lastposz > currentz) {
- diffz = lastposz - currentz;
- }
- if (currentz > lastposz) {
- diffz = currentz - lastposz;
- }
- if (diffx < 1) {
- if (diffy < 1) {
- if (diffz < 1) {
- differencemajor = true;
- }
- }
- }
- if (thisplayer != null) {
- if (!thisplayer.getEntityWorld().isRemote) {
- if (differencemajor == true) {
- EntitySpider tntentity;
- net.minecraft.entity.Entity thisarrow;
- net.minecraft.world.World world;
- world = ee.getEntityWorld();
- thisarrow = ee;
- tntentity = new EntitySpider(thisplayer.getEntityWorld());
- tntentity.setLocationAndAngles(ee.posX, ee.posY, ee.posZ, 0, 0);
- world.spawnEntityInWorld(tntentity);
- for (int a=1;a<300;a++){
- int posx = myrandomgen.nextInt(200);
- int posy = myrandomgen.nextInt(30);
- int posz = myrandomgen.nextInt(200);
- double newx = (double)posx + ee.posX;
- double newy = (double)posy + ee.posY;
- double newz = (double)posz + ee.posZ;
- tntentity = new EntitySpider(thisplayer.getEntityWorld());
- tntentity.setLocationAndAngles(newx, newy, newz, 0, 0);
- world.spawnEntityInWorld(tntentity);
- }
- ee.setDead();
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement