public static void init() {
   networkWrapper.registerMessage(
       GraveDeathMessageToServer.class, GraveDeathMessageToServer.class, 0, Side.SERVER);
   networkWrapper.registerMessage(
       AltarMessageToServer.class, AltarMessageToServer.class, 1, Side.SERVER);
   networkWrapper.registerMessage(
       AltarMessageToClient.class, AltarMessageToClient.class, 2, Side.CLIENT);
 }
Esempio n. 2
0
 public static void init() {
   int id = 0;
   HANDLER.registerMessage(
       PacketBotaniaEffect.Handler.class, PacketBotaniaEffect.class, id++, Side.CLIENT);
   HANDLER.registerMessage(
       PacketLeftClick.Handler.class, PacketLeftClick.class, id++, Side.SERVER);
   HANDLER.registerMessage(PacketDodge.Handler.class, PacketDodge.class, id++, Side.SERVER);
   HANDLER.registerMessage(PacketDodge.Handler.class, PacketDodge.class, id++, Side.SERVER);
   HANDLER.registerMessage(PacketJump.Handler.class, PacketJump.class, id++, Side.SERVER);
 }
Esempio n. 3
0
 public static void sendToClient(IMessage toSend, EntityPlayer player) {
   if (player == null) {
     System.out.println("null player");
     return;
   }
   packetPipeline.sendTo(toSend, (EntityPlayerMP) player);
 }
Esempio n. 4
0
  @EventHandler
  public void init(FMLInitializationEvent event) throws Exception {
    packetPipeline.registerMessage(
        AnvilTechniquePacket.Handler.class, AnvilTechniquePacket.class, 0, Side.SERVER);
    packetPipeline.registerMessage(
        ChunkPutNbtPacket.Handler.class, ChunkPutNbtPacket.class, 1, Side.CLIENT);
    packetPipeline.registerMessage(
        ChunkRemoveNbtPacket.Handler.class, ChunkRemoveNbtPacket.class, 2, Side.CLIENT);
    packetPipeline.registerMessage(
        SoundEffectToServerPacket.Handler.class, SoundEffectToServerPacket.class, 3, Side.SERVER);
    packetPipeline.registerMessage(
        MechanicalNetworkNBTPacket.ClientHandler.class,
        MechanicalNetworkNBTPacket.class,
        4,
        Side.CLIENT);
    packetPipeline.registerMessage(
        StartMeteorShowerPacket.ClientHandler.class, StartMeteorShowerPacket.class, 5, Side.CLIENT);
    packetPipeline.registerMessage(
        WorldDataPacket.ClientHandler.class, WorldDataPacket.class, 6, Side.CLIENT);
    packetPipeline.registerMessage(
        CarpentryTechniquePacket.Handler.class, CarpentryTechniquePacket.class, 7, Side.SERVER);

    BlocksVC.init();
    ItemsVC.init();
    AchievementsVC.init();

    FMLCommonHandler.instance().bus().register(this);
    MinecraftForge.EVENT_BUS.register(this);

    proxy.registerTileEntities();

    NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);

    System.out.println("vcraft has init.");

    GameRegistry.registerWorldGenerator(new WorldGenDeposits(), 4);

    WorldType.DEFAULT = WorldTypeVC.DEFAULT;
    WorldType.FLAT = WorldTypeVC.FLAT;

    // DimensionManager.unregisterDimension(-1);
    DimensionManager.unregisterDimension(0);
    DimensionManager.unregisterDimension(1);

    // DimensionManager.unregisterProviderType(-1);
    DimensionManager.unregisterProviderType(0);
    DimensionManager.unregisterProviderType(1);
    DimensionManager.registerProviderType(0, WorldProviderVC.class, true);
    DimensionManager.registerProviderType(1, WorldProviderVC.class, false);

    // DimensionManager.registerDimension(-1, -1);
    DimensionManager.registerDimension(0, 0);
    DimensionManager.registerDimension(1, 1);

    proxy.init(event);
  }
Esempio n. 5
0
  @SubscribeEvent
  public void entityJoin(EntityJoinWorldEvent evt) {
    if (!evt.world.isRemote && evt.entity instanceof EntityPlayerMP) {

      packetPipeline.sendTo(new WorldDataPacket(evt.world.getSeed()), (EntityPlayerMP) evt.entity);
    }

    if (evt.entity instanceof EntityZombie) {
      if (((EntityZombie) evt.entity).isChild()) {
        ((EntityZombie) evt.entity).setChild(false);
      }
    }
  }
