-
Notifications
You must be signed in to change notification settings - Fork 128
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
Farming Station #568
Changes from all commits
9cdc3d6
d221ae4
9960998
8cef239
c784717
513a270
ce807b3
f016601
360ee49
9d84e45
36498a9
73ae0a2
d266d29
eacfcbf
e6c0551
8bd2ed1
c3e44e8
2dffc1f
64b7990
deca1e4
f8720a1
bfdf66f
d891311
4b2ca24
a063c0f
fdba6f9
6e5e03d
ed9d076
37b8e29
8397ed0
8d62af9
9a77a31
35af189
275f870
b5c19a8
f7b5ba3
e6e9b4c
1203e1d
0669881
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.enderio.base.api.farm; | ||
|
||
public enum FarmInteraction { | ||
FINISHED, | ||
POWERED, | ||
BLOCKED, | ||
IGNORED; | ||
} | ||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Import for FarmingStation is missing. The interface references package com.enderio.base.api.farm;
import net.minecraft.core.BlockPos;
+import com.enderio.machines.common.blocks.farming_station.FarmingStation; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
} |
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix formatting issues flagged by Spotless The pipeline failure indicates that this file has formatting violations. Please run #!/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; | ||
|
@@ -65,4 +66,6 @@ default void createData(GatherDataEvent event) { | |
default boolean canBlockTeleport(Player player) { | ||
return false; | ||
} | ||
|
||
default void registerFarmTasks(FarmTaskManager manager) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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:
|
||
} |
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 |
---|---|---|
@@ -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" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
🧰 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.