Pack as requested
only works for 1.19.30
sub minor updates don't matter. it will work as long as the current beta version for release is 1.6.0-beta
import { world, Vector, system, Direction } from '@minecraft/server';
const DirectionToVector = {
[Direction.Down]: Vector.down,
[Direction.Up]: Vector.up,
[Direction.North]: Vector.forward,
[Direction.South]: Vector.back,
[Direction.West]: Vector.left,
[Direction.East]: Vector.right,
};
function floorVector3(vector) {
return {
x: Math.floor(vector.x),
y: Math.floor(vector.y),
z: Math.floor(vector.z),
};
}
world.beforeEvents.itemUseOn.subscribe(async (event) => {
try {
const { source, block, blockFace, faceLocation } = event;
// logVector3(DirectionToVector[blockFace]);
const placeLocation = Vector.add(block.location, DirectionToVector[blockFace]);
const predictedPlaceLocation = Vector.add(block.location, floorVector3(faceLocation));
await null;
world.sendMessage('============================================');
world.sendMessage(JSON.stringify({ "§7not Floored faceLocation§f": faceLocation }, null));
world.sendMessage(JSON.stringify({ blockFace, "§7Floored faceLocation§f": floorVector3(faceLocation) }));
world.sendMessage('§7Floored faceLocation + block.location: §cminecraft:villager_angry paricle and red_stained_glass');
world.sendMessage('§7blockFace converted to vector + block.location: §aminecraft:villager_happy paricle and lime_stained_glass\n§7(if place location for both is correct it will be lime)');
world.sendMessage('§7block.location: §fminecraft:endrod paricle(will be where faceLocation is relitive from) and glass ');
source.dimension.spawnParticle('minecraft:villager_angry', predictedPlaceLocation);
source.dimension.spawnParticle('minecraft:endrod', block.location);
source.dimension.spawnParticle('minecraft:villager_happy', placeLocation);
source.dimension.getBlock(block.location).setType('glass');
source.dimension.getBlock(predictedPlaceLocation).setType('red_stained_glass');
source.dimension.getBlock(placeLocation).setType('lime_stained_glass');
} catch (error) {
console.warn(error, error.stack);
}
});
function rotationToDirection(rotation) {
let { x, y } = rotation;
x = (x / 45 + 2) | 0;
y = ((y + 45) / 90 + 2) | 0;
if (x < 1) return 'Up (y + 1)';
else if ((x > 2)) return 'Down (y - 1)';
switch (y) {
case 2:
return 'North (z + 1)';
case 4:
case 0:
return 'South (z - 1)';
case 1:
return 'East (x + 1)';
case 3:
return 'West (x - 1)';
}
};
system.runInterval(() => {
const players = world.getAllPlayers();
players.forEach(player => {
player.onScreenDisplay.setActionBar(rotationToDirection(player.getRotation()) ?? "None" + '\n(based off Direction Enum on docs)');
});
});
reference for each direction: https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/direction
The docs could be wrong for why blockFace is backwards in the z direction but idk
Edit:
cleaned up the code so it better represents the cases and doesn't need content log on
Pack has the same code
affects 1.20.30
affects 1.19.73
The code below ran in preview 1.19.70.22 if the player uses on the block, for instance, x: 1, y: 2, z: 3. should output:
import { world } from "@minecraft/server";
world.events.beforeItemUseOn.subscribe((event) => {
const blockLocation = event.getBlockLocation();
let keys = [];
for (const key in event) {
keys.push(key);
}
const { x, y, z } = blockLocation ?? {};
console.warn('hello, ', x, y, z, keys.join(', '));
});
[Scripting][warning]-hello, 1 2 3 getBlockLocation, item, source, blockFace, faceLocationX, faceLocationY, cancel
but instead outputs
[Scripting][warning]-hello, undefined undefined undefined getBlockLocation, item, source, blockFace, faceLocationX, faceLocationY, cancel
As you can see the method getBlockLocation is defined on the BeforeItemUseOnEvent class instance passed as a parameter in the event callback so the method always returns undefined.
new code and console output to further prove getBlockLocation is defined on the BeforeItemUseOnEvent instance.
import { world } from "@minecraft/server";world.events.beforeItemUseOn.subscribe((event) => {
const blockLocation = event.getBlockLocation();
let eventClone = {};
for (const key in event) {
eventClone[key] = typeof event[key];
}
const { x = 'undefined', y = 'undefined', z = 'undefined' } = blockLocation ?? {};
world.sendMessage(JSON.stringify({ t: 'test', blockLocation: { x, y, z }, eventClone }, null, 4));
});
[media]
Happens in 1.19.20 as well.
this happens in 1.18.12.
Happens in 1.18.0 realms
still happens but a loading bar appears.
happens in 1.17.41
You do have to wait a about 10 seconds for the op to be removed since the command will execute immediately after the op is removed and will not run after a few seconds.
you set 1 to a string ie "1" it must be an int ie "minecraft:direction": 1
I added a sample world for testing. Just remove op for the experiment and use op for the control group. The interact thing isn’t required it just fixes the issue of players completely acting like npcs
Yes.
Apparently, if a player is wearing armor and they receive an amount damage that would kill them without armor, it triggers as fatal even though the player is not dead.
Steps to Reproduce:
1. create a damage sensor component in player.json with a test for fatal that runs a command on "other" which is the attacker.
2. give the player a full set of any diamond armor.
3. crit hit the player with a sharpness 5 diamond sword.
Observed Results:
the command runs even though the player attacked is alive
Expected Results:
no command is run
still an issue in 1.17.2
yes
It is still a issue
Still a issue in 1.16.221
Steps to Reproduce:
1. Download the More Tools Addon at https://mcpedl.com/more-tools-addon/ and apply the addon.
2. make sure and check all experiments but /gametest.
3. run /give @s sp:lapis_chestplate and /give @s sp:redstone_chestplate.
4. equip one of the chestplates
5. Try and equip the other chestplate from the hotbar.
Observed Results:
It does not replace.
Expected Results:
Works like vanilla armor and replaces.
It is an issue with the latest version.
in 1.20.51 the hierarchy (heirs to the leader and the leader) switches to the new villagers when more villagers are added to the village via breeding. Will do more testing soon.
Edit.
even if the leader can sleep in its bed, the leader position can be assigned to newly created villages breading or spawning.