mirror of
https://github.com/italicsjenga/valence.git
synced 2024-12-23 22:41:30 +11:00
Add replaceable boolean to block states (#116)
This commit is contained in:
parent
59ca1ab573
commit
ad153159dd
|
@ -46,6 +46,7 @@ struct State {
|
||||||
id: u16,
|
id: u16,
|
||||||
luminance: u8,
|
luminance: u8,
|
||||||
opaque: bool,
|
opaque: bool,
|
||||||
|
replaceable: bool,
|
||||||
collision_shapes: Vec<u16>,
|
collision_shapes: Vec<u16>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +114,18 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
})
|
})
|
||||||
.collect::<TokenStream>();
|
.collect::<TokenStream>();
|
||||||
|
|
||||||
|
let state_to_replaceable_arms = blocks
|
||||||
|
.iter()
|
||||||
|
.flat_map(|b| {
|
||||||
|
b.states.iter().filter(|s| s.replaceable).map(|s| {
|
||||||
|
let id = s.id;
|
||||||
|
quote! {
|
||||||
|
#id => true,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.collect::<TokenStream>();
|
||||||
|
|
||||||
let shapes = shapes.iter().map(|s| {
|
let shapes = shapes.iter().map(|s| {
|
||||||
let min_x = s.min_x;
|
let min_x = s.min_x;
|
||||||
let min_y = s.min_y;
|
let min_y = s.min_y;
|
||||||
|
@ -517,6 +530,13 @@ pub fn build() -> anyhow::Result<TokenStream> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const fn is_replaceable(self) -> bool {
|
||||||
|
match self.0 {
|
||||||
|
#state_to_replaceable_arms
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const SHAPES: [[f64; 6]; #shape_count] = [
|
const SHAPES: [[f64; 6]; #shape_count] = [
|
||||||
#(#shapes,)*
|
#(#shapes,)*
|
||||||
];
|
];
|
||||||
|
|
21448
extracted/blocks.json
21448
extracted/blocks.json
File diff suppressed because it is too large
Load diff
|
@ -3,6 +3,7 @@ package rs.valence.extractor.extractors;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.EmptyBlockView;
|
import net.minecraft.world.EmptyBlockView;
|
||||||
|
@ -60,6 +61,7 @@ public class Blocks implements Main.Extractor {
|
||||||
stateJson.addProperty("id", id);
|
stateJson.addProperty("id", id);
|
||||||
stateJson.addProperty("luminance", state.getLuminance());
|
stateJson.addProperty("luminance", state.getLuminance());
|
||||||
stateJson.addProperty("opaque", state.isOpaque());
|
stateJson.addProperty("opaque", state.isOpaque());
|
||||||
|
stateJson.addProperty("replaceable", state.getMaterial().isReplaceable());
|
||||||
|
|
||||||
if (block.getDefaultState().equals(state)) {
|
if (block.getDefaultState().equals(state)) {
|
||||||
blockJson.addProperty("default_state_id", id);
|
blockJson.addProperty("default_state_id", id);
|
||||||
|
|
|
@ -227,7 +227,7 @@ pub struct Client<C: Config> {
|
||||||
new_game_mode: GameMode,
|
new_game_mode: GameMode,
|
||||||
old_game_mode: GameMode,
|
old_game_mode: GameMode,
|
||||||
settings: Option<Settings>,
|
settings: Option<Settings>,
|
||||||
dug_block_sequence: i32,
|
block_change_sequence: i32,
|
||||||
/// Should be sent after login packet.
|
/// Should be sent after login packet.
|
||||||
msgs_to_send: Vec<Text>,
|
msgs_to_send: Vec<Text>,
|
||||||
bar_to_send: Option<Text>,
|
bar_to_send: Option<Text>,
|
||||||
|
@ -301,7 +301,7 @@ impl<C: Config> Client<C> {
|
||||||
new_game_mode: GameMode::Survival,
|
new_game_mode: GameMode::Survival,
|
||||||
old_game_mode: GameMode::Survival,
|
old_game_mode: GameMode::Survival,
|
||||||
settings: None,
|
settings: None,
|
||||||
dug_block_sequence: 0,
|
block_change_sequence: 0,
|
||||||
msgs_to_send: Vec::new(),
|
msgs_to_send: Vec::new(),
|
||||||
bar_to_send: None,
|
bar_to_send: None,
|
||||||
resource_pack_to_send: None,
|
resource_pack_to_send: None,
|
||||||
|
@ -1016,7 +1016,7 @@ impl<C: Config> Client<C> {
|
||||||
C2sPlayPacket::PlayerAbilitiesC2s(_) => {}
|
C2sPlayPacket::PlayerAbilitiesC2s(_) => {}
|
||||||
C2sPlayPacket::PlayerAction(p) => {
|
C2sPlayPacket::PlayerAction(p) => {
|
||||||
if p.sequence.0 != 0 {
|
if p.sequence.0 != 0 {
|
||||||
self.dug_block_sequence = p.sequence.0;
|
self.block_change_sequence = p.sequence.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.events.push_back(match p.status {
|
self.events.push_back(match p.status {
|
||||||
|
@ -1100,7 +1100,7 @@ impl<C: Config> Client<C> {
|
||||||
face: p.face,
|
face: p.face,
|
||||||
cursor_pos: p.cursor_pos,
|
cursor_pos: p.cursor_pos,
|
||||||
head_inside_block: p.head_inside_block,
|
head_inside_block: p.head_inside_block,
|
||||||
sequence: p.sequence,
|
sequence: dbg!(p.sequence),
|
||||||
}),
|
}),
|
||||||
C2sPlayPacket::UseItem(_) => {}
|
C2sPlayPacket::UseItem(_) => {}
|
||||||
}
|
}
|
||||||
|
@ -1361,15 +1361,15 @@ impl<C: Config> Client<C> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Acknowledge broken blocks.
|
// Acknowledge broken/placed blocks.
|
||||||
if self.dug_block_sequence != 0 {
|
if self.block_change_sequence != 0 {
|
||||||
send_packet(
|
send_packet(
|
||||||
&mut self.send,
|
&mut self.send,
|
||||||
AcknowledgeBlockChange {
|
AcknowledgeBlockChange {
|
||||||
sequence: VarInt(self.dug_block_sequence),
|
sequence: VarInt(self.block_change_sequence),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
self.dug_block_sequence = 0;
|
self.block_change_sequence = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Teleport the player.
|
// Teleport the player.
|
||||||
|
|
Loading…
Reference in a new issue