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;
}
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));
}
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);
}
}
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++;
}
}
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;
}
Aggregations