Skip to content

Commit 4215978

Browse files
committed
Raw block id command and CustomBlocks now use raw block id
1 parent e1df2b2 commit 4215978

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package nekiplay.meteorplus.features.commands;
2+
3+
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
4+
import meteordevelopment.meteorclient.commands.Command;
5+
import net.minecraft.block.Block;
6+
import net.minecraft.block.BlockState;
7+
import net.minecraft.command.CommandSource;
8+
import net.minecraft.util.hit.HitResult;
9+
import net.minecraft.util.math.BlockPos;
10+
11+
public class BlockRawIdCommand extends Command {
12+
public BlockRawIdCommand() {
13+
super("rawblockid", "Get raw block id under mouse");
14+
}
15+
public void build(LiteralArgumentBuilder<CommandSource> builder) {
16+
builder.executes(context -> {
17+
if (mc.crosshairTarget != null && mc.crosshairTarget.getType() == HitResult.Type.BLOCK) {
18+
BlockPos pos = new BlockPos((int) mc.crosshairTarget.getPos().x, (int) mc.crosshairTarget.getPos().y, (int) mc.crosshairTarget.getPos().z);
19+
BlockState state = mc.world.getBlockState(pos);
20+
int raw_id = Block.getRawIdFromState(state);
21+
info(String.valueOf(raw_id));
22+
}
23+
return SINGLE_SUCCESS;
24+
});
25+
}
26+
}

src/main/java/nekiplay/meteorplus/features/modules/world/customblocks/CustomBlocksModule.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,9 @@ private boolean isValidBlockForReplace(Block block) {
100100
}
101101

102102
private void setBlock(BlockPos pos, CustomBlockData data) {
103-
Item item = Item.byRawId(data.block_id);
104-
Block block = Block.getBlockFromItem(item);
105-
BlockState state = block.getDefaultState();
103+
BlockState block = Block.getStateFromRawId(data.block_id);
106104

107-
mc.world.setBlockState(pos, state);
105+
mc.world.setBlockState(pos, block);
108106
}
109107

110108
@EventHandler

0 commit comments

Comments
 (0)