Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Paindar committed Jul 24, 2018
2 parents d1ffad6 + d7add3f commit c3c94b0
Show file tree
Hide file tree
Showing 37 changed files with 1,712 additions and 643 deletions.
4 changes: 2 additions & 2 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod_name = AcademyMonster
mod_ver = 1.0.3a
mod_ver = 1.0.4
mod_group = cn.paindar
mc_ver = 1.7.10
forge_ver = 10.13.4.1517-1.7.10
Expand All @@ -9,6 +9,6 @@ ccl_ver = 1.1.3.136
ccc_ver = 1.0.6.43

lambdalib_ver = 1.2.3
academycraft_ver = 1.0.4
academycraft_ver = 1.0.7


Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Fri Mar 03 12:20:36 CST 2017
#Tue Jul 24 21:01:49 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import cn.lambdalib.util.mc.WorldUtils;
import cn.paindar.academymonster.config.AMConfig;
import cn.paindar.academymonster.entity.EntityMagManipBlock;
import net.minecraft.block.BlockStairs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.util.Vec3;
Expand Down Expand Up @@ -46,7 +47,10 @@ public void spell()
lastX=speller.posX;
lastY=speller.posY;
lastZ=speller.posZ;
List<BlockPos> list=WorldUtils.getBlocksWithin(speller, 7, (int)lerpf(25,100,getSkillExp()), BlockSelectors.filNormal,(world1, x, y, z, block) -> world1.getBlock(x,y,z).getBlockHardness(world1,x,y,z)>0);
List<BlockPos> list=WorldUtils.getBlocksWithin(speller, 7, (int)lerpf(25,100,getSkillExp()),
BlockSelectors.filNormal,
(world1, x, y, z, block) -> world1.getBlock(x,y,z).getBlockHardness(world1,x,y,z)>0,
((world1, i, i1, i2, block) -> !(block instanceof BlockStairs)));//BlockStair will cause server crash for its onUpdate()
for(BlockPos pos:list)
{
EntityMagManipBlock entity= new EntityMagManipBlock(speller, damage,this);
Expand Down
178 changes: 123 additions & 55 deletions src/main/java/cn/paindar/academymonster/ability/AIMeltdowner.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import cn.lambdalib.util.mc.WorldUtils;
import cn.paindar.academymonster.config.AMConfig;
import cn.paindar.academymonster.network.NetworkManager;
import cn.paindar.academymonster.events.RayShootingEvent;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
Expand All @@ -19,9 +20,7 @@
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;

import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.function.Predicate;

import static cn.lambdalib.util.generic.MathUtils.lerpf;
Expand Down Expand Up @@ -62,13 +61,11 @@ private void destroyBlock(World world, int x, int y, int z) {
}
}

private void spellLightgun()
private List<Entity> selectTargets(EntityLivingBase entity, double incr_)
{
Motion3D motion=new Motion3D(speller, true).move(0.1).normalize();
Motion3D motion = new Motion3D(entity, true).move(0.1).normalize();
float yaw = -MathUtils.PI_F * 0.5f - motion.getRotationYawRadians(),
pitch = motion.getRotationPitchRadians();
Set<int[]> processed = new HashSet<>();
World world=speller.worldObj;
Vec3 start = motion.getPosVec();
Vec3 slope = motion.getMotionVec();

Expand All @@ -79,67 +76,130 @@ private void spellLightgun()
Vec3 vp1 = VecUtils.vec(0, 1, 0);
vp1.rotateAroundZ(pitch);
vp1.rotateAroundY(yaw);
Vec3 v0 = add(start, add(multiply(vp0, -range), multiply(vp1, -range))),
v1 = add(start, add(multiply(vp0, range), multiply(vp1, -range))),
v2 = add(start, add(multiply(vp0, range), multiply(vp1, range))),
v3 = add(start, add(multiply(vp0, -range), multiply(vp1, range))),
v4 = add(v0, multiply(slope, incr_)),
v5 = add(v1, multiply(slope, incr_)),
v6 = add(v2, multiply(slope, incr_)),
v7 = add(v3, multiply(slope, incr_));
AxisAlignedBB aabb = WorldUtils.minimumBounds(v0, v1, v2, v3, v4, v5, v6, v7);

Predicate<Entity> areaSelector = target -> {
Vec3 dv = subtract(vec(target.posX, target.posY, target.posZ), start);
Vec3 proj = dv.crossProduct(slope);
return !target.equals(entity) && proj.lengthVector() < range * 1.2;
};
return WorldUtils.getEntities(speller.worldObj, aabb, EntitySelectors.everything().and(areaSelector));

}

