Search in sources :

Example 1 with TileMagiciansWorktable

use of com.teamwizardry.wizardry.common.tile.TileMagiciansWorktable in project Wizardry by TeamWizardry.

the class PacketWorktableUpdate method handle.

@Override
public void handle(@Nonnull MessageContext messageContext) {
    World world = FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(worldID);
    if (!world.isBlockLoaded(pos))
        return;
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock() != ModBlocks.MAGICIANS_WORKTABLE)
        return;
    TileEntity table = world.getTileEntity(pos);
    if (table == null)
        return;
    if (!(table instanceof TileMagiciansWorktable))
        return;
    ((TileMagiciansWorktable) table).componentLinks = links;
    ((TileMagiciansWorktable) table).paperComponents = components;
    table.markDirty();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileMagiciansWorktable(com.teamwizardry.wizardry.common.tile.TileMagiciansWorktable) IBlockState(net.minecraft.block.state.IBlockState) World(net.minecraft.world.World)

Example 2 with TileMagiciansWorktable

use of com.teamwizardry.wizardry.common.tile.TileMagiciansWorktable 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

TileMagiciansWorktable (com.teamwizardry.wizardry.common.tile.TileMagiciansWorktable)2 IBlockState (net.minecraft.block.state.IBlockState)2 TileEntity (net.minecraft.tileentity.TileEntity)2 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 World (net.minecraft.world.World)1