cpw.mods.fml.common.network.NetworkRegistry Java Examples

The following examples show how to use cpw.mods.fml.common.network.NetworkRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommonProxy.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void initalize() {
    NetworkRegistry.INSTANCE.registerGuiHandler(Gadomancy.instance, this);

    MinecraftForge.EVENT_BUS.register(EVENT_HANDLER_GOLEM);
    FMLCommonHandler.instance().bus().register(new EventHandlerNetwork());
    EventHandlerWorld worldEventHandler = new EventHandlerWorld();
    MinecraftForge.EVENT_BUS.register(worldEventHandler);
    FMLCommonHandler.instance().bus().register(worldEventHandler);
    MinecraftForge.EVENT_BUS.register(new EventHandlerEntity());

    RegisteredEnchantments.init();
    RegisteredRecipes.init();

    SyncDataHolder.initialize();
    ModSubstitutions.init();

    RegisteredEntities.init();

    DimensionManager.registerProviderType(ModConfig.dimOuterId, WorldProviderTCEldrich.class, true);
    DimensionManager.registerDimension(ModConfig.dimOuterId, ModConfig.dimOuterId);
}
 
Example #2
Source File: MCPacketHandler.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void channelRead0(ChannelHandlerContext ctx, PacketAbstract packet) throws Exception {
	INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();

	switch (FMLCommonHandler.instance().getEffectiveSide()) {
		case CLIENT:
			packet.handleClientSide(NovaMinecraft.proxy.getClientPlayer());
			break;
		case SERVER:
			packet.handleServerSide(((NetHandlerPlayServer) netHandler).playerEntity);
			break;
		default:
			break;
	}

}
 
Example #3
Source File: EtFuturum.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@EventHandler
public void init(FMLInitializationEvent event) {
	NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);

	ModRecipes.init();

	proxy.registerEvents();
	proxy.registerEntities();
	proxy.registerRenderers();

	if (ModEntityList.hasEntitiesWithEggs()) {
		ModEntityList.entity_egg = new ItemEntityEgg();
		GameRegistry.registerItem(ModEntityList.entity_egg, "entity_egg");
		OreDictionary.registerOre("mobEgg", ModEntityList.entity_egg);
	}

	isTinkersConstructLoaded = Loader.isModLoaded("TConstruct");
}
 
Example #4
Source File: TileEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private boolean doDrain(Aspect a, List<WorldCoordinates> coordinates) {
    for (WorldCoordinates coordinate : coordinates) {
        TileEntity sourceTile = worldObj.getTileEntity(coordinate.x, coordinate.y, coordinate.z);
        if ((sourceTile == null) || (!(sourceTile instanceof IAspectSource))) {
            continue;
        }
        if(sourceTile instanceof TileEssentiaCompressor) continue;
        IAspectSource as = (IAspectSource)sourceTile;
        AspectList contains = as.getAspects();
        if(contains == null || contains.visSize() > al.visSize()) continue;
        if(!canAccept(a)) continue;
        if (as.takeFromContainer(a, 1)) {
            PacketHandler.INSTANCE.sendToAllAround(new PacketFXEssentiaSource(xCoord, yCoord + 1, zCoord,
                    (byte)(xCoord - coordinate.x), (byte)(yCoord - coordinate.y + 1), (byte)(zCoord - coordinate.z),
                    a.getColor()), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord + 1, zCoord, 32.0D));
            return true;
        }
    }
    return false;
}
 