private void spellLightgun()
{
EntityLivingBase lastEntity=speller;
World world=speller.worldObj;
double incr_=maxIncrement;

/* Apply Entity Damage */
{
Vec3 v0 = add(start, add(multiply(vp0, -range), multiply(vp1, -range))),
v1 = add(start, add(multiply(vp0, range), multiply(vp1, -range))),
v2 = add(start, add(multiply(vp0, range), multiply(vp1, range))),
v3 = add(start, add(multiply(vp0, -range), multiply(vp1, range))),
v4 = add(v0, multiply(slope, maxIncrement)),
v5 = add(v1, multiply(slope, maxIncrement)),
v6 = add(v2, multiply(slope, maxIncrement)),
v7 = add(v3, multiply(slope, maxIncrement));
AxisAlignedBB aabb = WorldUtils.minimumBounds(v0, v1, v2, v3, v4, v5, v6, v7);

Predicate<Entity> areaSelector = target -> {
Vec3 dv = subtract(vec(target.posX, target.posY, target.posZ), start);
Vec3 proj = dv.crossProduct(slope);
return proj.lengthVector() < range * 1.2;
};
List<Entity> targets = WorldUtils.getEntities(speller.worldObj, aabb, EntitySelectors.everything().and(areaSelector).and(EntitySelectors.exclude(speller)));

for (Entity e : targets)
{
if (e instanceof EntityLivingBase)
{
attack((EntityLivingBase) e, damage);
} else
{
e.setDead();
boolean reflectCheck = true;
List<Vec3> paths = new ArrayList<>();
Vec3 pos=Vec3.createVectorHelper(lastEntity.posX, lastEntity.posY +lastEntity.getEyeHeight(),
lastEntity.posZ);
paths.add(pos);
paths.add(add(pos, multiply(lastEntity.getLookVec(), incr_)));
while (reflectCheck) {
reflectCheck=false;
if(incr_<=0)
break;
List<Entity> targets = selectTargets(lastEntity, incr_);
targets.sort(Comparator.comparingDouble(lastEntity::getDistanceSqToEntity));
for (Entity e : targets) {
if (e instanceof EntityLivingBase) {
RayShootingEvent event = new RayShootingEvent(speller, (EntityLivingBase) e, incr_);
boolean result = MinecraftForge.EVENT_BUS.post(event);
incr_=event.range;
if (!result)
attack((EntityLivingBase) e, damage);
else {
incr_ -= (e.getDistanceToEntity(lastEntity));
paths.remove(paths.size()-1);
pos=Vec3.createVectorHelper(e.posX, e.posY +e.getEyeHeight(), e.posZ);
paths.add(pos);
paths.add(add(pos,multiply(e.getLookVec(), incr_)));
lastEntity = (EntityLivingBase) e;
reflectCheck=true;
break;
}
} else {
e.setDead();
}
}
}
}

if(AMConfig.getBoolean("am.skill.meltdowner.destroyBlock",true))
{
for(int i=1;i<maxIncrement;i++)
{
Vec3 str=VecUtils.add(start,VecUtils.multiply(slope,i));
for (double s = -range; s <= range; s += STEP)
int index=0;
Vec3 str=paths.get(index), end=paths.get(index+1), dir=subtract(end, str);
float yaw = (float)(-MathUtils.PI_F * 0.5f -Math.atan2(dir.xCoord, dir.zCoord)),
pitch = (float) -Math.atan2(dir.yCoord, Math.sqrt(dir.xCoord * dir.xCoord + dir.zCoord * dir.zCoord));
Vec3 vp0 = VecUtils.vec(0, 0, 1);
vp0.rotateAroundZ(pitch);
vp0.rotateAroundY(yaw);

Vec3 vp1 = VecUtils.vec(0, 1, 0);
vp1.rotateAroundZ(pitch);
vp1.rotateAroundY(yaw);
incr_=1;
for(int i=1;i<=maxIncrement;i++)
{
for (double t = -range; t <= range; t += STEP)
if(incr_>=dir.lengthVector()||i==maxIncrement)
{
double rr = range * RandUtils.ranged(0.9, 1.1);
if (s * s + t * t > rr * rr)
continue;
Vec3 pos = VecUtils.add(str,
VecUtils.add(
VecUtils.multiply(vp0, s),
VecUtils.multiply(vp1, t)));
destroyBlock(world,(int) pos.xCoord,(int) pos.yCoord,(int) pos.zCoord);
incr_=1;
index++;
if(!speller.worldObj.isRemote)
{
List<Entity> list=WorldUtils.getEntities(speller, 40, EntitySelectors.player());
for(Entity e:list)
{
for(int j=0;j<paths.size()-1;j++)
NetworkManager.sendMeltdownerEffectTo(speller,str, end, (EntityPlayerMP)e);
}
}
if(index==paths.size()-1)
break;
str=paths.get(index);
end=paths.get(index+1);
dir=subtract(end, str);
yaw = (float)(-MathUtils.PI_F * 0.5f -Math.atan2(dir.xCoord, dir.zCoord));
pitch = (float) -Math.atan2(dir.yCoord, Math.sqrt(dir.xCoord * dir.xCoord + dir.zCoord * dir.zCoord));
vp0 = VecUtils.vec(0, 0, 1);
vp0.rotateAroundZ(pitch);
vp0.rotateAroundY(yaw);

vp1 = VecUtils.vec(0, 1, 0);
vp1.rotateAroundZ(pitch);
vp1.rotateAroundY(yaw);
}
if(AMConfig.getBoolean("am.skill.Meltdowner.destroyBlock",true)) {
Vec3 cur=add(str,multiply(dir.normalize(),incr_));
for (double s = -range; s <= range; s += STEP) {
for (double t = -range; t <= range; t += STEP) {
double rr = range * RandUtils.ranged(0.9, 1.1);
if (s * s + t * t > rr * rr)
continue;
pos = VecUtils.add(cur,
VecUtils.add(
VecUtils.multiply(vp0, s),
VecUtils.multiply(vp1, t)));
destroyBlock(world, (int) pos.xCoord, (int) pos.yCoord, (int) pos.zCoord);
}
}
}
incr_++;
}
}
}
if(!speller.worldObj.isRemote)
{
List<Entity> list=WorldUtils.getEntities(speller, 40, EntitySelectors.player());
for(Entity e:list)
{
NetworkManager.sendMeltdownerEffectTo(speller,maxIncrement,(EntityPlayerMP)e);
}

}
}

Expand All @@ -148,6 +208,13 @@ protected void onTick()
{
if(!isChanting)
return;
if(speller.isDead)
{
isChanting=false;
tick=0;
super.spell();
}

tick++;
if(isInterf())
{
Expand All @@ -159,6 +226,7 @@ protected void onTick()
{
spellLightgun();
isChanting=false;
super.spell();
tick=0;
}
}
Expand Down
Loading

0 comments on commit c3c94b0

Please sign in to comment.