Skip to content

Commit fc80ba0

Browse files
committed
Raw block id command and CustomBlocks now use raw block id
1 parent 75c07a8 commit fc80ba0

3 files changed

Lines changed: 32 additions & 7 deletions

File tree

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

src/main/java/nekiplay/meteorplus/features/commands/ItemRawIdCommand.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,5 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
2525
}
2626
return SINGLE_SUCCESS;
2727
});
28-
29-
3028
}
3129
}

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,8 @@ 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();
106-
107-
mc.world.setBlockState(pos, state);
103+
BlockState block = Block.getStateFromRawId(data.block_id);
104+
mc.world.setBlockState(pos, block);
108105
}
109106

110107
@EventHandler

0 commit comments

Comments
 (0)