Example #5
Source File: RegisteredFamiliarAI_Old.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void tick(int ticksSoFar, World world, EntityPlayer parent, ItemStack itemStack) {
    int rangeInc = ((ItemFamiliar_Old) itemStack.getItem()).getAttackRangeIncrease(itemStack);

    List<EntityLivingBase> lastTargetters = getPotentialTargets(world, parent, rangeInc);
    if(lastTargetters.size() == 0) {
        FamiliarAIController_Old.cleanTargetterList(parent);
        return;
    }
    EntityLivingBase mob = lastTargetters.get(world.rand.nextInt(lastTargetters.size()));
    if(mob.isDead || mob instanceof EntityPlayer) {
        FamiliarAIController_Old.cleanTargetterList(parent);
        return;
    }

    mob.attackEntityFrom(DamageSource.magic, ((ItemFamiliar_Old) itemStack.getItem()).getAttackStrength(itemStack));

    world.playSoundEffect(mob.posX + 0.5, mob.posY + 0.5, mob.posZ + 0.5, "thaumcraft:zap", 0.8F, 1.0F);

    PacketFamiliarBolt bolt = new PacketFamiliarBolt(parent.getCommandSenderName(), (float) mob.posX, (float) mob.posY, (float) mob.posZ, 6, true);
    PacketHandler.INSTANCE.sendToAllAround(bolt, new NetworkRegistry.TargetPoint(mob.worldObj.provider.dimensionId, mob.posX, mob.posY, mob.posZ, 32));
    FamiliarAIController_Old.cleanTargetterList(parent);
}
 
Example #6
Source File: EtFuturum.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	ConfigurationHandler.INSTANCE.init(new File(event.getModConfigurationDirectory().getAbsolutePath() + File.separator + Reference.MOD_ID + ".cfg"));

	GameRegistry.registerWorldGenerator(new EtFuturumWorldGenerator(), 0);

	ModBlocks.init();
	ModItems.init();
	ModEnchantments.init();

	OceanMonument.makeMap();

	NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
	networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MOD_ID);
	networkWrapper.registerMessage(ArmourStandInteractHandler.class, ArmourStandInteractMessage.class, 0, Side.SERVER);
	networkWrapper.registerMessage(BlackHeartParticlesHandler.class, BlackHeartParticlesMessage.class, 1, Side.CLIENT);
	networkWrapper.registerMessage(SetPlayerModelHandler.class, SetPlayerModelMessage.class, 2, Side.CLIENT);
}
 
Example #7
Source File: MainMod.java    From bartworks with MIT License 6 votes vote down vote up
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent postinit) {
    NetworkRegistry.INSTANCE.registerGuiHandler(MainMod.instance, MainMod.GH);
    if (ConfigHandler.BioLab) {
        GTNHBlocks.run();
        for (Map.Entry<BioVatLogicAdder.BlockMetaPair, Byte> pair : BioVatLogicAdder.BioVatGlass.getGlassMap().entrySet()) {
            GT_OreDictUnificator.registerOre("blockGlass" + VN[pair.getValue()], new ItemStack(pair.getKey().getBlock(), 1, pair.getKey().getaByte()));
        }
    }

    BioObjectAdder.regenerateBioFluids();
    if (ConfigHandler.newStuff) {
        WerkstoffLoader.run();
        LocalisationLoader.localiseAll();
    }
}
 
Example #8
Source File: AdvancedMod.java    From AdvancedMod with GNU General Public License v3.0 6 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event){
    ModBlocks.init();
    ModTileEntities.init();
    proxy.preInit();
    GameRegistry.registerWorldGenerator(new WorldGeneratorFlag(), 0);
    NetworkHandler.init();
    DescriptionHandler.init();
    NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
    MinecraftForge.EVENT_BUS.register(new AdvancedModEventHandler());//For registering events from the net.miencraftforge.event package.
    FMLCommonHandler.instance().bus().register(new AdvancedModEventHandler());//For registering events from the cpw.mods.fml.gameevent package.
    FMLInterModComms.sendMessage(Reference.MOD_ID, "camoMineBlacklist", new ItemStack(Blocks.stone));
    FMLInterModComms.sendMessage("Waila", "register", "com.minemaarten.advancedmod.thirdparty.waila.Waila.onWailaCall");
    Log.info("Pre Initialization Complete!");

    if(Loader.isModLoaded("Thaumcraft")) {
        loadThaumcraft();
    }
}
 
