Compare commits
No commits in common. "4472b68ecab8e73d665f66e3aeac1b70a11216e3" and "1131b22447d5df20056b366a469715fd5b4804e3" have entirely different histories.
4472b68eca
...
1131b22447
2 changed files with 63 additions and 108 deletions
0
gradlew
vendored
Executable file → Normal file
0
gradlew
vendored
Executable file → Normal file
|
@ -45,28 +45,13 @@ import trinity.handler.Vec3;
|
||||||
import trinity.init.ModBlocks;
|
import trinity.init.ModBlocks;
|
||||||
|
|
||||||
public class EntityShockwave extends Entity {
|
public class EntityShockwave extends Entity {
|
||||||
|
|
||||||
private static final DataParameter<Integer> SCALE = EntityDataManager.<Integer>createKey(EntityShockwave.class, DataSerializers.VARINT);
|
private static final DataParameter<Integer> SCALE = EntityDataManager.<Integer>createKey(EntityShockwave.class, DataSerializers.VARINT);
|
||||||
|
|
||||||
|
|
||||||
public int revProgress;
|
public int revProgress;
|
||||||
public int radProgress;
|
public int radProgress;
|
||||||
|
|
||||||
private int iCounter = 0;
|
|
||||||
private boolean needsInit = true;
|
|
||||||
|
|
||||||
private int blastState = 0; // Not started
|
|
||||||
private int blastCount = 0;
|
|
||||||
|
|
||||||
private MutableBlockPos pos;
|
|
||||||
private MutableBlockPos pos2;
|
|
||||||
private MutableBlockPos pos3;
|
|
||||||
private MutableBlockPos pos4;
|
|
||||||
private MutableBlockPos pos5;
|
|
||||||
|
|
||||||
private double dist;
|
|
||||||
private double circum;
|
|
||||||
|
|
||||||
public EntityShockwave(World p_i1582_1_) {
|
public EntityShockwave(World p_i1582_1_) {
|
||||||
super(p_i1582_1_);
|
super(p_i1582_1_);
|
||||||
this.setSize(0, 0);
|
this.setSize(0, 0);
|
||||||
|
@ -98,117 +83,87 @@ public class EntityShockwave extends Entity {
|
||||||
return bb;
|
return bb;
|
||||||
//return this.getEntityBoundingBox();
|
//return this.getEntityBoundingBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
|
|
||||||
if(!world.isRemote) {
|
if(!world.isRemote) {
|
||||||
if(needsInit) {
|
MutableBlockPos pos = new BlockPos.MutableBlockPos();
|
||||||
pos = new BlockPos.MutableBlockPos();
|
MutableBlockPos pos2 = new BlockPos.MutableBlockPos();
|
||||||
pos2 = new BlockPos.MutableBlockPos();
|
MutableBlockPos pos3 = new BlockPos.MutableBlockPos();
|
||||||
pos3 = new BlockPos.MutableBlockPos();
|
MutableBlockPos pos4 = new BlockPos.MutableBlockPos();
|
||||||
pos4 = new BlockPos.MutableBlockPos();
|
MutableBlockPos pos5 = new BlockPos.MutableBlockPos();
|
||||||
pos5 = new BlockPos.MutableBlockPos();
|
for(int i = 0; i < 512; i++) {
|
||||||
needsInit = false;
|
|
||||||
}
|
Vec3 vec = Vec3.createVectorHelper(radProgress * 0.5, 0, 0);
|
||||||
if(iCounter < 512*3) {
|
double circum = radProgress * 2 * Math.PI * 2;
|
||||||
if(blastState == 0) { // Not started
|
|
||||||
Vec3 vec = Vec3.createVectorHelper(radProgress * 0.5, 0, 0);
|
///
|
||||||
circum = radProgress * 2 * Math.PI * 2;
|
if(circum == 0)
|
||||||
|
circum = 1;
|
||||||
///
|
///
|
||||||
if(circum == 0)
|
|
||||||
circum = 1;
|
double part = 360D / circum;
|
||||||
///
|
|
||||||
|
vec.rotateAroundY((float) (part * revProgress));
|
||||||
double part = 360D / circum;
|
|
||||||
|
int x = (int) (posX + vec.xCoord);
|
||||||
vec.rotateAroundY((float) (part * revProgress));
|
int z = (int) (posZ + vec.zCoord);
|
||||||
|
|
||||||
int x = (int) (posX + vec.xCoord);
|
double dist = radProgress * 100 / getScale() * 0.5;
|
||||||
int z = (int) (posZ + vec.zCoord);
|
pos.setPos(x, posY, z);
|
||||||
|
pos2.setPos(x-1, posY, z);
|
||||||
dist = radProgress * 100 / getScale() * 0.5;
|
pos3.setPos(x+1, posY, z);
|
||||||
pos.setPos(x, posY, z);
|
pos4.setPos(x, posY, z-1);
|
||||||
pos2.setPos(x-1, posY, z);
|
pos5.setPos(x, posY, z-1);
|
||||||
pos3.setPos(x+1, posY, z);
|
blast(pos, dist);
|
||||||
pos4.setPos(x, posY, z-1);
|
blast(pos2, dist);
|
||||||
pos5.setPos(x, posY, z-1);
|
blast(pos3, dist);
|
||||||
blastState = 1;
|
blast(pos4, dist);
|
||||||
} else if(blastState == 1) {
|
blast(pos5, dist);
|
||||||
switch(blastCount) {
|
|
||||||
case 0:
|
revProgress++;
|
||||||
blast(pos, dist);
|
|
||||||
blastCount++;
|
if(revProgress > circum) {
|
||||||
break;
|
revProgress = 0;
|
||||||
case 1:
|
radProgress++;
|
||||||
blast(pos2, dist);
|
}
|
||||||
blastCount++;
|
|
||||||
break;
|
if(radProgress > getScale() * 2D) {
|
||||||
case 2:
|
|
||||||
blast(pos3, dist);
|
this.setDead();
|
||||||
blastCount++;
|
}
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
blast(pos4, dist);
|
|
||||||
blastCount++;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
blast(pos5, dist);
|
|
||||||
blastCount++;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
blastState = 2;
|
|
||||||
blastCount = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if(blastState == 2) {
|
|
||||||
revProgress++;
|
|
||||||
|
|
||||||
if(revProgress > circum) {
|
|
||||||
revProgress = 0;
|
|
||||||
radProgress++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(radProgress > getScale() * 2D) {
|
|
||||||
|
|
||||||
this.setDead();
|
|
||||||
blastState = 4;
|
|
||||||
}
|
|
||||||
blastState = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
iCounter++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void blast(MutableBlockPos pos, double dist) {
|
private void blast(MutableBlockPos pos, double dist) {
|
||||||
|
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
|
|
||||||
int topBlock =world.getTopSolidOrLiquidBlock(pos).getY();
|
int topBlock =world.getTopSolidOrLiquidBlock(pos).getY();
|
||||||
|
|
||||||
for(int y = (topBlock-8); y <= topBlock+48; y++) {
|
for(int y = (topBlock-8); y <= topBlock+48; y++) {
|
||||||
pos.setY(y);
|
pos.setY(y);
|
||||||
IBlockState b = world.getBlockState(pos);
|
IBlockState b = world.getBlockState(pos);
|
||||||
//int meta = world.getBlockMetadata(x, y, z);
|
//int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BlockPos left = new BlockPos(pos.getX()+1,pos.getY(),pos.getZ());
|
BlockPos left = new BlockPos(pos.getX()+1,pos.getY(),pos.getZ());
|
||||||
BlockPos right = new BlockPos(pos.getX()-1,pos.getY(),pos.getZ());
|
BlockPos right = new BlockPos(pos.getX()-1,pos.getY(),pos.getZ());
|
||||||
BlockPos up = new BlockPos(pos.getX(),pos.getY()+1,pos.getZ());
|
BlockPos up = new BlockPos(pos.getX(),pos.getY()+1,pos.getZ());
|
||||||
//BlockPos down = pos.add(0, -1, 0);
|
//BlockPos down = pos.add(0, -1, 0);
|
||||||
BlockPos down2 = new BlockPos(pos.getX(),pos.getY()-1,pos.getZ());
|
BlockPos down2 = new BlockPos(pos.getX(),pos.getY()-1,pos.getZ());
|
||||||
BlockPos front = pos.add(0, 0, 1);
|
BlockPos front = pos.add(0, 0, 1);
|
||||||
BlockPos back = pos.add(0, 0, -1);
|
BlockPos back = pos.add(0, 0, -1);
|
||||||
|
|
||||||
boolean LR = (world.isAirBlock(left) && world.isAirBlock(right));
|
boolean LR = (world.isAirBlock(left) && world.isAirBlock(right));
|
||||||
//boolean UD = (world.isAirBlock(up) && world.isAirBlock(down));
|
//boolean UD = (world.isAirBlock(up) && world.isAirBlock(down));
|
||||||
boolean FB = (world.isAirBlock(front) && world.isAirBlock(back));
|
boolean FB = (world.isAirBlock(front) && world.isAirBlock(back));
|
||||||
|
|
||||||
IBlockState bd = world.getBlockState(down2);
|
IBlockState bd = world.getBlockState(down2);
|
||||||
|
|
||||||
if((b.getMaterial() != Material.AIR || (b.getBlock()instanceof BlockFluidClassic)) && bd.getMaterial() == Material.AIR)
|
if((b.getMaterial() != Material.AIR || (b.getBlock()instanceof BlockFluidClassic)) && bd.getMaterial() == Material.AIR)
|
||||||
{
|
{
|
||||||
if(b.getBlock().getExplosionResistance(null)<=100)
|
if(b.getBlock().getExplosionResistance(null)<=100)
|
||||||
|
@ -219,13 +174,13 @@ public class EntityShockwave extends Entity {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(b.getMaterial() != Material.AIR && (LR || FB))
|
if(b.getMaterial() != Material.AIR && (LR || FB))
|
||||||
{
|
{
|
||||||
world.setBlockToAir(pos);
|
world.setBlockToAir(pos);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(b.getMaterial() == Material.AIR)
|
if(b.getMaterial() == Material.AIR)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -251,7 +206,7 @@ public class EntityShockwave extends Entity {
|
||||||
p_70014_1_.setInteger("scale", getScale());
|
p_70014_1_.setInteger("scale", getScale());
|
||||||
p_70014_1_.setInteger("revProgress", revProgress);
|
p_70014_1_.setInteger("revProgress", revProgress);
|
||||||
p_70014_1_.setInteger("radProgress", radProgress);
|
p_70014_1_.setInteger("radProgress", radProgress);
|
||||||
|
|
||||||
}
|
}
|
||||||
public void setScale(int i) {
|
public void setScale(int i) {
|
||||||
|
|
||||||
|
@ -261,7 +216,7 @@ public class EntityShockwave extends Entity {
|
||||||
public int getScale() {
|
public int getScale() {
|
||||||
|
|
||||||
int scale = this.dataManager.get(SCALE);
|
int scale = this.dataManager.get(SCALE);
|
||||||
|
|
||||||
return scale == 0 ? 1 : scale;
|
return scale == 0 ? 1 : scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue