package crazypants.enderio.machines.machine.obelisk.weather;

import java.util.Random;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import crazypants.enderio.base.EnderIO;
import crazypants.enderio.base.init.IModObject;
import crazypants.enderio.machines.machine.obelisk.AbstractBlockObelisk;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockWeatherObelisk extends AbstractBlockObelisk<TileWeatherObelisk> {

  public static BlockWeatherObelisk create(@Nonnull IModObject modObject) {
    BlockWeatherObelisk ret = new BlockWeatherObelisk(modObject);
    ret.init();

    // FIXME: this is wrong! "Detected an attempt by a mod %s to perform game activity during mod construction. This is a serious programming error."
    EntityRegistry.registerModEntity(new ResourceLocation(EnderIO.DOMAIN, "weather_rocket"), EntityWeatherRocket.class, "weather_rocket", 33, EnderIO.instance,
        64, 3, false); // TODO Check if Forge has a registry for this
    return ret;
  }

  private BlockWeatherObelisk(@Nonnull IModObject modObject) {
    super(modObject, TileWeatherObelisk.class);
  }

  @Override
  public @Nullable Container getServerGuiElement(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nullable EnumFacing facing,
      int param1, @Nonnull TileWeatherObelisk te) {
    return new ContainerWeatherObelisk(player.inventory, te);
  }

  @Override
  @SideOnly(Side.CLIENT)
  public @Nullable GuiScreen getClientGuiElement(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nullable EnumFacing facing,
      int param1, @Nonnull TileWeatherObelisk te) {
    return new GuiWeatherObelisk(player.inventory, te);
  }

  @Override
  @SideOnly(Side.CLIENT)
  public void randomDisplayTick(@Nonnull IBlockState bs, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Random rand) {
  }

  @Override
  public void neighborChanged(@Nonnull IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Block changedTo, @Nonnull BlockPos fromPos) {
    TileWeatherObelisk tileEntity = getTileEntity(world, pos);
    if (tileEntity != null) {
      tileEntity.updateRedstoneState();
    }
  }

}

@@ -681,16 +681,237 @@
 .World;%0A
+import net.minecraftforge.common.MinecraftForge;%0Aimport net.minecraftforge.event.RegistryEvent;%0Aimport net.minecraftforge.fml.common.eventhandler.SubscribeEvent;%0Aimport net.minecraftforge.fml.common.registry.EntityEntry;%0A
 import n
@@ -960,24 +960,24 @@
 tyRegistry;%0A
-
 import net.m
@@ -1310,158 +1310,168 @@
 ();%0A
-%0A
     
-// FIXME: this is wrong! %22Detected an attempt by a mod %25s to perform game activity during mo
+MinecraftForge.EVENT_BUS.register(ret);%0A    return ret;%0A  %7D%0A  %0A  @SubscribeEvent%0A  public voi
 d 
-c
 on
-struction. This is a serious programming error.%22
+EntityRegister(RegistryEvent.Register%3CEntityEntry%3E event) %7B
 %0A   
@@ -1627,16 +1627,16 @@
 stance,%0A
+
         
@@ -1653,71 +1653,8 @@
 se);
- // TODO Check if Forge has a registry for this%0A    return ret;
 %0A  %7D

Fix weather rocket register time