Search in sources :

Example 6 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project MinecraftForge by MinecraftForge.

the class NetworkDispatcher method serverInitiateHandshake.

int serverInitiateHandshake() {
    // Send mod salutation to the client
    // This will be ignored by vanilla clients
    this.state = ConnectionState.AWAITING_HANDSHAKE;
    // Need to start the handler here, so we can send custompayload packets
    serverHandler = new NetHandlerPlayServer(scm.getServerInstance(), manager, player) {

        @Override
        public void update() {
            if (NetworkDispatcher.this.state == ConnectionState.FINALIZING) {
                completeServerSideConnection(ConnectionType.MODDED);
            }
            // FORGE: sometimes the netqueue will tick while login is occurring, causing an NPE. We shouldn't tick until the connection is complete
            if (this.playerEntity.connection != this)
                return;
            super.update();
        }
    };
    this.netHandler = serverHandler;
    // NULL the play server here - we restore it further on. If not, there are packets sent before the login
    player.connection = null;
    // manually for the manager into the PLAY state, so we can send packets later
    this.manager.setConnectionState(EnumConnectionState.PLAY);
    // Return the dimension the player is in, so it can be pre-sent to the client in the ServerHello v2 packet
    // Requires some hackery to the serverconfigmanager and stuff for this to work
    NBTTagCompound playerNBT = scm.getPlayerNBT(player);
    if (playerNBT != null) {
        int dimension = playerNBT.getInteger("Dimension");
        if (DimensionManager.isDimensionRegistered(dimension)) {
            return dimension;
        }
    }
    return 0;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer)

Example 7 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project BluePower by Qmunity.

the class CompatModuleIC2 method init.

@Override
public void init(FMLInitializationEvent ev) {
    Recipes.macerator.addRecipe(new IC2RecipeInput(new ItemStack(BPBlocks.zinc_ore)), null, new ItemStack(BPItems.zinc_ore_crushed, 2));
    NBTTagCompound tag = new NBTTagCompound();
    tag.setInteger("amount", 1000);
    Recipes.oreWashing.addRecipe(new IC2RecipeInput(new ItemStack(BPItems.zinc_ore_crushed)), tag, new ItemStack(BPItems.zinc_ore_purified), new ItemStack(BPItems.zinc_tiny_dust, 2), new ItemStack(GameData.getItemRegistry().getObject("IC2:itemDust"), 1, 9));
    tag = new NBTTagCompound();
    tag.setInteger("minHeat", 2000);
    Recipes.centrifuge.addRecipe(new IC2RecipeInput(new ItemStack(BPItems.zinc_ore_purified)), tag, new ItemStack(BPItems.zinc_dust), new ItemStack(GameData.getItemRegistry().getObject("IC2:itemDustSmall"), 1, 6));
    Recipes.centrifuge.addRecipe(new IC2RecipeInput(new ItemStack(BPItems.zinc_ore_crushed)), tag, new ItemStack(BPItems.zinc_dust), new ItemStack(GameData.getItemRegistry().getObject("IC2:itemDustSmall"), 1, 6), new ItemStack(GameData.getItemRegistry().getObject("IC2:itemDust"), 1, 9));
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 8 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project BluePower by Qmunity.

the class MessageSyncMachineBacklog method toBytes.

@Override
public void toBytes(ByteBuf buf) {
    super.toBytes(buf);
    buf.writeInt(stacks.size());
    for (TubeStack stack : stacks) {
        NBTTagCompound tag = new NBTTagCompound();
        stack.writeToNBT(tag);
        ByteBufUtils.writeTag(buf, tag);
    }
}
Also used : TubeStack(com.bluepowermod.part.tube.TubeStack) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 9 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project BluePower by Qmunity.

the class GateBase method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound tag) {
    super.readFromNBT(tag);
    NBTTagCompound connections = tag.getCompoundTag("connections");
    for (GateConnectionBase c : getConnections()) if (c != null)
        c.readFromNBT(connections.getCompoundTag(c.getDirection().name()));
    NBTTagCompound components = tag.getCompoundTag("components");
    int i = 0;
    for (IGateComponent c : getComponents()) {
        c.readFromNBT(components.getCompoundTag(i + ""));
        i++;
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IGateComponent(com.bluepowermod.api.gate.IGateComponent) GateConnectionBase(com.bluepowermod.part.gate.connection.GateConnectionBase)

Example 10 with NBTTagCompound

use of net.minecraft.nbt.NBTTagCompound in project BluePower by Qmunity.

the class WorldConverter method convertTile.

private boolean convertTile(NBTTagCompound tag) {
    NBTTagList parts = tag.getTagList("parts", new NBTTagCompound().getId());
    int count = parts.tagCount();
    FMPPart fmppart = new FMPPart(true);
    for (int i = 0; i < count; i++) {
        NBTTagCompound part = parts.getCompoundTagAt(i);
        String id = part.getString("id");
        for (IPartConverter c : converters) {
            if (c.matches(id)) {
                IPart p = c.convert(part);
                if (p == null)
                    continue;
                fmppart.addPart(p);
                parts.removeTag(i);
                i--;
                break;
            }
        }
        count = parts.tagCount();
    }
    if (fmppart.getParts().size() > 0) {
        NBTTagCompound part = new NBTTagCompound();
        fmppart.save(part);
        part.setString("id", fmppart.getType());
        parts.appendTag(part);
        return true;
    }
    return false;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) IPart(uk.co.qmunity.lib.part.IPart) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) FMPPart(uk.co.qmunity.lib.part.compat.fmp.FMPPart)

Aggregations

NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3985 NBTTagList (net.minecraft.nbt.NBTTagList)1052 ItemStack (net.minecraft.item.ItemStack)883 BlockPos (net.minecraft.util.math.BlockPos)229 TileEntity (net.minecraft.tileentity.TileEntity)173 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)148 ArrayList (java.util.ArrayList)99 Block (net.minecraft.block.Block)98 ResourceLocation (net.minecraft.util.ResourceLocation)96 IBlockState (net.minecraft.block.state.IBlockState)92 EntityPlayer (net.minecraft.entity.player.EntityPlayer)81 NBTTagString (net.minecraft.nbt.NBTTagString)79 Nonnull (javax.annotation.Nonnull)74 Map (java.util.Map)71 UUID (java.util.UUID)69 NBTBase (net.minecraft.nbt.NBTBase)66 HashMap (java.util.HashMap)64 EnumFacing (net.minecraft.util.EnumFacing)61 NotNull (org.jetbrains.annotations.NotNull)60 Item (net.minecraft.item.Item)55