-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffec7db
commit ff6c35b
Showing
5 changed files
with
42 additions
and
15 deletions.
There are no files selected for viewing
11 changes: 0 additions & 11 deletions
11
...kentity/common/src/main/java/band/kessoku/lib/api/blockentity/BlockEntityCoordinator.java
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
blockentity/common/src/main/java/band/kessoku/lib/api/blockentity/Coordinator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package band.kessoku.lib.api.blockentity; | ||
|
||
import band.kessoku.lib.api.data.DataStructure; | ||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.block.entity.BlockEntityType; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import org.apache.commons.lang3.function.TriFunction; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class Coordinator<S extends DataStructure> { | ||
private final Map<BlockEntityType<?>, TriFunction<BlockEntityType<?>, World, BlockPos, S>> map = new HashMap<>(); | ||
|
||
public <T extends BlockEntity> void add(BlockEntityType<T> type, BlockEntityAccess<T, S> access) { | ||
map.put(type, ((t, world, blockPos) -> { | ||
if (t == type) { | ||
return access.to(type.get(world, blockPos)); | ||
} | ||
return null; | ||
})); | ||
} | ||
|
||
public <T extends BlockEntity> S get(BlockEntityType<T> type, World world, BlockPos pos) { | ||
return map.get(type).apply(type, world, pos); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
blockentity/common/src/main/java/band/kessoku/lib/api/blockentity/Coordinators.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package band.kessoku.lib.api.blockentity; | ||
|
||
import band.kessoku.lib.api.data.Storage; | ||
import band.kessoku.lib.impl.ItemSidinator; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class Coordinators { | ||
public static final Coordinator<Storage<ItemStack>> ITEM = new Coordinator<>(); | ||
public static final Coordinator<ItemSidinator> ITEM_SIDE = new Coordinator<>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters