cpw.mods.fml.common.network.simpleimpl.IMessage Java Examples

The following examples show how to use cpw.mods.fml.common.network.simpleimpl.IMessage. 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: PacketTCNotificationText.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public IMessage onMessage(PacketTCNotificationText message, MessageContext ctx) {
    if(message.text == null) return null;
    String translated = StatCollector.translateToLocal(message.text);
    ResourceLocation image = null;
    int color = message.color;
    Aspect a = Aspect.getAspect(message.additionalInfo);
    if(a != null) {
        image = a.getImage();
        color = a.getColor();
    }
    if(message.text.equals("gadomancy.aura.research.unlock")) {
        if(a != null) {
            translated = EnumChatFormatting.GREEN + String.format(translated, a.getName());
        } else {
            translated = EnumChatFormatting.GREEN + String.format(translated, message.additionalInfo);
        }
    }
    color &= 0xFFFFFF;
    PlayerNotifications.addNotification(translated, image, color);
    return null;
}
 
Example #2
Source File: MessageModKey.java    From SimplyJetpacks with MIT License 6 votes vote down vote up
@Override
public IMessage onMessage(MessageModKey msg, MessageContext ctx) {
    EntityPlayer entityPlayer = ctx.getServerHandler().playerEntity;
    
    if (entityPlayer != null) {
        ItemStack armor = entityPlayer.inventory.armorItemInSlot(2);
        if (armor != null && armor.getItem() instanceof IControllableArmor) {
            if (msg.keyId < 0 || msg.keyId >= ModKey.values().length) {
                return null;
            }
            ModKey key = ModKey.values()[msg.keyId];
            ((IControllableArmor) armor.getItem()).onKeyPressed(armor, entityPlayer, key, msg.showInChat);
        }
    }
    return null;
}
 
Example #3
Source File: PacketAnimationAbsorb.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(PacketAnimationAbsorb p, MessageContext ctx) {
    Block b;
    int md;
    if(p.bid != -1 && p.bmd != -1) {
        b = Block.getBlockById(p.bid);
        md = p.bmd;
    } else {
        b = Minecraft.getMinecraft().theWorld.getBlock(p.targetX, p.targetY, p.targetZ);
        md = Minecraft.getMinecraft().theWorld.getBlockMetadata(p.targetX, p.targetY, p.targetZ);
    }
    MultiTickEffectDispatcher.VortexDigInfo info =
            new MultiTickEffectDispatcher.VortexDigInfo(Minecraft.getMinecraft().theWorld.provider.dimensionId, p.x, p.y, p.z, p.targetX, p.targetY, p.targetZ, b, md, p.tickCap);
    MultiTickEffectDispatcher.registerVortexDig(info);
    return null;
}
 
Example #4
Source File: DeviceChangeExposureMessage.java    From BigReactors with MIT License 6 votes vote down vote up
@Override
protected IMessage handleMessage(DeviceChangeExposureMessage message, MessageContext ctx, TileEntity te) {
	if(te instanceof TileEntityBeefBase) {
		TileEntityBeefBase beefTe = (TileEntityBeefBase)te;
		if(message.increment) {
			beefTe.incrSide(message.side);
		}
		else {
			beefTe.decrSide(message.side);
		}
	}
	else {
		BRLog.warning("Received SideChangeMessage for TE at %d, %d, %d, but it was not a TE with an iterable side exposure!", te.xCoord, te.yCoord, te.zCoord);
	}
	return null;
}
 
Example #5
Source File: ControlRodChangeInsertionMessage.java    From BigReactors with MIT License 6 votes vote down vote up
@Override
protected IMessage handleMessage(ControlRodChangeInsertionMessage message, 
								MessageContext ctx, TileEntity te) {
	if(te instanceof TileEntityReactorControlRod) {
		TileEntityReactorControlRod rod = (TileEntityReactorControlRod)te;
		int newInsertion = rod.getControlRodInsertion() + (short)message.amount;
		if(message.changeAll && rod.getReactorController() != null)
		{
			rod.getReactorController().setAllControlRodInsertionValues(newInsertion);
		}
		else {
			rod.setControlRodInsertion((short)newInsertion);
		}
	}
	return null;
}
 
