package com.example.stolzaddons.client;

import com.example.stolzaddons.PlanetLogic.WorldProviderPlanet;
import com.example.stolzaddons.network.PacketDestructionState;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import net.minecraft.client.Minecraft;
import net.minecraft.world.World;

// PacketDestructionHandler.java
public class PacketDestructionHandler implements IMessageHandler<PacketDestructionState, IMessage> {

    @Override
    public IMessage onMessage(PacketDestructionState msg, MessageContext ctx) {

        if (ctx.side.isClient()) {
            World world = Minecraft.getMinecraft().theWorld;

            if (world != null && world.provider instanceof WorldProviderPlanet) {
                ((WorldProviderPlanet) world.provider).isMarkedForDestruction = msg.marked;
            }
        }

        return null; // no response needed
    }
}
