use of net.minecraft.util.math.AxisAlignedBB in project Wizardry by TeamWizardry.
the class ModuleShapeZone method run.
@Override
@SuppressWarnings("unused")
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
World world = spell.world;
Vec3d position = spell.getData(ORIGIN);
Entity caster = spell.getCaster();
Vec3d targetPos = spell.getTarget();
if (targetPos == null)
return false;
double aoe = spellRing.getAttributeValue(AttributeRegistry.AREA, spell);
double strength = spellRing.getAttributeValue(AttributeRegistry.POTENCY, spell);
double range = spellRing.getAttributeValue(AttributeRegistry.RANGE, spell);
spellRing.multiplyMultiplierForAll((float) (aoe / 7.0 * strength / 15.0 * range / 15.0));
List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(new BlockPos(targetPos)).grow(aoe, 1, aoe));
if (RandUtil.nextInt((int) ((70 - strength))) == 0) {
if (!spellRing.taxCaster(spell))
return false;
for (Entity entity : entities) {
if (entity.getDistance(targetPos.x, targetPos.y, targetPos.z) <= aoe) {
Vec3d vec = targetPos.addVector(RandUtil.nextDouble(-strength, strength), RandUtil.nextDouble(range), RandUtil.nextDouble(-strength, strength));
SpellData copy = spell.copy();
copy.processEntity(entity, false);
copy.addData(YAW, entity.rotationYaw);
copy.addData(PITCH, entity.rotationPitch);
copy.addData(ORIGIN, vec);
if (spellRing.getChildRing() != null) {
spellRing.getChildRing().runSpellRing(spell);
}
}
}
}
if (RandUtil.nextInt((int) ((40 - strength))) != 0)
return false;
ArrayList<Vec3d> blocks = new ArrayList<>();
for (double i = -aoe; i < aoe; i++) for (double j = 0; j < range; j++) for (double k = -aoe; k < aoe; k++) {
Vec3d pos = targetPos.addVector(i, j, k);
if (pos.distanceTo(targetPos) <= aoe) {
// BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(new BlockPos(pos));
blocks.add(pos);
}
}
if (blocks.isEmpty())
return false;
if (!spellRing.taxCaster(spell))
return false;
Vec3d pos = blocks.get(RandUtil.nextInt(blocks.size() - 1));
SpellData copy = spell.copy();
copy.addData(ORIGIN, pos);
copy.processBlock(new BlockPos(pos), EnumFacing.UP, pos);
copy.addData(YAW, RandUtil.nextFloat(-180, 180));
copy.addData(PITCH, RandUtil.nextFloat(-50, 50));
if (spellRing.getChildRing() != null) {
spellRing.getChildRing().runSpellRing(copy);
}
return true;
}
use of net.minecraft.util.math.AxisAlignedBB in project BaseMetals by MinecraftModDevelopmentMods.
the class BlockHumanDetector method computeRedstoneStrength.
@Override
protected int computeRedstoneStrength(final World worldIn, final BlockPos pos) {
final AxisAlignedBB axisalignedbb = PRESSURE_AABB.offset(pos);
final List<? extends Entity> list = worldIn.<Entity>getEntitiesWithinAABB(EntityPlayer.class, axisalignedbb);
if (!list.isEmpty()) {
return 15;
}
return 0;
}
use of net.minecraft.util.math.AxisAlignedBB in project Wizardry by TeamWizardry.
the class ModuleEffectLightning method run.
@Override
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
World world = spell.world;
Vec3d target = spell.getTarget();
Entity caster = spell.getCaster();
float yaw = spell.getData(YAW, 0F);
float pitch = spell.getData(PITCH, 0F);
if (target == null)
return false;
Vec3d origin = target;
if (caster != null) {
float offX = 0.5f * (float) Math.sin(Math.toRadians(-90.0f - yaw));
float offZ = 0.5f * (float) Math.cos(Math.toRadians(-90.0f - yaw));
origin = new Vec3d(offX, caster.getEyeHeight(), offZ).add(target);
}
double range = spellRing.getAttributeValue(AttributeRegistry.RANGE, spell);
double strength = spellRing.getAttributeValue(AttributeRegistry.POTENCY, spell) / 2.0;
if (!spellRing.taxCaster(spell))
return false;
RayTraceResult traceResult = new RayTrace(world, PosUtils.vecFromRotations(pitch, yaw), target, range).setSkipBlocks(true).setSkipEntities(true).trace();
long seed = RandUtil.nextLong(100, 100000);
spell.addData(SEED, seed);
LightningGenerator generator = new LightningGenerator(origin, traceResult.hitVec, new RandUtilSeed(seed));
ArrayList<Vec3d> points = generator.generate();
spell.world.playSound(null, new BlockPos(traceResult.hitVec), ModSounds.LIGHTNING, SoundCategory.NEUTRAL, 0.5f, RandUtil.nextFloat(1, 1.5f));
for (Vec3d point : points) {
List<Entity> entityList = world.getEntitiesWithinAABBExcludingEntity(caster, new AxisAlignedBB(new BlockPos(point)).contract(0.2, 0.2, 0.2));
if (!entityList.isEmpty()) {
for (Entity entity : entityList) {
LightningTracker.INSTANCE.addEntity(origin, entity, caster, (int) strength);
}
}
}
return true;
}
use of net.minecraft.util.math.AxisAlignedBB in project ForestryMC by ForestryMC.
the class BlockEngine method collisionRayTrace.
@Override
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
EnumFacing orientation = blockState.getValue(FACING);
List<AxisAlignedBB> boundingBoxes = boundingBoxesForDirections.get(orientation);
if (boundingBoxes == null) {
return super.collisionRayTrace(blockState, worldIn, pos, start, end);
}
RayTraceResult nearestIntersection = null;
for (AxisAlignedBB boundingBoxBase : boundingBoxes) {
AxisAlignedBB boundingBox = boundingBoxBase.offset(pos.getX(), pos.getY(), pos.getZ());
RayTraceResult intersection = boundingBox.calculateIntercept(start, end);
if (intersection != null) {
if (nearestIntersection == null || intersection.hitVec.distanceTo(start) < nearestIntersection.hitVec.distanceTo(start)) {
nearestIntersection = intersection;
}
}
}
if (nearestIntersection != null) {
Object hitInfo = nearestIntersection.hitInfo;
Entity entityHit = nearestIntersection.entityHit;
nearestIntersection = new RayTraceResult(nearestIntersection.typeOfHit, nearestIntersection.hitVec, nearestIntersection.sideHit, pos);
nearestIntersection.hitInfo = hitInfo;
nearestIntersection.entityHit = entityHit;
}
return nearestIntersection;
}
use of net.minecraft.util.math.AxisAlignedBB in project ForestryMC by ForestryMC.
the class BlockEngine method addCollisionBoxToList.
@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) {
EnumFacing orientation = state.getValue(FACING);
List<AxisAlignedBB> boundingBoxes = boundingBoxesForDirections.get(orientation);
if (boundingBoxes == null) {
return;
}
for (AxisAlignedBB boundingBoxBase : boundingBoxes) {
AxisAlignedBB boundingBox = boundingBoxBase.offset(pos.getX(), pos.getY(), pos.getZ());
if (entityBox.intersects(boundingBox)) {
collidingBoxes.add(boundingBox);
}
}
}
Aggregations