Example #9
Source File: Chisel.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
@EventHandler
public void init(FMLInitializationEvent event) {
	Features.init();

	NetworkRegistry.INSTANCE.registerGuiHandler(this, new ChiselGuiHandler());

	addWorldgen(Features.MARBLE, ChiselBlocks.marble, Configurations.marbleAmount);
	addWorldgen(Features.LIMESTONE, ChiselBlocks.limestone, Configurations.limestoneAmount);
	addWorldgen(Features.ANDESITE, ChiselBlocks.andesite, Configurations.andesiteAmount, 40, 100, 0.5);
	addWorldgen(Features.GRANITE, ChiselBlocks.granite, Configurations.graniteAmount, 40, 100, 0.5);
	addWorldgen(Features.DIORITE, ChiselBlocks.diorite, Configurations.dioriteAmount, 40, 100, 0.5);
	GameRegistry.registerWorldGenerator(GeneratorChisel.INSTANCE, 1000);

       EntityRegistry.registerModEntity(EntityChiselSnowman.class, "snowman", 0, this, 80, 1, true);

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

	FMLInterModComms.sendMessage("Waila", "register", "com.cricketcraft.chisel.compat.WailaCompat.register");
}
 
Example #10
Source File: PacketPipeline.java    From NBTEdit with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
    ByteBuf payload = msg.payload();
    byte discriminator = payload.readByte();
    Class<? extends AbstractPacket> clazz = this.packets.get(discriminator);

    AbstractPacket pkt = clazz.newInstance();
    pkt.decodeInto(ctx, payload.slice());

    switch (FMLCommonHandler.instance().getEffectiveSide()) {
        case CLIENT:
            pkt.handleClientSide(this.getClientPlayer());
            break;
        case SERVER:
            INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
            pkt.handleServerSide(((NetHandlerPlayServer) netHandler).playerEntity);
            break;
        default:
        	break;
    }

    out.add(pkt);
}
 
Example #11
Source File: ASMessagePipeline.java    From archimedes-ships with MIT License 6 votes vote down vote up
@Override
protected void encode(ChannelHandlerContext ctx, ASMessage msg, List<Object> out) throws Exception
{
	ByteBuf buffer = Unpooled.buffer();
	Class<? extends ASMessage> clazz = msg.getClass();
	if (!packets.contains(msg.getClass()))
	{
		throw new NullPointerException("No Packet Registered for: " + msg.getClass().getCanonicalName());
	}
	
	byte discriminator = (byte) packets.indexOf(clazz);
	buffer.writeByte(discriminator);
	try
	{
		msg.encodeInto(ctx, buffer);
	} catch (IOException e)
	{
		e.printStackTrace();
		throw e;
	}
	FMLProxyPacket proxyPacket = new FMLProxyPacket(buffer, ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get());
	out.add(proxyPacket);
}
 
Example #12
Source File: ElectroMagicTools.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void load(FMLInitializationEvent event) {
    ElectroMagicTools.logger.info(localize("console.EMT.init.begin"));

    ElectroMagicTools.logger.info(localize("console.EMT.init.loadProxies"));
    proxy.load();
    ElectroMagicTools.logger.info(localize("console.EMT.init.mobDrops"));
    MinecraftForge.EVENT_BUS.register(new EntityEventHandler());
    ElectroMagicTools.logger.info(localize("console.EMT.init.loot"));
    DungeonChestGenerator.generateLoot();

    ElectroMagicTools.logger.info(localize("console.EMT.init.entities"));
    BaseEntityRegistry.registerEMTEntities();
    ElectroMagicTools.logger.info(localize("console.EMT.init.guiHandler"));
    NetworkRegistry.INSTANCE.registerGuiHandler(this, proxy);

    ElectroMagicTools.logger.info(localize("console.EMT.init.end"));
}
 
