use of org.spongepowered.math.vector.Vector3d in project SpongeCommon by SpongePowered.
the class FireworkRocketItemMixin method impl$throwConstructPreEvent.
/**
* Private method for bridging the duplicate between
* {@link #spongeImpl$ThrowPreBeforeSpawning(World, PlayerEntity, Hand, CallbackInfoReturnable, ItemStack)} and
* {@link #spongeImpl$ThrowPrimeEventsIfCancelled(ItemUseContext, CallbackInfoReturnable)}
* since both follow the same logic, but differ in how they are called.
*
* @param world The world
* @param player The player
* @param usedItem The used item
* @return True if the event is cancelled and the callback needs to be cancelled
*/
private boolean impl$throwConstructPreEvent(final Level world, final net.minecraft.world.entity.player.Player player, final ItemStack usedItem) {
if (ShouldFire.CONSTRUCT_ENTITY_EVENT_PRE && !((LevelBridge) world).bridge$isFake()) {
try (final CauseStackManager.StackFrame frame = PhaseTracker.getCauseStackManager().pushCauseFrame()) {
frame.addContext(EventContextKeys.USED_ITEM, ItemStackUtil.snapshotOf(usedItem));
frame.addContext(EventContextKeys.PROJECTILE_SOURCE, (ProjectileSource) player);
frame.pushCause(player);
final ConstructEntityEvent.Pre event = SpongeEventFactory.createConstructEntityEventPre(frame.currentCause(), ServerLocation.of((ServerWorld) world, player.getX(), player.getY(), player.getZ()), new Vector3d(0, 0, 0), EntityTypes.FIREWORK_ROCKET.get());
return SpongeCommon.post(event);
}
}
return false;
}
use of org.spongepowered.math.vector.Vector3d in project SpongeCommon by SpongePowered.
the class SpongeAABBTest method testContainsCoordinates.
@Test
void testContainsCoordinates() {
final AABB aabb = new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(7, 10, 13));
Assertions.assertTrue(aabb.contains(5, 3, 11));
Assertions.assertTrue(aabb.contains(7, 3, 11));
Assertions.assertTrue(aabb.contains(5, 4, 11));
Assertions.assertTrue(aabb.contains(5, 3, 13));
Assertions.assertFalse(aabb.contains(-1, 3, 11));
Assertions.assertFalse(aabb.contains(5, 11, 11));
Assertions.assertFalse(aabb.contains(5, 3, 14));
}
use of org.spongepowered.math.vector.Vector3d in project SpongeCommon by SpongePowered.
the class SpongeAABBTest method testOffsetVector3i.
@Test
void testOffsetVector3i() {
final AABB aabb1 = new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(7, 10, 13));
final AABB aabb2 = new SpongeAABB(new Vector3d(11, 0, 4), new Vector3d(17, 8, 14));
Assertions.assertEquals(aabb2, aabb1.offset(new Vector3i(10, -2, 1)));
}
use of org.spongepowered.math.vector.Vector3d in project SpongeCommon by SpongePowered.
the class SpongeAABBTest method testContainsVector3i.
@Test
void testContainsVector3i() {
final AABB aabb = new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(7, 10, 13));
Assertions.assertTrue(aabb.contains(new Vector3i(5, 3, 11)));
Assertions.assertFalse(aabb.contains(new Vector3i(-1, 3, 11)));
Assertions.assertFalse(aabb.contains(new Vector3i(5, 11, 11)));
Assertions.assertFalse(aabb.contains(new Vector3i(5, 3, 14)));
}
use of org.spongepowered.math.vector.Vector3d in project SpongeCommon by SpongePowered.
the class SpongeAABBTest method testOffsetVector3d.
@Test
void testOffsetVector3d() {
final AABB aabb1 = new SpongeAABB(new Vector3d(1, 2, 3), new Vector3d(7, 10, 13));
final AABB aabb2 = new SpongeAABB(new Vector3d(11, 0, 4), new Vector3d(17, 8, 14));
Assertions.assertEquals(aabb2, aabb1.offset(new Vector3d(10, -2, 1)));
}
Aggregations