Skip to content

Farming Station #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9cdc3d6
Create FarmBlockEntity.java
ferriarnus Nov 12, 2023
d221ae4
add task like system
ferriarnus Nov 14, 2023
9960998
add boilerplate
ferriarnus Nov 15, 2023
8cef239
Update FarmBlockEntity.java
ferriarnus Nov 15, 2023
c784717
fix onUse logic
ferriarnus Nov 19, 2023
513a270
add farm tasks
ferriarnus Nov 22, 2023
ce807b3
add bonemeal
ferriarnus Nov 23, 2023
f016601
screen stuff
ferriarnus Mar 4, 2024
360ee49
Merge branch 'dev/1.20.4' into farm
ferriarnus Mar 4, 2024
9d84e45
fix datagen
ferriarnus Mar 4, 2024
36498a9
move to api package
ferriarnus Mar 5, 2024
73ae0a2
add soul data
ferriarnus Mar 16, 2024
d266d29
fix crash
ferriarnus Mar 16, 2024
eacfcbf
proper datagen
ferriarnus Mar 16, 2024
e6c0551
setup api integration
ferriarnus Mar 16, 2024
8bd2ed1
handle full inv (somewhat)
ferriarnus Mar 16, 2024
c3e44e8
add some active tasks
ferriarnus Mar 17, 2024
2dffc1f
Merge branch 'dev/1.20.6' into farm
ferriarnus May 18, 2024
64b7990
port 1.20.6
ferriarnus May 18, 2024
deca1e4
fix datagen
ferriarnus May 18, 2024
f8720a1
fix cactus drops
ferriarnus May 19, 2024
bfdf66f
Merge branch 'dev/1.20.6' into farm
ferriarnus Jun 13, 2024
d891311
chore: rename + fluid tank
ferriarnus Jun 16, 2024
4b2ca24
Merge branch 'dev/1.20.6' into farm
ferriarnus Jun 16, 2024
a063c0f
feat: add fertilizer tag and fluid interactions
ferriarnus Jun 18, 2024
fdba6f9
Merge branch 'dev/1.21' into farm
ferriarnus Sep 29, 2024
6e5e03d
fix: conflicts
ferriarnus Sep 29, 2024
ed9d076
fix: more conflicts
ferriarnus Sep 29, 2024
37b8e29
Update to new machine system
dphaldes Jan 5, 2025
8397ed0
move FarmingStationMenu to correct folder
dphaldes Jan 5, 2025
8d62af9
fix FarmingStationScreen
dphaldes Jan 5, 2025
9a77a31
add model and run datagen
dphaldes Jan 5, 2025
35af189
remove fluidhandler from FarmingStation
dphaldes Jan 6, 2025
275f870
add sapling and tree behaviour for farmingstation
dphaldes Jan 7, 2025
b5c19a8
keep atleast one seed in farming station
dphaldes Jan 8, 2025
f7b5ba3
add netherwart support to farming station
dphaldes Jan 9, 2025
e6e9b4c
use shears for leaves
dphaldes Jan 9, 2025
1203e1d
try fix tree lag
dphaldes Jan 10, 2025
0669881
add range helper
dphaldes Jan 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"variants": {
"facing=east,powered=false": {
"model": "enderio:block/farming_station_combined",
"y": 90
},
"facing=east,powered=true": {
"model": "enderio:block/farming_station_active_combined",
"y": 90
},
"facing=north,powered=false": {
"model": "enderio:block/farming_station_combined"
},
"facing=north,powered=true": {
"model": "enderio:block/farming_station_active_combined"
},
"facing=south,powered=false": {
"model": "enderio:block/farming_station_combined",
"y": 180
},
"facing=south,powered=true": {
"model": "enderio:block/farming_station_active_combined",
"y": 180
},
"facing=west,powered=false": {
"model": "enderio:block/farming_station_combined",
"y": 270
},
"facing=west,powered=true": {
"model": "enderio:block/farming_station_active_combined",
"y": 270
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"parent": "minecraft:block/block",
"children": {
"machine": {
"parent": "enderio:block/farming_station_active"
},
"overlay": {
"parent": "enderio:block/io_overlay"
}
},
"item_render_order": [
"machine",
"overlay"
],
"loader": "neoforge:composite",
"textures": {
"particle": "enderio:block/farming_station_front"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"parent": "minecraft:block/block",
"children": {
"machine": {
"parent": "enderio:block/farming_station"
},
"overlay": {
"parent": "enderio:block/io_overlay"
}
},
"item_render_order": [
"machine",
"overlay"
],
"loader": "neoforge:composite",
"textures": {
"particle": "enderio:block/farming_station_front"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "enderio:block/farming_station"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_components",
"include": [
"enderio:stored_entity",
"enderio:energy",
"enderio:io_config",
"enderio:redstone_control",
"minecraft:container"
],
"source": "block_entity"
}
],
"name": "enderio:farming_station"
}
],
"rolls": 1.0
}
],
"random_sequence": "enderio:blocks/farming_station"
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,34 @@
"enderio:silent_heavy_weighted_pressure_plate",
"enderio:silent_light_weighted_pressure_plate",
"enderio:painted_redstone_block",
"enderio:painted_wall"
"enderio:fluid_tank",
"enderio:pressurized_fluid_tank",
"enderio:enchanter",
"enderio:primitive_alloy_smelter",
"enderio:alloy_smelter",
"enderio:painting_machine",
"enderio:wired_charger",
"enderio:stirling_generator",
"enderio:sag_mill",
"enderio:slice_and_splice",
"enderio:impulse_hopper",
"enderio:soul_binder",
"enderio:powered_spawner",
"enderio:vacuum_chest",
"enderio:xp_vacuum",
"enderio:travel_anchor",
"enderio:painted_travel_anchor",
"enderio:energetic_photovoltaic_module",
"enderio:pulsating_photovoltaic_module",
"enderio:vibrant_photovoltaic_module",
"enderio:basic_capacitor_bank",
"enderio:advanced_capacitor_bank",
"enderio:vibrant_capacitor_bank",
"enderio:crafter",
"enderio:soul_engine",
"enderio:drain",
"enderio:xp_obelisk",
"enderio:farming_station",
"enderio:conduit"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.enderio.base.api.farm;

public enum FarmInteraction {
FINISHED,
POWERED,
BLOCKED,
IGNORED;
}
Comment on lines +1 to +8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Good enum design with clear status values.

The enum provides a clean way to represent different farming operation outcomes. The status values are self-explanatory and well-chosen.

Fix formatting to pass CI pipeline.

The pipeline failure indicates formatting issues. Run the suggested command to fix:

./gradlew :enderio-base:spotlessApply
🧰 Tools
🪛 GitHub Actions: Verify Build

[error] 1-5: The following files had format violations: Spotless formatting check failed. Run './gradlew :enderio-base:spotlessApply' to fix these violations.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.enderio.base.api.farm;

import net.minecraft.core.BlockPos;

public interface FarmTask {

FarmInteraction farm(BlockPos soil, FarmingStation farmBlockEntity);
Comment on lines +1 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Import for FarmingStation is missing.

The interface references FarmingStation but doesn't import it. Add the appropriate import statement.

 package com.enderio.base.api.farm;

 import net.minecraft.core.BlockPos;
+import com.enderio.machines.common.blocks.farming_station.FarmingStation;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
package com.enderio.base.api.farm;
import net.minecraft.core.BlockPos;
public interface FarmTask {
FarmInteraction farm(BlockPos soil, FarmingStation farmBlockEntity);
package com.enderio.base.api.farm;
import net.minecraft.core.BlockPos;
import com.enderio.machines.common.blocks.farming_station.FarmingStation;
public interface FarmTask {
FarmInteraction farm(BlockPos soil, FarmingStation farmBlockEntity);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.enderio.base.api.farm;

import com.enderio.base.api.integration.IntegrationManager;
import com.google.common.collect.ImmutableList;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public class FarmTaskManager {
private final ArrayList<TaskEntry> tasks = new ArrayList<>();
private static ImmutableList<FarmTask> TASKS_IMMUTABLE;

public static int PLANT = 1;
public static int BONEMEAL = 3;
public static int HARVEST = 5;

private FarmTaskManager() {

}

public static List<FarmTask> getTasks() {
if (TASKS_IMMUTABLE == null) {
FarmTaskManager manager = new FarmTaskManager();
IntegrationManager.forAll(integration -> integration.registerFarmTasks(manager));
manager.tasks.sort(TaskEntry::compareTo);
TASKS_IMMUTABLE = ImmutableList.copyOf(manager.tasks.stream().map(e -> e.task).toList());
}
return TASKS_IMMUTABLE;
}

public void addTask(int priority, FarmTask task) {
tasks.add(new TaskEntry(priority, task));
}

public record TaskEntry(int priority, FarmTask task) implements Comparable<TaskEntry> {

@Override
public int compareTo(@NotNull FarmTaskManager.TaskEntry o) {
return priority - o.priority;
}
}
}
Comment on lines +1 to +43
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix formatting issues flagged by Spotless

The pipeline failure indicates that this file has formatting violations. Please run ./gradlew :enderio-base:spotlessApply to fix these issues before merging.

#!/bin/bash
# Show the exact formatting violations for this file
./gradlew :enderio-base:spotlessCheck --debug | grep -A 10 "FarmTaskManager.java"
🧰 Tools
🪛 GitHub Actions: Verify Build

[error] 2-10: The following files had format violations: Spotless formatting check failed. Run './gradlew :enderio-base:spotlessApply' to fix these violations.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.enderio.base.api.farm;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.common.util.FakePlayer;

import java.util.Optional;

public interface FarmingStation {

ItemStack getSeedsForPos(BlockPos pos);

int getConsumedPower();

void addConsumedPower(int i);

int consumeEnergy(int energy, boolean simulate);

ItemStack getHoe();

ItemStack getAxe();

ItemStack getShears();

FakePlayer getPlayer();

BlockPos getPosition();

int getFarmingRange();

boolean consumeBonemeal();

Level getLevel();

boolean handleDrops(BlockState plant, BlockPos pos, BlockPos soil, BlockEntity blockEntity, ItemStack stack);

Optional<ResourceLocation> getEntityType();

default InteractionResult useStack(BlockPos soil, ItemStack stack) {
getPlayer().setItemInHand(InteractionHand.MAIN_HAND, stack);
UseOnContext context = new UseOnContext(getPlayer(), InteractionHand.MAIN_HAND, new BlockHitResult(Vec3.atBottomCenterOf(soil), Direction.UP, soil, false));
InteractionResult result = stack.useOn(context);
getPlayer().setItemInHand(InteractionHand.MAIN_HAND, ItemStack.EMPTY);
return result;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.enderio.base.api.integration;

import com.enderio.base.api.farm.FarmTaskManager;
import com.enderio.base.api.glider.GliderMovementInfo;
import java.util.Optional;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -65,4 +66,6 @@ default void createData(GatherDataEvent event) {
default boolean canBlockTeleport(Player player) {
return false;
}

default void registerFarmTasks(FarmTaskManager manager) {}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

New method properly follows interface design patterns.

The default empty implementation allows integrations to optionally override this method only when needed, maintaining backward compatibility.

Please run Spotless to fix formatting issues as indicated by the pipeline failure:

./gradlew :enderio-base:spotlessApply

}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ private static void init() {
public static final TagKey<Item> STORAGE_BLOCKS_QUARTZ = commonTag("storage_blocks/quartz");
public static final TagKey<Item> STORAGE_BLOCKS_AMETHYST = commonTag("storage_blocks/amethyst");

public static final TagKey<Item> FERTILIZERS = commonTag("fertilizers");

public static final Map<GlassIdentifier, TagKey<Item>> GLASS_TAGS = createGlassTags();

public static Map<GlassIdentifier, TagKey<Item>> createGlassTags() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"block.enderio.enderman_head": "Enderman Head",
"block.enderio.energetic_alloy_block": "Energetic Alloy Block",
"block.enderio.ensouled_chassis": "Ensouled Chassis",
"block.enderio.farming_station": "Farming Station",
"block.enderio.fire_water": "Fire Water",
"block.enderio.fused_quartz": "Fused Quartz",
"block.enderio.fused_quartz_black": "Black Fused Quartz",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "enderio:block/farming_station"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"block.enderio.drain": "Drain",
"block.enderio.enchanter": "Enchanter",
"block.enderio.energetic_photovoltaic_module": "Energetic Photovoltaic Module",
"block.enderio.farming_station": "Farming Station",
"block.enderio.fluid_tank": "Fluid Tank",
"block.enderio.impulse_hopper": "Impulse Hopper",
"block.enderio.inhibitor_obelisk": "Inhibitor Obelisk",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "enderio:block/farming_station"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"bonemeal": 0.8,
"entity": "minecraft:bee"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"entity": "minecraft:sniffer",
"seeds": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"entity": "minecraft:villager",
"power": 1.2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_components",
"include": [
"enderio:stored_entity",
"enderio:energy",
"enderio:io_config",
"enderio:redstone_control",
"minecraft:container"
],
"source": "block_entity"
}
],
"name": "enderio:farming_station"
}
],
"rolls": 1.0
}
],
"random_sequence": "enderio:blocks/farming_station"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "enderio:soul_binding",
"energy": 188000,
"experience": 5,
"input": {
"item": "enderio:farming_station"
},
"output": {
"count": 1,
"id": "enderio:farming_station"
},
"soul_data": "farm"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"enderio:vat",
"enderio:block_detector",
"enderio:xp_obelisk",
"enderio:farming_station",
"enderio:inhibitor_obelisk",
"enderio:aversion_obelisk",
"enderio:relocator_obelisk"
Expand Down
Loading
Loading