upper for complete stacks
This commit is contained in:
parent
218c98ccfb
commit
0df9614d08
@ -9,7 +9,7 @@
|
|||||||
loader_version=0.14.8
|
loader_version=0.14.8
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.19.0.1
|
mod_version = 1.19.0.2
|
||||||
maven_group = de.jottyfan.minecraft
|
maven_group = de.jottyfan.minecraft
|
||||||
archives_base_name = quickiefabric
|
archives_base_name = quickiefabric
|
||||||
|
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
package de.jottyfan.minecraft.quickiefabric.blockentity;
|
||||||
|
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.block.entity.LootableContainerBlockEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jotty
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class BlockStackerEntity extends BlockEntity {
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(BlockStackerEntity.class);
|
||||||
|
|
||||||
|
public BlockStackerEntity(BlockPos blockPos, BlockState blockState) {
|
||||||
|
super(QuickieFabricBlockEntity.BLOCKSTACKER_ENTITY, blockPos, blockState);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void tick(World world, BlockPos pos, BlockState state, BlockStackerEntity entity) {
|
||||||
|
if (!world.isClient) {
|
||||||
|
BlockEntity source = world.getBlockEntity(pos.down());
|
||||||
|
BlockEntity dest = world.getBlockEntity(pos.up());
|
||||||
|
Boolean sourceIsLootable = source instanceof LootableContainerBlockEntity;
|
||||||
|
Boolean destIsLootable = dest instanceof LootableContainerBlockEntity;
|
||||||
|
if (sourceIsLootable && destIsLootable) {
|
||||||
|
LootableContainerBlockEntity lootableSource = (LootableContainerBlockEntity) source;
|
||||||
|
LootableContainerBlockEntity lootableDest = (LootableContainerBlockEntity) dest;
|
||||||
|
transferOneStack(lootableSource, lootableDest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void transferOneStack(LootableContainerBlockEntity source, LootableContainerBlockEntity dest) {
|
||||||
|
Integer sourceCounter = findItemStackPos(source, false);
|
||||||
|
Integer destCounter = findItemStackPos(dest, true);
|
||||||
|
// TODO: if stack.getItem().equals(source.getStack(sourceCounter).getItem() and stacksize < maxStackSize...
|
||||||
|
if (sourceCounter != null && destCounter != null) {
|
||||||
|
dest.setStack(destCounter, source.removeStack(sourceCounter));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Integer findItemStackPos(LootableContainerBlockEntity lcbe, Boolean empty) {
|
||||||
|
Integer counter = lcbe.size();
|
||||||
|
while (counter > 0) {
|
||||||
|
counter--;
|
||||||
|
ItemStack stack = lcbe.getStack(counter);
|
||||||
|
if (empty.equals(ItemStack.EMPTY.equals(stack))) {
|
||||||
|
return counter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ import net.minecraft.block.entity.BlockEntityType;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class QuickieFabricBlockEntity {
|
public class QuickieFabricBlockEntity {
|
||||||
|
public static BlockEntityType<BlockStackerEntity> BLOCKSTACKER_ENTITY;
|
||||||
public static BlockEntityType<ItemHoarderBlockEntity> ITEMHOARDER;
|
public static BlockEntityType<ItemHoarderBlockEntity> ITEMHOARDER;
|
||||||
public static BlockEntityType<MonsterHoarderBlockEntity> MONSTERHOARDER;
|
public static BlockEntityType<MonsterHoarderBlockEntity> MONSTERHOARDER;
|
||||||
public static BlockEntityType<EmptyLavaHoarderBlockEntity> EMPTYLAVAHOARDER;
|
public static BlockEntityType<EmptyLavaHoarderBlockEntity> EMPTYLAVAHOARDER;
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
package de.jottyfan.minecraft.quickiefabric.blocks;
|
||||||
|
|
||||||
|
import de.jottyfan.minecraft.quickiefabric.blockentity.BlockStackerEntity;
|
||||||
|
import de.jottyfan.minecraft.quickiefabric.blockentity.QuickieFabricBlockEntity;
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||||
|
import net.minecraft.block.BlockRenderType;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.BlockWithEntity;
|
||||||
|
import net.minecraft.block.Material;
|
||||||
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.block.entity.BlockEntityTicker;
|
||||||
|
import net.minecraft.block.entity.BlockEntityType;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jotty
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class BlockStacker extends BlockWithEntity {
|
||||||
|
|
||||||
|
public BlockStacker() {
|
||||||
|
super(FabricBlockSettings.of(Material.STONE).hardness(2.5f));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
|
||||||
|
return new BlockStackerEntity(pos, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockRenderType getRenderType(BlockState state) {
|
||||||
|
return BlockRenderType.MODEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state,
|
||||||
|
BlockEntityType<T> type) {
|
||||||
|
return checkType(type, QuickieFabricBlockEntity.BLOCKSTACKER_ENTITY,
|
||||||
|
(world1, pos, state1, be) -> BlockStackerEntity.tick(world1, pos, state1, be));
|
||||||
|
}
|
||||||
|
}
|
@ -25,4 +25,5 @@ public class QuickieBlocks {
|
|||||||
public static final BlockDrillWest DRILL_WEST = new BlockDrillWest();
|
public static final BlockDrillWest DRILL_WEST = new BlockDrillWest();
|
||||||
public static final BlockDrillNorth DRILL_NORTH = new BlockDrillNorth();
|
public static final BlockDrillNorth DRILL_NORTH = new BlockDrillNorth();
|
||||||
public static final BlockDrillstop DRILLSTOP = new BlockDrillstop();
|
public static final BlockDrillstop DRILLSTOP = new BlockDrillstop();
|
||||||
|
public static final BlockStacker BLOCKSTACKER = new BlockStacker();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import java.util.function.Predicate;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import de.jottyfan.minecraft.quickiefabric.blockentity.BlockStackerEntity;
|
||||||
import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockDownEntity;
|
import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockDownEntity;
|
||||||
import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockEastEntity;
|
import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockEastEntity;
|
||||||
import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockNorthEntity;
|
import de.jottyfan.minecraft.quickiefabric.blockentity.DrillBlockNorthEntity;
|
||||||
@ -163,6 +164,7 @@ public class RegistryManager {
|
|||||||
stacks.add(new ItemStack(QuickieBlocks.DRILL_WEST));
|
stacks.add(new ItemStack(QuickieBlocks.DRILL_WEST));
|
||||||
stacks.add(new ItemStack(QuickieBlocks.DRILL_NORTH));
|
stacks.add(new ItemStack(QuickieBlocks.DRILL_NORTH));
|
||||||
stacks.add(new ItemStack(QuickieBlocks.DRILLSTOP));
|
stacks.add(new ItemStack(QuickieBlocks.DRILLSTOP));
|
||||||
|
stacks.add(new ItemStack(QuickieBlocks.BLOCKSTACKER));
|
||||||
}).build();
|
}).build();
|
||||||
|
|
||||||
private static final void registerBlock(Block block, String name) {
|
private static final void registerBlock(Block block, String name) {
|
||||||
@ -193,16 +195,18 @@ public class RegistryManager {
|
|||||||
QuickieFabricBlockEntity.EMPTYLAVAHOARDER = (BlockEntityType<EmptyLavaHoarderBlockEntity>) registerBlockEntity(
|
QuickieFabricBlockEntity.EMPTYLAVAHOARDER = (BlockEntityType<EmptyLavaHoarderBlockEntity>) registerBlockEntity(
|
||||||
"emptylavahoarderblockentity", EmptyLavaHoarderBlockEntity::new, QuickieBlocks.EMPTYLAVAHOARDER,
|
"emptylavahoarderblockentity", EmptyLavaHoarderBlockEntity::new, QuickieBlocks.EMPTYLAVAHOARDER,
|
||||||
QuickieBlocks.LAVAHOARDER);
|
QuickieBlocks.LAVAHOARDER);
|
||||||
QuickieFabricBlockEntity.DRILL_DOWN = (BlockEntityType<DrillBlockDownEntity>) registerBlockEntity("drillblockdownentity",
|
QuickieFabricBlockEntity.DRILL_DOWN = (BlockEntityType<DrillBlockDownEntity>) registerBlockEntity(
|
||||||
DrillBlockDownEntity::new, QuickieBlocks.DRILL_DOWN);
|
"drillblockdownentity", DrillBlockDownEntity::new, QuickieBlocks.DRILL_DOWN);
|
||||||
QuickieFabricBlockEntity.DRILL_EAST = (BlockEntityType<DrillBlockEastEntity>) registerBlockEntity("drillblockeastentity",
|
QuickieFabricBlockEntity.DRILL_EAST = (BlockEntityType<DrillBlockEastEntity>) registerBlockEntity(
|
||||||
DrillBlockEastEntity::new, QuickieBlocks.DRILL_EAST);
|
"drillblockeastentity", DrillBlockEastEntity::new, QuickieBlocks.DRILL_EAST);
|
||||||
QuickieFabricBlockEntity.DRILL_SOUTH = (BlockEntityType<DrillBlockSouthEntity>) registerBlockEntity("drillblocksouthentity",
|
QuickieFabricBlockEntity.DRILL_SOUTH = (BlockEntityType<DrillBlockSouthEntity>) registerBlockEntity(
|
||||||
DrillBlockSouthEntity::new, QuickieBlocks.DRILL_SOUTH);
|
"drillblocksouthentity", DrillBlockSouthEntity::new, QuickieBlocks.DRILL_SOUTH);
|
||||||
QuickieFabricBlockEntity.DRILL_WEST = (BlockEntityType<DrillBlockWestEntity>) registerBlockEntity("drillblockwestentity",
|
QuickieFabricBlockEntity.DRILL_WEST = (BlockEntityType<DrillBlockWestEntity>) registerBlockEntity(
|
||||||
DrillBlockWestEntity::new, QuickieBlocks.DRILL_WEST);
|
"drillblockwestentity", DrillBlockWestEntity::new, QuickieBlocks.DRILL_WEST);
|
||||||
QuickieFabricBlockEntity.DRILL_NORTH = (BlockEntityType<DrillBlockNorthEntity>) registerBlockEntity("drillblocknorthentity",
|
QuickieFabricBlockEntity.DRILL_NORTH = (BlockEntityType<DrillBlockNorthEntity>) registerBlockEntity(
|
||||||
DrillBlockNorthEntity::new, QuickieBlocks.DRILL_NORTH);
|
"drillblocknorthentity", DrillBlockNorthEntity::new, QuickieBlocks.DRILL_NORTH);
|
||||||
|
QuickieFabricBlockEntity.BLOCKSTACKER_ENTITY = (BlockEntityType<BlockStackerEntity>) registerBlockEntity(
|
||||||
|
"blockstackerentity", BlockStackerEntity::new, QuickieBlocks.BLOCKSTACKER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void registerBlocks() {
|
public static final void registerBlocks() {
|
||||||
@ -226,6 +230,7 @@ public class RegistryManager {
|
|||||||
registerBlock(QuickieBlocks.DRILL_WEST, "drillwest");
|
registerBlock(QuickieBlocks.DRILL_WEST, "drillwest");
|
||||||
registerBlock(QuickieBlocks.DRILL_NORTH, "drillnorth");
|
registerBlock(QuickieBlocks.DRILL_NORTH, "drillnorth");
|
||||||
registerBlock(QuickieBlocks.DRILLSTOP, "drillstop");
|
registerBlock(QuickieBlocks.DRILLSTOP, "drillstop");
|
||||||
|
registerBlock(QuickieBlocks.BLOCKSTACKER, "blockstacker");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void registerItems() {
|
public static final void registerItems() {
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"": {
|
||||||
|
"model": "quickiefabric:block/blockstacker"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -62,7 +62,9 @@
|
|||||||
"block.quickiefabric.drillwest": "West-Bohrer",
|
"block.quickiefabric.drillwest": "West-Bohrer",
|
||||||
"block.quickiefabric.drillnorth": "Nord-Bohrer",
|
"block.quickiefabric.drillnorth": "Nord-Bohrer",
|
||||||
"block.quickiefabric.drillstop": "Bohrerstopper",
|
"block.quickiefabric.drillstop": "Bohrerstopper",
|
||||||
|
"block.quickiefabric.blockstacker": "Blockstapler",
|
||||||
"container.quickiefabric.backpack": "Rucksack",
|
"container.quickiefabric.backpack": "Rucksack",
|
||||||
|
"container.quickiefabric.blockstacker": "Blockstapler",
|
||||||
"msg.buildingplan.start": "beginne Konstruktionsaufnahme bei %s,%s,%s",
|
"msg.buildingplan.start": "beginne Konstruktionsaufnahme bei %s,%s,%s",
|
||||||
"msg.buildingplan.end": "beende Konstruktionsaufnahme bei %s,%s,%s",
|
"msg.buildingplan.end": "beende Konstruktionsaufnahme bei %s,%s,%s",
|
||||||
"msg.buildingplan.null": "Der Bauplan ist kaputt.",
|
"msg.buildingplan.null": "Der Bauplan ist kaputt.",
|
||||||
|
@ -62,7 +62,9 @@
|
|||||||
"block.quickiefabric.drillwest": "west drill",
|
"block.quickiefabric.drillwest": "west drill",
|
||||||
"block.quickiefabric.drillnorth": "north drill",
|
"block.quickiefabric.drillnorth": "north drill",
|
||||||
"block.quickiefabric.drillstop": "drill stopper",
|
"block.quickiefabric.drillstop": "drill stopper",
|
||||||
|
"block.quickiefabric.blockstacker": "block stacker",
|
||||||
"container.quickiefabric.backpack": "backpack",
|
"container.quickiefabric.backpack": "backpack",
|
||||||
|
"container.quickiefabric.blockstacker": "block stacker",
|
||||||
"msg.buildingplan.start": "started recording of construction at %s,%s,%s",
|
"msg.buildingplan.start": "started recording of construction at %s,%s,%s",
|
||||||
"msg.buildingplan.end": "finished recording of construction at %s,%s,%s",
|
"msg.buildingplan.end": "finished recording of construction at %s,%s,%s",
|
||||||
"msg.buildingplan.null": "The building plan is damaged.",
|
"msg.buildingplan.null": "The building plan is damaged.",
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "block/cube_all",
|
||||||
|
"textures": {
|
||||||
|
"all": "quickiefabric:block/blockstacker"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"parent": "quickiefabric:block/blockstacker",
|
||||||
|
"display": {
|
||||||
|
"thirdperson": {
|
||||||
|
"rotation": [ 10, -45, 170 ],
|
||||||
|
"translation": [ 0, 1.5, -2.75 ],
|
||||||
|
"scale": [ 0.375, 0.375, 0.375 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
" s ",
|
||||||
|
"s s",
|
||||||
|
"s s"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"s": {
|
||||||
|
"item": "quickiefabric:speedpowder"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "quickiefabric:blockstacker",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user