use of com.minecolonies.coremod.inventory.InventoryField in project minecolonies by Minecolonies.
the class Field method readFromNBT.
/**
* Save data to NBT compound.
* Writes the {@link #location} value.
*
* @param compound {@link net.minecraft.nbt.NBTTagCompound} to write data to.
*/
public void readFromNBT(@NotNull final NBTTagCompound compound) {
location = BlockPosUtil.readFromNBT(compound, TAG_LOCATION);
taken = compound.getBoolean(TAG_TAKEN);
fieldStage = FieldStage.values()[compound.getInteger(TAG_STAGE)];
lengthPlusX = compound.getInteger(TAG_LENGTH_PLUS);
widthPlusZ = compound.getInteger(TAG_WIDTH_PLUS);
lengthMinusX = compound.getInteger(TAG_LENGTH_MINUS);
widthMinusZ = compound.getInteger(TAG_WIDTH_MINUS);
inventory = new InventoryField();
inventory.deserializeNBT((NBTTagCompound) compound.getTag(Constants.MOD_ID + TAG_INVENTORY));
setOwner(compound.getString(TAG_OWNER));
initialized = compound.getBoolean(TAG_INITIALIZED);
}
use of com.minecolonies.coremod.inventory.InventoryField in project minecolonies by Minecolonies.
the class BlockHutField method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(@NotNull final World worldIn, @NotNull final BlockPos pos, final IBlockState state, final EntityLivingBase placer, final ItemStack stack) {
//Only work on server side.
if (worldIn.isRemote) {
return;
}
if (placer instanceof EntityPlayer) {
@Nullable final Colony colony = ColonyManager.getColony(worldIn, pos);
if (colony != null) {
@NotNull final InventoryField inventoryField = new InventoryField();
final ScarecrowTileEntity scareCrow = (ScarecrowTileEntity) worldIn.getTileEntity(pos);
final EntityPlayer player = (EntityPlayer) placer;
if (scareCrow != null) {
scareCrow.setInventoryField(inventoryField);
colony.addNewField(scareCrow, player.inventory, pos, worldIn);
}
}
}
}
use of com.minecolonies.coremod.inventory.InventoryField in project minecolonies by Minecolonies.
the class OpenInventoryMessage method doFieldInventory.
private static void doFieldInventory(final OpenInventoryMessage message, final EntityPlayerMP player) {
if (checkPermissions(ColonyManager.getClosestColony(player.getEntityWorld(), message.tePos), player)) {
@NotNull final InventoryField inventoryField = ColonyManager.getColony(message.colonyId).getField(message.tePos).getInventoryField();
if (!StringUtils.isNullOrEmpty(message.name)) {
// inventoryField.setCustomName(message.name);
}
player.openGui(MineColonies.instance, 1, player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ());
}
}
Aggregations