Example #6
Source File: ReactorMessageServer.java    From BigReactors with MIT License 6 votes vote down vote up
@Override
protected IMessage handleMessage(M message, MessageContext ctx, TileEntity te) {
	if(te instanceof TileEntityReactorPartBase) {
		MultiblockReactor reactor = ((TileEntityReactorPartBase)te).getReactorController();
		if(reactor != null) {
			return handleMessage(message, ctx, reactor);
		}
		else {
			BRLog.error("Received ReactorMessageServer for a reactor part @ %d, %d, %d which has no attached reactor", te.xCoord, te.yCoord, te.zCoord);
		}
	}
	else {
		BRLog.error("Received ReactorMessageServer for a non-reactor-part block @ %d, %d, %d", message.x, message.y, message.z);
	}
	return null;
}
 
Example #7
Source File: TurbineMessageServer.java    From BigReactors with MIT License 6 votes vote down vote up
@Override
protected IMessage handleMessage(M message, MessageContext ctx, TileEntity te) {
	if(te instanceof TileEntityTurbinePartBase) {
		MultiblockTurbine reactor = ((TileEntityTurbinePartBase)te).getTurbine();
		if(reactor != null) {
			return handleMessage(message, ctx, reactor);
		}
		else {
			BRLog.error("Received TurbineMessageServer for a turbine part @ %d, %d, %d which has no attached turbine", te.xCoord, te.yCoord, te.zCoord);
		}
	}
	else {
		BRLog.error("Received TurbineMessageServer for a non-turbine-part block @ %d, %d, %d", message.x, message.y, message.z);
	}
	return null;
}
 
Example #8
Source File: TurbineMessageClient.java    From BigReactors with MIT License 6 votes vote down vote up
@Override
protected IMessage handleMessage(M message, MessageContext ctx, TileEntity te) {
	if(te instanceof TileEntityTurbinePartBase) {
		MultiblockTurbine reactor = ((TileEntityTurbinePartBase)te).getTurbine();
		if(reactor != null) {
			return handleMessage(message, ctx, reactor);
		}
		else {
			BRLog.error("Received TurbineMessageClient for a turbine part @ %d, %d, %d which has no attached turbine", te.xCoord, te.yCoord, te.zCoord);
		}
	}
	else {
		BRLog.error("Received TurbineMessageClient for a non-turbine-part block @ %d, %d, %d", message.x, message.y, message.z);
	}
	return null;
}
 
Example #9
Source File: ReactorMessageClient.java    From BigReactors with MIT License 6 votes vote down vote up
@Override
protected IMessage handleMessage(M message, MessageContext ctx, TileEntity te) {
	if(te instanceof TileEntityReactorPartBase) {
		MultiblockReactor reactor = ((TileEntityReactorPartBase)te).getReactorController();
		if(reactor != null) {
			return handleMessage(message, ctx, reactor);
		}
		else {
			BRLog.error("Received ReactorMessageClient for a reactor part @ %d, %d, %d which has no attached reactor", te.xCoord, te.yCoord, te.zCoord);
		}
	}
	else {
		BRLog.error("Received ReactorMessageClient for a non-reactor-part block @ %d, %d, %d", message.x, message.y, message.z);
	}
	return null;
}
 
Example #10
Source File: PacketTCWispyLine.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public IMessage onMessage(PacketTCWispyLine p, MessageContext ctx) {
    MultiTickEffectDispatcher.FloatyLineInfo info =
            new MultiTickEffectDispatcher.FloatyLineInfo(p.dimId, p.pedestalX, p.pedestalY, p.pedestalZ,
                    p.originX, p.originY, p.originZ, p.tickCap, p.colorAsInt);
    MultiTickEffectDispatcher.registerFloatyLine(info);
    return null;
}
 
Example #11
Source File: PacketTCNodeBolt.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(PacketTCNodeBolt p, MessageContext ctx) {
    FXLightningBolt bolt = new FXLightningBolt(Minecraft.getMinecraft().theWorld, p.x, p.y, p.z, p.targetX, p.targetY, p.targetZ, Minecraft.getMinecraft().theWorld.rand.nextLong(), 10, 4.0F, 5);
    bolt.defaultFractal();
    bolt.setType(p.type);
    bolt.finalizeBolt();
    return null;
}
 
Example #12
Source File: ControlRodChangeNameMessage.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
protected IMessage handleMessage(ControlRodChangeNameMessage message, MessageContext ctx, TileEntity te) {
	if(te instanceof TileEntityReactorControlRod) {
		((TileEntityReactorControlRod)te).setName(message.name);
	}
	return null;
}
 
Example #13
Source File: MessageChiselMode.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public IMessage onMessage(MessageChiselMode message, MessageContext ctx) {
	ItemStack stack = ctx.getServerHandler().playerEntity.getCurrentEquippedItem();
	if (stack != null && stack.getItem() instanceof IChiselItem) {
		if (stack.getItem() instanceof IAdvancedChisel) {
			General.setChiselMode(stack, ((IAdvancedChisel) stack.getItem()).getMode(stack, message.mode));
		} else {
			General.setChiselMode(stack, ChiselMode.valueOf(message.mode));
		}
	}
	return null;
}
 
Example #14
Source File: DeviceUpdateRotationMessage.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
public IMessage handleMessage(DeviceUpdateRotationMessage message, MessageContext ctx, TileEntity te) {
    if(te instanceof IReconfigurableFacing) {
        ((IReconfigurableFacing)te).setFacing(message.newOrientation);
        getWorld(ctx).markBlockForUpdate(message.x, message.y, message.z);
    }
    return null;
}
 
Example #15
Source File: MessagePresentConnect.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public IMessage onMessage(MessagePresentConnect message, MessageContext ctx) {
	TileEntity te = message.getTileEntity(ctx);
	if (te instanceof TileEntityPresent) {
		if (message.connect) {
			((TileEntityPresent) te).connectTo(message.dir);
		} else {
			((TileEntityPresent) te).disconnect(message.preserveDir);
		}
	}
	return null;
}
 
Example #16
Source File: MessageAutoChisel.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
public IMessage onMessage(MessageAutoChisel message, MessageContext ctx) {

			TileEntity te = message.getTileEntity(ctx);
			if (te instanceof TileEntityAutoChisel) {
				((TileEntityAutoChisel) te).doChiselAnim(message.base, message.chiseled, message.playSound, message.breakChisel);
			}
			return null;
		}
 
Example #17
Source File: MessageSlotUpdate.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public IMessage onMessage(MessageSlotUpdate message, MessageContext ctx) {
	TileEntity te = Chisel.proxy.getClientWorld().getTileEntity(message.x, message.y, message.z);
	if (te != null && te instanceof IInventory) {
		((IInventory) te).setInventorySlotContents(message.slot, message.stack);
	}
	return null;
}
 
Example #18
Source File: MessageChiselSound.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public IMessage onMessage(MessageChiselSound message, MessageContext ctx) {
	String sound = ItemChisel.carving.getVariationSound(Block.getBlockById(message.block), message.meta);
	GeneralChiselClient.spawnChiselEffect(message.x, message.y, message.z, sound);
	if (message.breakChisel) {
		EntityPlayer player = Chisel.proxy.getClientPlayer();
		player.renderBrokenItemStack(player.getCurrentEquippedItem());
	}
	return null;
}
 
Example #19
Source File: MessageJetpackSync.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
@Override
public IMessage onMessage(MessageJetpackSync msg, MessageContext ctx) {
    Entity entity = FMLClientHandler.instance().getClient().theWorld.getEntityByID(msg.entityId);
    if (entity != null && entity instanceof EntityLivingBase && entity != FMLClientHandler.instance().getClient().thePlayer) {
        if (msg.particleId >= 0) {
            ParticleType particle = ParticleType.values()[msg.particleId];
            SyncHandler.processJetpackUpdate(msg.entityId, particle);
        } else {
            SyncHandler.processJetpackUpdate(msg.entityId, null);
        }
    }
    return null;
}
 
Example #20
Source File: Magnendo.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
public void tpEntity(Entity ent, int x, int y, int z) {
    try {
        SimpleNetworkWrapper snw = (SimpleNetworkWrapper) Class.forName("crazypants.enderio.network.PacketHandler").getField("INSTANCE").get(null);
        Object travelSource = Class.forName("crazypants.enderio.api.teleport.TravelSource").getField("BLOCK").get(null);
        Object packet = Class.forName("crazypants.enderio.teleport.packet.PacketTravelEvent").getConstructor(Entity.class, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE, Boolean.TYPE, Class.forName("crazypants.enderio.api.teleport.TravelSource")).newInstance(ent, x, y, z, 0, false, travelSource);
        Field f = Class.forName("crazypants.enderio.teleport.packet.PacketTravelEvent").getDeclaredField("entityId");
        f.setAccessible(true);
        f.set(packet, ent.getEntityId());
        snw.sendToServer((IMessage) packet);
    } catch (Exception e) {
    }
}
 
