Class FarmField
java.lang.Object
com.minecolonies.core.colony.buildingextensions.AbstractBuildingExtension
com.minecolonies.core.colony.buildingextensions.FarmField
- All Implemented Interfaces:
IBuildingExtension,IModuleContainer<IBuildingExtensionModule>
Field class implementation for the plantation
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDescribes the stage the field is in.Nested classes/interfaces inherited from interface com.minecolonies.api.colony.buildingextensions.IBuildingExtension
IBuildingExtension.ExtensionId -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intThe max width/length of a field.static final String -
Constructor Summary
ConstructorsConstructorDescriptionFarmField(BuildingExtensionRegistries.BuildingExtensionEntry fieldType, net.minecraft.core.BlockPos position) Constructor used in NBT deserialization. -
Method Summary
Modifier and TypeMethodDescriptionstatic FarmFieldcreate(net.minecraft.core.BlockPos position, net.minecraft.world.level.Level worldIn) Constructor to create new instancesvoiddeserialize(@NotNull net.minecraft.network.RegistryFriendlyByteBuf buf) Deserialize a building extension from a buffer.voiddeserializeNBT(net.minecraft.core.HolderLookup.Provider provider, @NotNull net.minecraft.nbt.CompoundTag compound) Reconstruct the building extension from the given NBT data.Get the current stage the field is in.intgetRadius(net.minecraft.core.Direction direction) @NotNull net.minecraft.world.item.ItemStackgetSeed()Get the current seed on the field.booleanisNoPartOfField(@NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos position) Checks if a certain position is part of the field.booleanisValidPlacement(IColony colony) Condition to check whether this building extension instance is currently properly placed down.voidMove the field into the new state.voidserialize(@NotNull net.minecraft.network.RegistryFriendlyByteBuf buf) Serialize a building extension to a buffer.@NotNull net.minecraft.nbt.CompoundTagserializeNBT(net.minecraft.core.HolderLookup.Provider provider) Stores the NBT data of the building extension.voidsetFieldStage(FarmField.Stage fieldStage) Sets the current stage of the field.voidsetRadius(net.minecraft.core.Direction direction, int radius) voidsetSeed(net.minecraft.world.item.ItemStack seed) Updates the seed in the field.Methods inherited from class com.minecolonies.core.colony.buildingextensions.AbstractBuildingExtension
equals, getBuildingExtensionType, getBuildingId, getClassType, getId, getModules, getPosition, getSqDistance, hashCode, isTaken, registerModule, resetOwningBuilding, setBuildingMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.minecolonies.api.colony.modules.IModuleContainer
getFirstModuleOccurance, getModule, getModule, getModule, getModuleMatching, getModules, getModules, getModules, getModulesByType, hasModule, hasModule, hasModule
-
Field Details
-
MAX_RANGE
public static final int MAX_RANGEThe max width/length of a field.- See Also:
-
DEFAULT_RANGE
public static final int DEFAULT_RANGE- See Also:
-
TAG_RADIUS
- See Also:
-
-
Constructor Details
-
FarmField
public FarmField(BuildingExtensionRegistries.BuildingExtensionEntry fieldType, net.minecraft.core.BlockPos position) Constructor used in NBT deserialization.- Parameters:
fieldType- the type of field.position- the position of the field.
-
-
Method Details
-
create
public static FarmField create(net.minecraft.core.BlockPos position, net.minecraft.world.level.Level worldIn) Constructor to create new instances- Parameters:
position- the position it is placed in.worldIn-
-
isValidPlacement
Description copied from interface:IBuildingExtensionCondition to check whether this building extension instance is currently properly placed down.- Parameters:
colony- the colony this building extension is in.- Returns:
- true if the building extension is correctly placed at the current position.
-
serializeNBT
@NotNull public @NotNull net.minecraft.nbt.CompoundTag serializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider) Description copied from interface:IBuildingExtensionStores the NBT data of the building extension.- Specified by:
serializeNBTin interfaceIBuildingExtension- Overrides:
serializeNBTin classAbstractBuildingExtension
-
deserializeNBT
public void deserializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, @NotNull @NotNull net.minecraft.nbt.CompoundTag compound) Description copied from interface:IBuildingExtensionReconstruct the building extension from the given NBT data.- Specified by:
deserializeNBTin interfaceIBuildingExtension- Overrides:
deserializeNBTin classAbstractBuildingExtension- Parameters:
compound- the compound to read from.
-
serialize
public void serialize(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf) Description copied from interface:IBuildingExtensionSerialize a building extension to a buffer.- Specified by:
serializein interfaceIBuildingExtension- Overrides:
serializein classAbstractBuildingExtension- Parameters:
buf- the buffer to write the building extension data to.
-
deserialize
public void deserialize(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf) Description copied from interface:IBuildingExtensionDeserialize a building extension from a buffer.- Specified by:
deserializein interfaceIBuildingExtension- Overrides:
deserializein classAbstractBuildingExtension- Parameters:
buf- the buffer to read the building extension data from.
-
getSeed
@NotNull public @NotNull net.minecraft.world.item.ItemStack getSeed()Get the current seed on the field.- Returns:
- the current seed.
-
setSeed
public void setSeed(net.minecraft.world.item.ItemStack seed) Updates the seed in the field.- Parameters:
seed- the new seed
-
nextState
public void nextState()Move the field into the new state. -
getFieldStage
Get the current stage the field is in.- Returns:
- the stage of the field.
-
setFieldStage
Sets the current stage of the field.- Parameters:
fieldStage- the stage of the field.
-
getRadius
public int getRadius(net.minecraft.core.Direction direction) - Parameters:
direction- the direction to get the range for- Returns:
- the radius
-
setRadius
public void setRadius(net.minecraft.core.Direction direction, int radius) - Parameters:
direction- the direction for the radiusradius- the number of blocks from the scarecrow that the farmer will work with
-
isNoPartOfField
public boolean isNoPartOfField(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos position) Checks if a certain position is part of the field. Complies with the definition of field block.- Parameters:
world- the world object.position- the position.- Returns:
- true if it is.
-