use of com.cjm721.overloaded.network.packets.ContainerDataMessage in project Overloaded by CJ-MC-Mods.
the class CommonProxy method commonSetup.
public void commonSetup(FMLCommonSetupEvent event) {
CapabilityHyperItem.register();
CapabilityHyperEnergy.register();
CapabilityHyperFluid.register();
CapabilityGenericDataStorage.register();
networkWrapper = newSimpleChannel(ResourceLocation.of("overloaded_network", '_'), () -> "1.0", v -> true, v -> true);
int dis = 0;
networkWrapper.registerMessage(dis++, LeftClickBlockMessage.class, LeftClickBlockMessage::toBytes, LeftClickBlockMessage::fromBytes, new PlayerMessageHandler<>(ItemMultiTool::leftClickOnBlockServer));
networkWrapper.registerMessage(dis++, RightClickBlockMessage.class, RightClickBlockMessage::toBytes, RightClickBlockMessage::fromBytes, new PlayerMessageHandler<>(ModItems.multiTool::rightClickWithItem));
networkWrapper.registerMessage(dis++, RayGunMessage.class, RayGunMessage::toBytes, RayGunMessage::fromBytes, new PlayerMessageHandler<>(ModItems.rayGun::handleMessage));
networkWrapper.registerMessage(dis++, MultiArmorSettingsMessage.class, MultiArmorSettingsMessage::toBytes, MultiArmorSettingsMessage::fromBytes, new PlayerMessageHandler<>(ModItems.customHelmet::updateSettings));
networkWrapper.registerMessage(dis++, RailGunFireMessage.class, RailGunFireMessage::toBytes, RailGunFireMessage::fromBytes, new PlayerMessageHandler<>(ModItems.railgun::handleFireMessage));
networkWrapper.registerMessage(dis++, RailGunSettingsMessage.class, RailGunSettingsMessage::toBytes, RailGunSettingsMessage::fromBytes, new PlayerMessageHandler<>(ModItems.railgun::handleSettingsMessage));
networkWrapper.registerMessage(dis++, KeyBindPressedMessage.class, KeyBindPressedMessage::toBytes, KeyBindPressedMessage::fromBytes, new KeyBindPressedHandler());
networkWrapper.registerMessage(dis++, NoClipStatusMessage.class, NoClipStatusMessage::toBytes, NoClipStatusMessage::fromBytes, new NoClipUpdateHandler());
networkWrapper.registerMessage(dis++, ContainerDataMessage.class, ContainerDataMessage::toBytes, ContainerDataMessage::fromBytes, new ContainerDataHandler());
MinecraftForge.EVENT_BUS.register(new ArmorEventHandler());
}
use of com.cjm721.overloaded.network.packets.ContainerDataMessage in project Overloaded by CJ-MC-Mods.
the class InstantFurnaceContainer method broadcastChanges.
@Override
public void broadcastChanges() {
int j;
for (j = 0; j < this.slots.size(); ++j) {
ItemStack itemstack = this.slots.get(j).getItem();
itemstack = itemstack.isEmpty() ? ItemStack.EMPTY : itemstack.copy();
this.lastSlots.set(j, itemstack);
for (IContainerListener icontainerlistener : this.containerListeners) {
icontainerlistener.slotChanged(this, j, itemstack);
}
}
ContainerDataMessage message = new ContainerDataMessage(this.containerId);
for (j = 0; j < this.dataSlots.size(); ++j) {
IntReferenceHolder intreferenceholder = this.dataSlots.get(j);
if (intreferenceholder.checkAndClearUpdateFlag()) {
message.addData(j, intreferenceholder.get());
}
}
if (!message.getData().isEmpty()) {
for (IContainerListener listener : this.containerListeners) {
if (listener instanceof ServerPlayerEntity) {
Overloaded.proxy.networkWrapper.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) listener), message);
}
}
}
}
Aggregations