Skip to content

Commit

Permalink
feat: glass block won't drop unless silk touch
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Jun 15, 2024
1 parent 3d6096f commit 1360184
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.allaymc.server.block.component.glass;

import org.allaymc.api.block.BlockBehavior;
import org.allaymc.api.block.type.BlockState;
import org.allaymc.api.block.type.BlockType;
import org.allaymc.api.item.ItemStack;
import org.allaymc.api.utils.Utils;
import org.allaymc.server.block.component.common.BlockBaseComponentImpl;

/**
* Allay Project 2024/6/15
*
* @author daoge_cmd
*/
public class BlockGlassBaseComponentImpl extends BlockBaseComponentImpl {
public BlockGlassBaseComponentImpl(BlockType<? extends BlockBehavior> blockType) {
super(blockType);
}

@Override
public ItemStack[] getDrops(BlockState blockState, ItemStack usedItem) {
return Utils.EMPTY_ITEM_STACK_ARRAY;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.allaymc.server.block.type;

import org.allaymc.api.block.interfaces.*;
import org.allaymc.api.block.interfaces.glass.BlockGlassBehavior;
import org.allaymc.api.block.interfaces.stairs.*;
import org.allaymc.api.block.interfaces.torch.BlockColoredTorchBpBehavior;
import org.allaymc.api.block.interfaces.torch.BlockColoredTorchRgBehavior;
Expand All @@ -20,6 +21,7 @@
import org.allaymc.server.block.component.common.BlockAttributeComponentImpl;
import org.allaymc.server.block.component.craftingtable.BlockCraftingTableBaseComponentImpl;
import org.allaymc.server.block.component.doubleplant.BlockDoublePlantBaseComponentImpl;
import org.allaymc.server.block.component.glass.BlockGlassBaseComponentImpl;
import org.allaymc.server.block.component.grassblock.BlockGrassBlockBaseComponentImpl;
import org.allaymc.server.block.component.stairs.BlockStairsBaseComponentImpl;
import org.allaymc.server.block.component.tallgrass.BlockTallgrassBaseComponentImpl;
Expand Down Expand Up @@ -57,6 +59,14 @@ public static void initDoublePlant() {
.build();
}

public static void initGlass() {
BlockTypes.GLASS_TYPE = BlockTypeBuilder
.builder(BlockGlassBehavior.class)
.vanillaBlock(VanillaBlockId.GLASS)
.setBlockBaseComponentSupplier(BlockGlassBaseComponentImpl::new)
.build();
}

public static void initBarrel() {
BlockTypes.BARREL_TYPE = BlockTypeBuilder
.builder(BlockBarrelBehavior.class)
Expand Down

0 comments on commit 1360184

Please sign in to comment.