mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 19:28:49 -04:00
parent
5bea8f41b6
commit
a0663d7338
@ -802,6 +802,12 @@ pub const MeshSelection = struct { // MARK: MeshSelection
|
||||
updateBlockAndSendUpdate(inventory, slot, selectedPos[0], selectedPos[1], selectedPos[2], oldBlock, block);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if(rotationMode.modifyBlock(&block, itemBlock)) {
|
||||
if(!canPlaceBlock(selectedPos, block)) return;
|
||||
updateBlockAndSendUpdate(inventory, slot, selectedPos[0], selectedPos[1], selectedPos[2], oldBlock, block);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Check the block in front of it:
|
||||
const neighborPos = posBeforeBlock;
|
||||
|
@ -35,6 +35,9 @@ pub const RotationMode = struct { // MARK: RotationMode
|
||||
fn updateData(_: *Block, _: Neighbor, _: Block) bool {
|
||||
return false;
|
||||
}
|
||||
fn modifyBlock(_: *Block, _: u16) bool {
|
||||
return false;
|
||||
}
|
||||
fn rayIntersection(block: Block, _: ?main.items.Item, relativePlayerPos: Vec3f, playerDir: Vec3f) ?RayIntersectionResult {
|
||||
return rayModelIntersection(blocks.meshes.model(block), relativePlayerPos, playerDir);
|
||||
}
|
||||
@ -115,6 +118,8 @@ pub const RotationMode = struct { // MARK: RotationMode
|
||||
/// Updates data of a placed block if the RotationMode dependsOnNeighbors.
|
||||
updateData: *const fn(block: *Block, neighbor: Neighbor, neighborBlock: Block) bool = &DefaultFunctions.updateData,
|
||||
|
||||
modifyBlock: *const fn(block: *Block, newType: u16) bool = DefaultFunctions.modifyBlock,
|
||||
|
||||
rayIntersection: *const fn(block: Block, item: ?main.items.Item, relativePlayerPos: Vec3f, playerDir: Vec3f) ?RayIntersectionResult = &DefaultFunctions.rayIntersection,
|
||||
|
||||
onBlockBreaking: *const fn(item: ?main.items.Item, relativePlayerPos: Vec3f, playerDir: Vec3f, currentData: *Block) void = &DefaultFunctions.onBlockBreaking,
|
||||
@ -947,6 +952,19 @@ pub const RotationModes = struct {
|
||||
modelCache = modelIndex;
|
||||
return modelIndex;
|
||||
}
|
||||
|
||||
pub fn generateData(_: *main.game.World, _: Vec3i, _: Vec3f, _: Vec3f, _: Vec3i, _: ?Neighbor, _: *Block, _: Block, _: bool) bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
pub fn modifyBlock(block: *Block, newBlockType: u16) bool {
|
||||
if(block.transparent() or block.viewThrough()) return false;
|
||||
if(!main.models.models.items[main.blocks.meshes.modelIndexStart(block.*)].allNeighborsOccluded) return false;
|
||||
if(block.data != 0) return false;
|
||||
block.data = block.typ;
|
||||
block.typ = newBlockType;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user