Skip to content

Commit d1de22a

Browse files
committed
Fixes
- Add block drops - Add BE inventory drops - Add blocks to `mineable` tags
1 parent 76cac09 commit d1de22a

8 files changed

Lines changed: 79 additions & 1 deletion

File tree

src/main/java/dev/falseresync/wizcraft/common/block/EnergizedWorktableBlock.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
import net.minecraft.block.entity.BlockEntity;
1414
import net.minecraft.block.entity.BlockEntityTicker;
1515
import net.minecraft.block.entity.BlockEntityType;
16+
import net.minecraft.block.entity.CampfireBlockEntity;
1617
import net.minecraft.entity.player.PlayerEntity;
1718
import net.minecraft.util.ActionResult;
1819
import net.minecraft.util.Hand;
1920
import net.minecraft.util.Identifier;
21+
import net.minecraft.util.ItemScatterer;
2022
import net.minecraft.util.hit.BlockHitResult;
2123
import net.minecraft.util.math.BlockPos;
2224
import net.minecraft.world.World;
@@ -74,6 +76,17 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
7476
return super.onUse(state, world, pos, player, hand, hit);
7577
}
7678

79+
@Override
80+
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
81+
if (!state.isOf(newState.getBlock())) {
82+
if (world.getBlockEntity(pos) instanceof EnergizedWorktableBlockEntity worktable) {
83+
ItemScatterer.spawn(world, pos, worktable.getInventory());
84+
}
85+
86+
super.onStateReplaced(state, world, pos, newState, moved);
87+
}
88+
}
89+
7790
@Override
7891
public Identifier getId() {
7992
return ID;

src/main/java/dev/falseresync/wizcraft/common/block/LensingPedestalBlock.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.mojang.serialization.MapCodec;
44
import dev.falseresync.wizcraft.common.Wizcraft;
5+
import dev.falseresync.wizcraft.common.block.entity.EnergizedWorktableBlockEntity;
56
import dev.falseresync.wizcraft.common.block.entity.LensingPedestalBlockEntity;
67
import dev.falseresync.wizcraft.api.HasId;
78
import dev.falseresync.wizcraft.common.WizUtil;
@@ -14,6 +15,7 @@
1415
import net.minecraft.util.ActionResult;
1516
import net.minecraft.util.Hand;
1617
import net.minecraft.util.Identifier;
18+
import net.minecraft.util.ItemScatterer;
1719
import net.minecraft.util.hit.BlockHitResult;
1820
import net.minecraft.util.math.BlockPos;
1921
import net.minecraft.util.shape.VoxelShape;
@@ -67,6 +69,17 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
6769
return super.onUse(state, world, pos, player, hand, hit);
6870
}
6971

72+
@Override
73+
public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean moved) {
74+
if (!state.isOf(newState.getBlock())) {
75+
if (world.getBlockEntity(pos) instanceof LensingPedestalBlockEntity pedestal) {
76+
ItemScatterer.spawn(world, pos, pedestal.getInventory());
77+
}
78+
79+
super.onStateReplaced(state, world, pos, newState, moved);
80+
}
81+
}
82+
7083
@Override
7184
public Identifier getId() {
7285
return ID;

src/main/java/dev/falseresync/wizcraft/common/block/WizBlocks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class WizBlocks {
1919

2020
static {
2121
LENS = r("lens", new Block(FabricBlockSettings.copyOf(Blocks.GLASS).luminance(1)));
22-
ENERGIZED_WORKTABLE = r(new EnergizedWorktableBlock(FabricBlockSettings.copyOf(Blocks.CRAFTING_TABLE)));
22+
ENERGIZED_WORKTABLE = r(new EnergizedWorktableBlock(FabricBlockSettings.copyOf(Blocks.CRAFTING_TABLE).requiresTool()));
2323
LENSING_PEDESTAL = r(new LensingPedestalBlock(FabricBlockSettings.copyOf(Blocks.BRICK_WALL)));
2424
}
2525

src/main/java/dev/falseresync/wizcraft/common/block/entity/EnergizedWorktableBlockEntity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ public NbtCompound toInitialChunkDataNbt() {
133133
return createNbt();
134134
}
135135

136+
public SimpleInventory getInventory() {
137+
return inventory;
138+
}
139+
136140
public InventoryStorage getStorage() {
137141
return storage;
138142
}

src/main/java/dev/falseresync/wizcraft/common/block/entity/LensingPedestalBlockEntity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public NbtCompound toInitialChunkDataNbt() {
6363
return createNbt();
6464
}
6565

66+
public SimpleInventory getInventory() {
67+
return inventory;
68+
}
69+
6670
public InventoryStorage getStorage() {
6771
return storage;
6872
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package dev.falseresync.wizcraft.datagen;
2+
3+
import dev.falseresync.wizcraft.common.block.WizBlocks;
4+
import dev.falseresync.wizcraft.common.item.WizItems;
5+
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
6+
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
7+
8+
public class WizBlockLootTableProvider extends FabricBlockLootTableProvider {
9+
protected WizBlockLootTableProvider(FabricDataOutput dataOutput) {
10+
super(dataOutput);
11+
}
12+
13+
@Override
14+
public void generate() {
15+
addDrop(WizBlocks.ENERGIZED_WORKTABLE, drops(WizItems.ENERGIZED_WORKTABLE));
16+
addDrop(WizBlocks.LENSING_PEDESTAL, drops(WizItems.LENSING_PEDESTAL));
17+
}
18+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package dev.falseresync.wizcraft.datagen;
2+
3+
import dev.falseresync.wizcraft.common.block.WizBlocks;
4+
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
5+
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
6+
import net.minecraft.registry.RegistryWrapper;
7+
import net.minecraft.registry.tag.BlockTags;
8+
9+
import java.util.concurrent.CompletableFuture;
10+
11+
public class WizBlockTagProvider extends FabricTagProvider.BlockTagProvider {
12+
public WizBlockTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
13+
super(output, registriesFuture);
14+
}
15+
16+
@Override
17+
protected void configure(RegistryWrapper.WrapperLookup arg) {
18+
getOrCreateTagBuilder(BlockTags.AXE_MINEABLE)
19+
.add(WizBlocks.ENERGIZED_WORKTABLE);
20+
getOrCreateTagBuilder(BlockTags.PICKAXE_MINEABLE)
21+
.add(WizBlocks.ENERGIZED_WORKTABLE)
22+
.add(WizBlocks.LENSING_PEDESTAL);
23+
}
24+
}

src/main/java/dev/falseresync/wizcraft/datagen/WizcraftDatagen.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
99
var pack = fabricDataGenerator.createPack();
1010
pack.addProvider(WizModelProvider::new);
1111
pack.addProvider(WizRecipeProvider::new);
12+
pack.addProvider(WizBlockLootTableProvider::new);
13+
pack.addProvider(WizBlockTagProvider::new);
1214
}
1315
}

0 commit comments

Comments
 (0)