Example #21
Source File: MessageKeyboardSync.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
@Override
public IMessage onMessage(MessageKeyboardSync msg, MessageContext ctx) {
    EntityPlayer entityPlayer = ctx.getServerHandler().playerEntity;
    if (entityPlayer != null) {
        SyncHandler.processKeyUpdate(entityPlayer, msg.flyState, msg.descendState, msg.forwardState, msg.backwardState, msg.leftState, msg.rightState);
    }
    return null;
}
 
Example #22
Source File: MachineCommandActivateMessage.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
protected IMessage handleMessage(MachineCommandActivateMessage message,
		MessageContext ctx, TileEntity te) {
	if(te instanceof IActivateable) {
		IActivateable machine = (IActivateable)te;
		machine.setActive(message.setActive);
	}
	else {
		BRLog.error("Received a MachineCommandActivateMessage for %d, %d, %d but found no activateable machine", message.x, message.y, message.z);
	}
	return null;
}
 
Example #23
Source File: ControlRodUpdateMessage.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
protected IMessage handleMessage(ControlRodUpdateMessage message, MessageContext ctx, TileEntity te) {
    if(te instanceof TileEntityReactorControlRod) {
        ((TileEntityReactorControlRod)te).onControlRodUpdate(message.insertion);
    }
    return null;
}
 
Example #24
Source File: ReactorCommandEjectMessage.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
public IMessage handleMessage(ReactorCommandEjectMessage message, MessageContext ctx, MultiblockReactor reactor) {
	if(message.ejectFuel) {
		reactor.ejectFuel(message.dumpExcess, null);
	}
	else {
		reactor.ejectWaste(message.dumpExcess, null);
	}
	return null;
}
 
Example #25
Source File: DeviceUpdateMessage.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
public IMessage handleMessage(DeviceUpdateMessage message, MessageContext ctx, TileEntity te) {
    if(te instanceof TileEntityBeefBase) {
        ((TileEntityBeefBase)te).onReceiveUpdate(message.compound);
    }
    return null;
}
 
Example #26
Source File: ContainerPneumaticBase.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
protected void sendToCrafters(IMessage message){
    for(ICrafting crafter : (List<ICrafting>)crafters) {
        if(crafter instanceof EntityPlayerMP) {
            NetworkHandler.sendTo(message, (EntityPlayerMP)crafter);
        }
    }
}
 
Example #27
Source File: DeviceUpdateExposureMessage.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
protected IMessage handleMessage(DeviceUpdateExposureMessage message,
		MessageContext ctx, TileEntity te) {
	if(te instanceof TileEntityBeefBase) {
		TileEntityBeefBase beefTe = (TileEntityBeefBase)te;
		beefTe.setSides(message.exposures);
	}
	// TODO Auto-generated method stub
	return null;
}
 
Example #28
Source File: TileMessageClient.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
protected IMessage handleMessage(MESSAGE message, MessageContext ctx,
		TileEntity te) {
	TE concrete = getImpl(te);
	if(concrete != null) {
		return handle(message, ctx, concrete);
	}
	else {
		BRLog.error("Received a TileMessageClient for a non-resolvable TileEntity @ %d, %d, %d", message.x, message.y, message.z);
	}
	return null;
}
 
Example #29
Source File: WorldMessage.java    From BigReactors with MIT License 5 votes vote down vote up
public IMessage onMessage(WorldMessage message, MessageContext ctx) {
	World world = getWorld(ctx);
	if(world == null) {
		BRLog.fatal("Unable to resolve world from messagecontext for WorldMessage");
		return null;
	}
	
	TileEntity te = world.getTileEntity(message.x, message.y, message.z);
	if(te == null) {
		BRLog.error("Unable to find tile entity for WorldMessage at %d, %d, %d", message.x, message.y, message.z);
		return null;
	}

	return handleMessage((M)message, ctx, te);
}
 
Example #30
Source File: TileMessageServer.java    From BigReactors with MIT License 5 votes vote down vote up
@Override
protected IMessage handleMessage(MESSAGE message, MessageContext ctx,
		TileEntity te) {
	TE concrete = getImpl(te);
	if(concrete != null) {
		return handle(message, ctx, concrete);
	}
	else {
		BRLog.error("Received a TileMessageServer for a non-resolvable TileEntity @ %d, %d, %d", message.x, message.y, message.z);
	}
	return null;
}