Skip to content

Commit c307dd4

Browse files
committed
Raw block id command and CustomBlocks now use raw block id
1 parent 68f788a commit c307dd4

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
@@ -99,11 +99,9 @@ private boolean isValidBlockForReplace(Block block) {
9999
}
100100

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

106-
mc.world.setBlockState(pos, state);
104+
mc.world.setBlockState(pos, block);
107105
}
108106

109107
@EventHandler

0 commit comments

Comments
 (0)