Example #13
Source File: ItemStreamChainsaw.java    From Electro-Magic-Tools with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) {
    World world = player.worldObj;
    Block bi = world.getBlock(x, y, z);
    if ((!player.isSneaking()) && (Utils.isWoodLog(world, x, y, z))) {
        if (!world.isRemote) {
            BlockUtils.breakFurthestBlock(world, x, y, z, bi, player);
            PacketHandler.INSTANCE.sendToAllAround(new PacketFXBlockBubble(x, y, z, new Color(0.33F, 0.33F, 1.0F).getRGB()), new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32.0D));

            world.playSoundEffect(x, y, z, "thaumcraft:bubble", 0.15F, 1.0F);
        }
        ElectricItem.manager.use(itemstack, cost, player);
        return true;
    }
    return super.onBlockStartBreak(itemstack, x, y, z, player);
}
 
Example #14
Source File: TileEntityBeefBase.java    From BigReactors with MIT License 6 votes vote down vote up
@Override
public boolean setFacing(int newFacing) {
	if(facing == newFacing) { return false; }

	if(!allowYAxisFacing() && (newFacing == ForgeDirection.UP.ordinal() || newFacing == ForgeDirection.DOWN.ordinal())) {
		return false;
	}
	
	facing = newFacing;
	if(!worldObj.isRemote) {
           CommonPacketHandler.INSTANCE.sendToAllAround(new DeviceUpdateRotationMessage(xCoord, yCoord, zCoord, facing), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50));
           this.markChunkDirty();
	}

	this.callNeighborBlockChange();
	return true;
}
 
Example #15
Source File: CommonProxy.java    From BigReactors with MIT License 6 votes vote down vote up
public void init() {
	BigReactors.registerTileEntities();
	
	CommonPacketHandler.init();

	NetworkRegistry.INSTANCE.registerGuiHandler(BRLoader.instance, new BigReactorsGUIHandler());
	BigReactors.tickHandler = new BigReactorsTickHandler();
	FMLCommonHandler.instance().bus().register(BigReactors.tickHandler);
       FMLCommonHandler.instance().bus().register(new MultiblockServerTickHandler());
	
	sendInterModAPIMessages();

	if(Loader.isModLoaded("VersionChecker")) {
		FMLInterModComms.sendRuntimeMessage(BRLoader.MOD_ID, "VersionChecker", "addVersionCheck", "http://big-reactors.com/version.json");
	}
}
 
Example #16
Source File: BlockEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int these, float are, float some, float variables) { //LUL side, hitx, hity, hitz
    if(world.isRemote) return false;
    TileEntity te = world.getTileEntity(x, y, z);
    if(te == null || !(te instanceof TileEssentiaCompressor)) return false;
    if(((TileEssentiaCompressor) te).isMultiblockFormed()) {
        if(!((TileEssentiaCompressor) te).isMasterTile()) {
            int yOffset = ((TileEssentiaCompressor) te).getMultiblockYIndex();
            return RegisteredBlocks.blockEssentiaCompressor.onBlockActivated(world, x, y - yOffset, z, player, these, are, some, variables);
        }
    } else {
        ItemStack heldItem = player.getHeldItem();
        if(heldItem != null && heldItem.getItem() instanceof ItemWandCasting &&
                ResearchManager.isResearchComplete(player.getCommandSenderName(), SimpleResearchItem.getFullName("ESSENTIA_COMPRESSOR"))) {
            ChunkCoordinates lowest = findLowestCompressorBlock(world, x, y, z);
            boolean canForm = lowest != null && isMuliblockPossible(world, lowest);
            if(canForm && ThaumcraftApiHelper.consumeVisFromWandCrafting(player.getCurrentEquippedItem(), player, RegisteredRecipes.costsCompressorMultiblock, true)) {
                int multiblockID = TileEssentiaCompressor.getAndIncrementNewMultiblockId();
                TileEssentiaCompressor compressor = (TileEssentiaCompressor) world.getTileEntity(lowest.posX, lowest.posY, lowest.posZ);
                compressor.setInMultiblock(true, 0, multiblockID);
                PacketStartAnimation pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, lowest.posX, lowest.posY, lowest.posZ);
                NetworkRegistry.TargetPoint point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, lowest.posX, lowest.posY, lowest.posZ, 32);
                PacketHandler.INSTANCE.sendToAllAround(pkt, point);
                compressor = (TileEssentiaCompressor) world.getTileEntity(lowest.posX, lowest.posY + 1, lowest.posZ);
                compressor.setInMultiblock(false, 1, multiblockID);
                pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, lowest.posX, lowest.posY + 1, lowest.posZ);
                point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, lowest.posX, lowest.posY + 1, lowest.posZ, 32);
                PacketHandler.INSTANCE.sendToAllAround(pkt, point);
                compressor = (TileEssentiaCompressor) world.getTileEntity(lowest.posX, lowest.posY + 2, lowest.posZ);
                compressor.setInMultiblock(false, 2, multiblockID);
                pkt = new PacketStartAnimation(PacketStartAnimation.ID_SPARKLE_SPREAD, lowest.posX, lowest.posY + 2, lowest.posZ);
                point = new NetworkRegistry.TargetPoint(world.provider.dimensionId, lowest.posX, lowest.posY + 2, lowest.posZ, 32);
                PacketHandler.INSTANCE.sendToAllAround(pkt, point);
            }
        }
    }
    return false;
}
 
