Search in sources :

Example 1 with PacketWorktableUpdate

use of com.teamwizardry.wizardry.common.network.PacketWorktableUpdate in project Wizardry by TeamWizardry.

the class WorktableGui method sync.

public void sync() {
    if (!Minecraft.getMinecraft().world.isBlockLoaded(worktablePos))
        return;
    IBlockState state = Minecraft.getMinecraft().world.getBlockState(worktablePos);
    if (state.getBlock() != ModBlocks.MAGICIANS_WORKTABLE)
        return;
    TileEntity table = Minecraft.getMinecraft().world.getTileEntity(worktablePos);
    if (!(table instanceof TileMagiciansWorktable))
        return;
    HashMap<SpellRing, UUID> convertComponents = new HashMap<>();
    for (Map.Entry<GuiComponent, UUID> entrySet : paperComponents.entrySet()) {
        Module module1 = getModule(entrySet.getKey());
        if (module1 == null)
            continue;
        SpellRing ring = new SpellRing(module1);
        ring.getInformationTag().setDouble("worktable_x", entrySet.getKey().getPos().getX());
        ring.getInformationTag().setDouble("worktable_y", entrySet.getKey().getPos().getY());
        convertComponents.put(ring, entrySet.getValue());
    }
    ((TileMagiciansWorktable) table).componentLinks = componentLinks;
    ((TileMagiciansWorktable) table).paperComponents = convertComponents;
    PacketHandler.NETWORK.sendToServer(new PacketWorktableUpdate(Minecraft.getMinecraft().world.provider.getDimension(), worktablePos, convertComponents, componentLinks));
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PacketWorktableUpdate(com.teamwizardry.wizardry.common.network.PacketWorktableUpdate) TileMagiciansWorktable(com.teamwizardry.wizardry.common.tile.TileMagiciansWorktable) IBlockState(net.minecraft.block.state.IBlockState) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) GuiComponent(com.teamwizardry.librarianlib.features.gui.component.GuiComponent) Module(com.teamwizardry.wizardry.api.spell.module.Module) BiMap(com.google.common.collect.BiMap) HashBiMap(com.google.common.collect.HashBiMap)

Aggregations

BiMap (com.google.common.collect.BiMap)1 HashBiMap (com.google.common.collect.HashBiMap)1 GuiComponent (com.teamwizardry.librarianlib.features.gui.component.GuiComponent)1 SpellRing (com.teamwizardry.wizardry.api.spell.SpellRing)1 Module (com.teamwizardry.wizardry.api.spell.module.Module)1 PacketWorktableUpdate (com.teamwizardry.wizardry.common.network.PacketWorktableUpdate)1 TileMagiciansWorktable (com.teamwizardry.wizardry.common.tile.TileMagiciansWorktable)1 IBlockState (net.minecraft.block.state.IBlockState)1 TileEntity (net.minecraft.tileentity.TileEntity)1