Search in sources :

Example 1 with InventoryField

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);
}
Also used : InventoryField(com.minecolonies.coremod.inventory.InventoryField)

Example 2 with InventoryField

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);
            }
        }
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) Colony(com.minecolonies.coremod.colony.Colony) InventoryField(com.minecolonies.coremod.inventory.InventoryField) ScarecrowTileEntity(com.minecolonies.coremod.tileentities.ScarecrowTileEntity) NotNull(org.jetbrains.annotations.NotNull) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with InventoryField

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());
    }
}
Also used : InventoryField(com.minecolonies.coremod.inventory.InventoryField) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

InventoryField (com.minecolonies.coremod.inventory.InventoryField)3 NotNull (org.jetbrains.annotations.NotNull)2 Colony (com.minecolonies.coremod.colony.Colony)1 ScarecrowTileEntity (com.minecolonies.coremod.tileentities.ScarecrowTileEntity)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 Nullable (org.jetbrains.annotations.Nullable)1