Example #17
Source File: CommonProxy.java    From archimedes-ships with MIT License 5 votes vote down vote up
public void registerEventHandlers()
{
	NetworkRegistry.INSTANCE.registerGuiHandler(ArchimedesShipMod.instance, new ASGuiHandler());
	
	playerTicker = new CommonPlayerTicker();
	FMLCommonHandler.instance().bus().register(playerTicker);
	MinecraftForge.EVENT_BUS.register(hookContainer = getHookContainer());
}
 
Example #18
Source File: LookingGlass.java    From LookingGlass with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void preinit(FMLPreInitializationEvent event) {
	//Initialize the packet handling
	LookingGlassPacketManager.registerPacketHandler(new PacketCreateView(), (byte) 10);
	LookingGlassPacketManager.registerPacketHandler(new PacketCloseView(), (byte) 11);
	LookingGlassPacketManager.registerPacketHandler(new PacketWorldInfo(), (byte) 100);
	LookingGlassPacketManager.registerPacketHandler(new PacketChunkInfo(), (byte) 101);
	LookingGlassPacketManager.registerPacketHandler(new PacketTileEntityNBT(), (byte) 102);
	LookingGlassPacketManager.registerPacketHandler(new PacketRequestWorldInfo(), (byte) 200);
	LookingGlassPacketManager.registerPacketHandler(new PacketRequestChunk(), (byte) 201);
	LookingGlassPacketManager.registerPacketHandler(new PacketRequestTE(), (byte) 202);

	LookingGlassPacketManager.bus = NetworkRegistry.INSTANCE.newEventDrivenChannel(LookingGlassPacketManager.CHANNEL);
	LookingGlassPacketManager.bus.register(new LookingGlassPacketManager());

	// Load our basic configs
	ModConfigs.loadConfigs(new Configuration(event.getSuggestedConfigurationFile()));

	// Here we use the recommended config file to establish a good place to put a log file for any proxy world error logs.  Used primarily to log the full errors when ticking or rendering proxy worlds. 
	File configroot = event.getSuggestedConfigurationFile().getParentFile();
	// Main tick handler. Handles FML events.
	FMLCommonHandler.instance().bus().register(new LookingGlassEventHandler(new File(configroot.getParentFile(), "logs/proxyworlds.log")));
	// Forge event handler
	MinecraftForge.EVENT_BUS.register(new LookingGlassForgeEventHandler());

	// Initialize the API provider system.  Beware, this way be dragons.
	APIProviderImpl.init();
}
 
Example #19
Source File: EventHandlerPneumaticCraft.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Used by PneumaticHelmet
 * @param event
 */