Esempio n. 6
0
  @SubscribeEvent
  public void onServerTick(TickEvent.WorldTickEvent event) {
    if (FMLCommonHandler.instance().getMinecraftServerInstance() == null
        || event.phase == TickEvent.Phase.END
        || event.world.provider.getDimensionId() != 0) return;

    if (MechnicalNetworkManager.getNetworkManagerForWorld(event.world) == null) {

      VCraftWorldSavedData worlddata = getOrCreateWorldData(event.world);
      worlddata.setWorld(event.world);
      MechnicalNetworkManager.addManager(event.world, worlddata.getNetworks());
    }

    long worldtime = event.world.getTotalWorldTime();
    long timeofday = event.world.getWorldTime() / 24000L;

    if (worldtime % 6000L == 0) {
      VintageCraftMobTweaker.setSpawnCap(
          EnumCreatureType.MONSTER,
          VintageCraftMobTweaker.spawnCapByDay(worldtime / 24000L, event.world.getDifficulty()));
      VintageCraftConfig.saveConfig();
    }

    int moonphase = event.world.provider.getMoonPhase(event.world.getWorldTime());
    boolean cannotSleeptonight =
        moonphase == 0
            || (event.world.getDifficulty() == EnumDifficulty.HARD
                && (moonphase == 7 || moonphase == 1));

    if (cannotSleeptonight) {
      for (Object obj : event.world.playerEntities) {
        EntityPlayer player = (EntityPlayer) obj;
        if (player.isPlayerSleeping() && getSleepTimer(player) > 80) {
          player.wakeUpPlayer(true, true, true);
          player.addChatMessage(
              new ChatComponentText(
                  "You tried to fall sleep, but something is keeping you awake tonight."));
        }
      }
    }

    long day = worldtime / 24000L;
    if (day > 0 && day % 20 == 0 && timeofday % 24000L == 14000) {
      packetPipeline.sendToAll(new StartMeteorShowerPacket(10000));
      MinecraftServer.getServer()
          .getConfigurationManager()
          .sendChatMsg(new ChatComponentText("Something strange is happening in the night sky"));
    }
  }
Esempio n. 7
0
  /** Send message to all within 64 blocks that have this chunk loaded */
  public static void sendToNearby(World world, BlockPos pos, IMessage toSend) {
    if (world instanceof WorldServer) {
      WorldServer ws = (WorldServer) world;

      for (EntityPlayer player : ws.playerEntities) {
        EntityPlayerMP playerMP = (EntityPlayerMP) player;

        if (playerMP.getDistanceSq(pos) < 64 * 64
            && ws.getPlayerChunkMap()
                .isPlayerWatchingChunk(playerMP, pos.getX() >> 4, pos.getZ() >> 4)) {
          HANDLER.sendTo(toSend, playerMP);
        }
      }
    }
  }
Esempio n. 8
0
  public static void init() {
    // Register Network Messages
    INSTANCE.registerMessage(
        MessageSyncRecipeChip.class, MessageSyncRecipeChip.class, ID++, Side.SERVER);
    //        INSTANCE.registerMessage(MessageSyncIngredients.class, MessageSyncIngredients.class,
    // ID++, Side.SERVER);
    //        INSTANCE.registerMessage(MessageUpdateMissingItems.class,
    // MessageUpdateMissingItems.class, ID++, Side.SERVER);
    //        INSTANCE.registerMessage(MessageSwitchItems.class, MessageSwitchItems.class, ID++,
    // Side.SERVER);
    //        INSTANCE.registerMessage(MessageSwitchGui.class, MessageSwitchGui.class, ID++,
    // Side.SERVER);
    //        INSTANCE.registerMessage(MessageNameCrafter.class, MessageNameCrafter.class, ID++,
    // Side.SERVER);
    //        INSTANCE.registerMessage(MessageNameCrafterClient.class,
    // MessageNameCrafterClient.class, ID++, Side.CLIENT);

  }
Esempio n. 9
0
 public static void sendToServer(IMessage msg) {
   HANDLER.sendToServer(msg);
 }
Esempio n. 10
0
 public static void sendTo(EntityPlayerMP playerMP, IMessage toSend) {
   HANDLER.sendTo(toSend, playerMP);
 }
Esempio n. 11
0
 public static void sendToServer(IMessage toSend) {
   packetPipeline.sendToServer(toSend);
 }
Esempio n. 12
0
 public static void sendToAllNear(IMessage toSend, Vector3 point, int dimID, double distance) {
   packetPipeline.sendToAllAround(
       toSend, new TargetPoint(dimID, point.x, point.y, point.z, distance));
 }
Esempio n. 13
0
 public static void sendToAll(IMessage toSend) {
   packetPipeline.sendToAll(toSend);
 }
Esempio n. 14
0
 @SuppressWarnings("unchecked")
 private static void registerMessage(Class packet, Class message) {
   net.registerMessage(packet, message, nextPacketId, Side.CLIENT);
   net.registerMessage(packet, message, nextPacketId, Side.SERVER);
   nextPacketId++;
 }