Skip to content

Commit

Permalink
Not Transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
Chemiofitor4096 committed Nov 30, 2024
1 parent ffec7db commit ff6c35b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 15 deletions.

This file was deleted.

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);
}
}
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<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public class KessokuBlockEntity {
public static final Marker MARKER = MarkerFactory.getMarker("[" + NAME +"]");

public void init() {
BlockEntityCoordinator.add(BlockEntityType.FURNACE, Storage::inventory);
BlockEntityCoordinator.add(BlockEntityType.CHEST, Storage::inventory);
BlockEntityCoordinator.add(
Coordinators.ITEM.add(BlockEntityType.FURNACE, Storage::inventory);
Coordinators.ITEM.add(BlockEntityType.CHEST, Storage::inventory);
Coordinators.ITEM_SIDE.add(
BlockEntityType.FURNACE,
(blockentity) -> ItemSidinator.builder().side(1).bottom(2, 1).top(0).build()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@

@FunctionalInterface
public interface DataAccess<T, S extends DataStructure> {
S get(T target);
S to(T target);
}

0 comments on commit ff6c35b

Please sign in to comment.