@SubscribeEvent
public void onMobTargetSet(LivingSetAttackTargetEvent event){
    if(event.entity instanceof EntityCreature) {
        if(!event.entity.worldObj.isRemote) {
            NetworkHandler.sendToAllAround(new PacketSetMobTarget((EntityCreature)event.entity, event.target), new NetworkRegistry.TargetPoint(event.entity.worldObj.provider.dimensionId, event.entity.posX, event.entity.posY, event.entity.posZ, TileEntityConstants.PACKET_UPDATE_DISTANCE));
        } else {
            warnPlayerIfNecessary(event);
        }
    }
}
 
Example #20
Source File: CommonHUDHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private void handleHacking(EntityPlayer player){
    if(hackedBlock != null) {
        IHackableBlock hackableBlock = HackableHandler.getHackableForCoord(hackedBlock, player);
        if(hackableBlock != null) {
            if(++hackTime >= hackableBlock.getHackTime(hackedBlock.world, hackedBlock.x, hackedBlock.y, hackedBlock.z, player)) {
                hackableBlock.onHackFinished(player.worldObj, hackedBlock.x, hackedBlock.y, hackedBlock.z, player);
                PneumaticCraft.proxy.getHackTickHandler().trackBlock(hackedBlock, hackableBlock);
                NetworkHandler.sendToAllAround(new PacketHackingBlockFinish(hackedBlock), player.worldObj);
                setHackedBlock(null);
            }
        } else {
            setHackedBlock(null);
        }
    } else if(hackedEntity != null) {
        IHackableEntity hackableEntity = HackableHandler.getHackableForEntity(hackedEntity, player);
        if(hackableEntity != null) {
            if(++hackTime >= hackableEntity.getHackTime(hackedEntity, player)) {
                hackableEntity.onHackFinished(hackedEntity, player);
                PneumaticCraft.proxy.getHackTickHandler().trackEntity(hackedEntity, hackableEntity);
                NetworkHandler.sendToAllAround(new PacketHackingEntityFinish(hackedEntity), new NetworkRegistry.TargetPoint(hackedEntity.worldObj.provider.dimensionId, hackedEntity.posX, hackedEntity.posY, hackedEntity.posZ, 64));
                setHackedEntity(null);
            }
        } else {
            setHackedEntity(null);
        }
    }
}
 
Example #21
Source File: TileEntityBeefBase.java    From BigReactors with MIT License 5 votes vote down vote up
private void sendExposureUpdate() {
	if(!this.worldObj.isRemote) {
		// Send unrotated, as the rotation will be re-applied on the client
           CommonPacketHandler.INSTANCE.sendToAllAround(new DeviceUpdateExposureMessage(xCoord, yCoord, zCoord, exposures), new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50));
           this.markChunkDirty();
	}
	else {
		// Re-render block on client
		worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
	}

	this.callNeighborTileChange();
	this.callNeighborBlockChange();
}
 
Example #22
Source File: PacketHackingEntityStart.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void handleServerSide(PacketHackingEntityStart message, EntityPlayer player){
    Entity entity = player.worldObj.getEntityByID(message.entityId);
    if(entity != null) {
        CommonHUDHandler.getHandlerForPlayer(player).setHackedEntity(entity);
        NetworkHandler.sendToAllAround(message, new NetworkRegistry.TargetPoint(entity.worldObj.provider.dimensionId, entity.posX, entity.posY, entity.posZ, 64));
    }
}
 
Example #23
Source File: PacketPipeline.java    From NBTEdit with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void encode(ChannelHandlerContext ctx, AbstractPacket msg, List<Object> out) throws Exception {
    ByteBuf buffer = Unpooled.buffer();
    Class<? extends AbstractPacket> clazz = msg.getClass();
    
    byte discriminator = (byte) this.packets.indexOf(clazz);
    buffer.writeByte(discriminator);
    msg.encodeInto(ctx, buffer);
    FMLProxyPacket proxyPacket = new FMLProxyPacket(buffer.copy(), ctx.channel().attr(NetworkRegistry.FML_CHANNEL).get());
    out.add(proxyPacket);
}
 
Example #24
Source File: CommonProxy.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
public void registerHandlers() {
    SimplyJetpacks.logger.info("Registering handlers");
    NetworkRegistry.INSTANCE.registerGuiHandler(SimplyJetpacks.instance, new GuiHandler());
    FMLCommonHandler.instance().bus().register(new SyncHandler());
    FMLCommonHandler.instance().bus().register(new PlatingReturnHandler());
    MinecraftForge.EVENT_BUS.register(new EntityInteractHandler());
    MinecraftForge.EVENT_BUS.register(new LivingTickHandler());
}
 
Example #25
Source File: GardenStuff.java    From GardenCollection with MIT License 5 votes vote down vote up
@Mod.EventHandler
public void init (FMLInitializationEvent event) {
    proxy.registerRenderers();
    NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());

    integration.init();
}
 
Example #26
Source File: GardenCore.java    From GardenCollection with MIT License 5 votes vote down vote up
@Mod.EventHandler
public void init (FMLInitializationEvent event) {
    proxy.registerRenderers();
    NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());

    MinecraftForge.EVENT_BUS.register(new ForgeEventHandler());

    integration.init();
    GardenCoreAPI.instance().registerBonemealHandler(new VanillaBonemealHandler());
}
 
Example #27
Source File: GardenContainers.java    From GardenCollection with MIT License 5 votes vote down vote up
@Mod.EventHandler
public void init (FMLInitializationEvent event) {
    proxy.registerRenderers();
    NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());

    for (int j = 0; j < config.getPatternLocationCount(); j++)
        ChestGenHooks.addItem(config.getPatternLocation(j), new WeightedRandomChestContent(items.potteryPatternDirty, 0, 1, 1, config.getPatternLocationRarity(j)));

    VillagerTradeHandler.instance().load();
}
 
Example #28
Source File: NetworkHandler.java    From AdvancedMod with GNU General Public License v3.0 5 votes vote down vote up
public static void init(){
    INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MOD_ID);

    INSTANCE.registerMessage(MessageExplode.class, MessageExplode.class, 0, Side.SERVER);
    INSTANCE.registerMessage(MessageHandleGuiButtonPress.class, MessageHandleGuiButtonPress.class, 1, Side.SERVER);
    INSTANCE.registerMessage(MessageHandleTextUpdate.class, MessageHandleTextUpdate.class, 2, Side.SERVER);
    INSTANCE.registerMessage(MessageHandleTextUpdate.class, MessageHandleTextUpdate.class, 3, Side.CLIENT);
}
 
Example #29
Source File: FamiliarController.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void attack(EntityLivingBase toAttack, double damage, int boltType) {
    toAttack.attackEntityFrom(DamageSource.magic, (float) damage);
    toAttack.worldObj.playSoundEffect(toAttack.posX + 0.5, toAttack.posY + 0.5, toAttack.posZ + 0.5, "thaumcraft:zap", 0.8F, 1.0F);
    PacketFamiliarBolt bolt = new PacketFamiliarBolt(owningPlayer.getCommandSenderName(), (float) toAttack.posX, (float) toAttack.posY, (float) toAttack.posZ, boltType, true);
    PacketHandler.INSTANCE.sendToAllAround(bolt, new NetworkRegistry.TargetPoint(toAttack.worldObj.provider.dimensionId, owningPlayer.posX,
            owningPlayer.posY, owningPlayer.posZ, 16));
}
 
Example #30
Source File: MainRegistry.java    From NewHorizonsCoreMod with GNU General Public License v3.0 5 votes vote down vote up
private void InitAdditionalBlocks()
{
    GameRegistry.registerBlock(_mBlockBabyChest, ItemBlockBabyChest.class, "BabyChest");
    GameRegistry.addShapelessRecipe(new ItemStack(_mBlockBabyChest, 9), new ItemStack(Blocks.chest, 1, 0));
    GameRegistry.registerTileEntity(TileEntityBabyChest.class, "teBabyChest");

    NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());

    proxy.registerRenderInfo();
}