Skip to content

Commit

Permalink
fix: no items dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeronimo97 committed Oct 10, 2024
1 parent 2d92467 commit c73a3ef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/main/java/com/troblecodings/signals/blocks/BasicBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootContext.Builder;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.world.IBlockReader;

public class BasicBlock extends Block {

private static final Map<TileEntitySupplierWrapper, String> BLOCK_NAMES = new HashMap<>();
private static final Map<TileEntitySupplierWrapper, List<BasicBlock>> BLOCK_SUPPLIER = new HashMap<>();
public static final Map<TileEntitySupplierWrapper, TileEntityType<?>> BLOCK_ENTITYS = new HashMap<>();
private static final Map<TileEntitySupplierWrapper, List<BasicBlock>> BLOCK_SUPPLIER =
new HashMap<>();
public static final Map<TileEntitySupplierWrapper, TileEntityType<?>> BLOCK_ENTITYS =
new HashMap<>();

public BasicBlock(final Properties properties) {
super(properties);
Expand Down Expand Up @@ -58,8 +62,8 @@ public static void prepare() {
for (int i = 0; i < blocks.size(); i++) {
allBlocks[i] = blocks.get(i);
}
final Supplier<TileEntity> supplier = () -> wrapper
.supply(new TileEntityInfo().with(type.get()));
final Supplier<TileEntity> supplier =
() -> wrapper.supply(new TileEntityInfo().with(type.get()));
type.set(TileEntityType.Builder.of(supplier, allBlocks).build(null));
type.get().setRegistryName(name);
BLOCK_ENTITYS.put(wrapper, type.get());
Expand All @@ -75,4 +79,11 @@ public boolean hasTileEntity(final BlockState state) {
public TileEntity createTileEntity(final BlockState state, final IBlockReader world) {
return BLOCK_ENTITYS.get(getSupplierWrapper().get()).create();
}

@Override
public List<ItemStack> getDrops(final BlockState state, final Builder builder) {
List<ItemStack> drops = new ArrayList<ItemStack>();
drops.add(new ItemStack(this.getBlock().asItem()));
return drops;
}
}
8 changes: 8 additions & 0 deletions src/main/java/com/troblecodings/signals/blocks/Signal.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ public ItemStack getCloneItemStack(final IBlockReader getter, final BlockPos pos
return getPlacementtool().getDefaultInstance();
}

@Override
public List<ItemStack> getDrops(final BlockState state,
final net.minecraft.loot.LootContext.Builder builder) {
List<ItemStack> drops = new ArrayList<ItemStack>();
drops.add(getPlacementtool().getDefaultInstance());
return drops;
}

@Override
protected void createBlockStateDefinition(final Builder<Block, BlockState> builder) {
final List<SEProperty> properties = new ArrayList<>();
Expand Down

0 comments on commit c73a3ef

Please sign in to comment.