mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-24 22:14:45 +00:00
Merge 1.12
This commit is contained in:
commit
13e56153a9
80 files changed
+1165
-784
No files matched your search
@@ -40,6 +40,7 @@ import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntityBeacon;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
@@ -65,6 +66,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
import org.lwjgl.opengl.ARBShaderObjects;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.boss.IBotaniaBoss;
|
||||
import vazkii.botania.api.internal.ShaderCallback;
|
||||
import vazkii.botania.api.lexicon.multiblock.Multiblock;
|
||||
@@ -89,8 +91,10 @@ import javax.annotation.Nullable;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -100,6 +104,8 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
|
||||
public static EntityType<?> TYPE;
|
||||
|
||||
public static final float ARENA_RANGE = 12F;
|
||||
public static final int ARENA_HEIGHT = 5;
|
||||
|
||||
private static final int SPAWN_TICKS = 160;
|
||||
private static final float MAX_HP = 320F;
|
||||
|
||||
@@ -129,8 +135,8 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
|
||||
};
|
||||
|
||||
private static final List<ResourceLocation> CHEATY_BLOCKS = Arrays.asList(
|
||||
new ResourceLocation("openblocks", "beartrap"),
|
||||
new ResourceLocation("thaumictinkerer", "magnet")
|
||||
new ResourceLocation("openblocks", "beartrap"),
|
||||
new ResourceLocation("thaumictinkerer", "magnet")
|
||||
);
|
||||
|
||||
private boolean spawnLandmines = false;
|
||||
@@ -174,43 +180,53 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
|
||||
}
|
||||
|
||||
public static boolean spawn(EntityPlayer player, ItemStack stack, World world, BlockPos pos, boolean hard) {
|
||||
if(world.getTileEntity(pos) instanceof TileEntityBeacon && isTruePlayer(player)) {
|
||||
if(world.getDifficulty() == EnumDifficulty.PEACEFUL) {
|
||||
//initial checks
|
||||
if(
|
||||
!(world.getTileEntity(pos) instanceof TileEntityBeacon) ||
|
||||
!isTruePlayer(player) ||
|
||||
countGaiaGuardiansAround(world, pos) > 0
|
||||
)
|
||||
return false;
|
||||
|
||||
//check difficulty
|
||||
if(world.getDifficulty() == EnumDifficulty.PEACEFUL) {
|
||||
if(!world.isRemote)
|
||||
player.sendMessage(new TextComponentTranslation("botaniamisc.peacefulNoob").setStyle(new Style().setColor(TextFormatting.RED)));
|
||||
return false;
|
||||
}
|
||||
|
||||
//check pylons
|
||||
for(BlockPos coords : PYLON_LOCATIONS) {
|
||||
BlockPos pos_ = pos.add(coords);
|
||||
|
||||
IBlockState state = world.getBlockState(pos_);
|
||||
if(state.getBlock() != ModBlocks.gaiaPylon) {
|
||||
if(!world.isRemote)
|
||||
player.sendMessage(new TextComponentTranslation("botaniamisc.peacefulNoob").setStyle(new Style().setColor(TextFormatting.RED)));
|
||||
player.sendMessage(new TextComponentTranslation("botaniamisc.needsCatalysts").setStyle(new Style().setColor(TextFormatting.RED)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for(BlockPos coords : PYLON_LOCATIONS) {
|
||||
BlockPos pos_ = pos.add(coords);
|
||||
//check arena shape
|
||||
List<BlockPos> invalidArenaBlocks = checkArena(world, pos);
|
||||
if(!invalidArenaBlocks.isEmpty()) {
|
||||
if(world.isRemote) {
|
||||
Botania.proxy.setWispFXDepthTest(false);
|
||||
for(BlockPos pos_ : invalidArenaBlocks)
|
||||
Botania.proxy.wispFX(pos_.getX() + 0.5, pos_.getY() + 0.5, pos_.getZ() + 0.5, 1F, 0.2F, 0.2F, 0.5F, 0F, 8);
|
||||
Botania.proxy.setWispFXDepthTest(true);
|
||||
} else {
|
||||
PacketHandler.sendTo((EntityPlayerMP) player,
|
||||
new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.ARENA_INDICATOR, pos.getX(), pos.getY(), pos.getZ()));
|
||||
|
||||
IBlockState state = world.getBlockState(pos_);
|
||||
Block blockat = state.getBlock();
|
||||
if(blockat != ModBlocks.gaiaPylon) {
|
||||
if(!world.isRemote)
|
||||
player.sendMessage(new TextComponentTranslation("botaniamisc.needsCatalysts").setStyle(new Style().setColor(TextFormatting.RED)));
|
||||
return false;
|
||||
}
|
||||
player.sendMessage(new TextComponentTranslation("botaniamisc.badArena").setStyle(new Style().setColor(TextFormatting.RED)));
|
||||
}
|
||||
|
||||
if(!hasProperArena(world, pos)) {
|
||||
if(!world.isRemote) {
|
||||
PacketHandler.sendTo((EntityPlayerMP) player,
|
||||
new PacketBotaniaEffect(PacketBotaniaEffect.EffectType.ARENA_INDICATOR, pos.getX(), pos.getY(), pos.getZ()));
|
||||
|
||||
player.sendMessage(new TextComponentTranslation("botaniamisc.badArena").setStyle(new Style().setColor(TextFormatting.RED)));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int guardians = getGaiaGuardiansAround(world, pos);
|
||||
if(guardians > 0)
|
||||
return false;
|
||||
|
||||
if(world.isRemote)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//all checks ok, spawn the boss
|
||||
if(!world.isRemote) {
|
||||
stack.shrink(1);
|
||||
|
||||
EntityDoppleganger e = new EntityDoppleganger(world);
|
||||
@@ -221,72 +237,46 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
|
||||
e.mobSpawnTicks = MOB_SPAWN_TICKS;
|
||||
e.hardMode = hard;
|
||||
|
||||
int playerCount = (int) e.getPlayersAround().stream().filter(EntityDoppleganger::isTruePlayer).count();
|
||||
int playerCount = e.getPlayersAround().size();
|
||||
e.playerCount = playerCount;
|
||||
e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(MAX_HP * playerCount);
|
||||
if (hard)
|
||||
if(hard)
|
||||
e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ARMOR).setBaseValue(15);
|
||||
|
||||
e.playSound(SoundEvents.ENTITY_ENDER_DRAGON_GROWL, 10F, 0.1F);
|
||||
e.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(e)), null, null);
|
||||
world.spawnEntity(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean hasProperArena(World world, BlockPos startPos) {
|
||||
private static List<BlockPos> checkArena(World world, BlockPos beaconPos) {
|
||||
List<BlockPos> trippedPositions = new ArrayList<>();
|
||||
boolean tripped = false;
|
||||
|
||||
int heightCheck = 3;
|
||||
int heightMin = 2;
|
||||
int range = (int) Math.ceil(ARENA_RANGE);
|
||||
for(int i = -range; i < range + 1; i++)
|
||||
for(int j = -range; j < range + 1; j++) {
|
||||
if(Math.abs(i) == 4 && Math.abs(j) == 4 || vazkii.botania.common.core.helper.MathHelper.pointDistancePlane(i, j, 0, 0) > ARENA_RANGE)
|
||||
BlockPos pos;
|
||||
|
||||
for(int x = -range; x <= range; x++)
|
||||
for(int z = -range; z <= range; z++) {
|
||||
if(Math.abs(x) == 4 && Math.abs(z) == 4 || vazkii.botania.common.core.helper.MathHelper.pointDistancePlane(x, z, 0, 0) > ARENA_RANGE)
|
||||
continue; // Ignore pylons and out of circle
|
||||
|
||||
int air = 0;
|
||||
for(int y = -1; y <= ARENA_HEIGHT; y++) {
|
||||
if(x == 0 && y == 0 && z == 0)
|
||||
continue; //this is the beacon
|
||||
|
||||
yCheck: {
|
||||
BlockPos pos = null;
|
||||
int trippedColumn = 0;
|
||||
pos = beaconPos.add(x, y, z);
|
||||
|
||||
for(int k = heightCheck + heightMin; k >= -heightCheck; k--) {
|
||||
pos = startPos.add(i, k, j);
|
||||
boolean isAir = world.getBlockState(pos).getCollisionBoundingBox(world, pos) == null;
|
||||
if(isAir)
|
||||
air++;
|
||||
else {
|
||||
if(air >= 2)
|
||||
break yCheck;
|
||||
else if(trippedColumn < 2) {
|
||||
trippedPositions.add(pos);
|
||||
trippedColumn++;
|
||||
}
|
||||
air = 0;
|
||||
}
|
||||
}
|
||||
boolean expectedBlockHere = y == -1; //the floor
|
||||
boolean isBlockHere = world.getBlockState(pos).getCollisionBoundingBox(world, pos) != null;
|
||||
|
||||
if(trippedColumn == 0)
|
||||
if(expectedBlockHere != isBlockHere) {
|
||||
trippedPositions.add(pos);
|
||||
|
||||
tripped = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(tripped) {
|
||||
Botania.proxy.setWispFXDepthTest(false);
|
||||
for(BlockPos pos : trippedPositions)
|
||||
Botania.proxy.wispFX(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 1F, 0.2F, 0.2F, 0.5F, 0F, 8);
|
||||
Botania.proxy.setWispFXDepthTest(true);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return trippedPositions;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -314,35 +304,35 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAdditional(NBTTagCompound par1nbtTagCompound) {
|
||||
super.writeAdditional(par1nbtTagCompound);
|
||||
par1nbtTagCompound.setInt(TAG_INVUL_TIME, getInvulTime());
|
||||
par1nbtTagCompound.setBoolean(TAG_AGGRO, aggro);
|
||||
par1nbtTagCompound.setInt(TAG_MOB_SPAWN_TICKS, mobSpawnTicks);
|
||||
public void writeAdditional(NBTTagCompound cmp) {
|
||||
super.writeAdditional(cmp);
|
||||
cmp.putInt(TAG_INVUL_TIME, getInvulTime());
|
||||
cmp.putBoolean(TAG_AGGRO, aggro);
|
||||
cmp.putInt(TAG_MOB_SPAWN_TICKS, mobSpawnTicks);
|
||||
|
||||
par1nbtTagCompound.setInt(TAG_SOURCE_X, source.getX());
|
||||
par1nbtTagCompound.setInt(TAG_SOURCE_Y, source.getY());
|
||||
par1nbtTagCompound.setInt(TAG_SOURCE_Z, source.getZ());
|
||||
cmp.putInt(TAG_SOURCE_X, source.getX());
|
||||
cmp.putInt(TAG_SOURCE_Y, source.getY());
|
||||
cmp.putInt(TAG_SOURCE_Z, source.getZ());
|
||||
|
||||
par1nbtTagCompound.setBoolean(TAG_HARD_MODE, hardMode);
|
||||
par1nbtTagCompound.setInt(TAG_PLAYER_COUNT, playerCount);
|
||||
cmp.putBoolean(TAG_HARD_MODE, hardMode);
|
||||
cmp.putInt(TAG_PLAYER_COUNT, playerCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAdditional(NBTTagCompound par1nbtTagCompound) {
|
||||
super.readAdditional(par1nbtTagCompound);
|
||||
setInvulTime(par1nbtTagCompound.getInt(TAG_INVUL_TIME));
|
||||
aggro = par1nbtTagCompound.getBoolean(TAG_AGGRO);
|
||||
mobSpawnTicks = par1nbtTagCompound.getInt(TAG_MOB_SPAWN_TICKS);
|
||||
public void readAdditional(NBTTagCompound cmp) {
|
||||
super.readAdditional(cmp);
|
||||
setInvulTime(cmp.getInt(TAG_INVUL_TIME));
|
||||
aggro = cmp.getBoolean(TAG_AGGRO);
|
||||
mobSpawnTicks = cmp.getInt(TAG_MOB_SPAWN_TICKS);
|
||||
|
||||
int x = par1nbtTagCompound.getInt(TAG_SOURCE_X);
|
||||
int y = par1nbtTagCompound.getInt(TAG_SOURCE_Y);
|
||||
int z = par1nbtTagCompound.getInt(TAG_SOURCE_Z);
|
||||
int x = cmp.getInt(TAG_SOURCE_X);
|
||||
int y = cmp.getInt(TAG_SOURCE_Y);
|
||||
int z = cmp.getInt(TAG_SOURCE_Z);
|
||||
source = new BlockPos(x, y, z);
|
||||
|
||||
hardMode = par1nbtTagCompound.getBoolean(TAG_HARD_MODE);
|
||||
if(par1nbtTagCompound.hasKey(TAG_PLAYER_COUNT))
|
||||
playerCount = par1nbtTagCompound.getInt(TAG_PLAYER_COUNT);
|
||||
hardMode = cmp.getBoolean(TAG_HARD_MODE);
|
||||
if(cmp.contains(TAG_PLAYER_COUNT))
|
||||
playerCount = cmp.getInt(TAG_PLAYER_COUNT);
|
||||
else playerCount = 1;
|
||||
|
||||
if (this.hasCustomName()) {
|
||||
@@ -396,10 +386,10 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void damageEntity(@Nonnull DamageSource par1DamageSource, float par2) {
|
||||
super.damageEntity(par1DamageSource, par2);
|
||||
protected void damageEntity(@Nonnull DamageSource source, float par2) {
|
||||
super.damageEntity(source, par2);
|
||||
|
||||
Entity attacker = par1DamageSource.getImmediateSource();
|
||||
Entity attacker = source.getImmediateSource();
|
||||
if(attacker != null) {
|
||||
Vector3 thisVector = Vector3.fromEntityCenter(this);
|
||||
Vector3 playerVector = Vector3.fromEntityCenter(attacker);
|
||||
@@ -448,8 +438,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dropLoot(boolean wasRecentlyHit, int lootingModifier, @Nonnull DamageSource source)
|
||||
{
|
||||
protected void dropLoot(boolean wasRecentlyHit, int lootingModifier, @Nonnull DamageSource source) {
|
||||
// Save true killer, they get extra loot
|
||||
if (wasRecentlyHit && source.getTrueSource() instanceof EntityPlayer) {
|
||||
trueKiller = (EntityPlayer) source.getTrueSource();
|
||||
@@ -495,12 +484,12 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
|
||||
super.remove();
|
||||
}
|
||||
|
||||
private List<EntityPlayer> getPlayersAround() {
|
||||
public List<EntityPlayer> getPlayersAround() {
|
||||
float range = 15F;
|
||||
return world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range));
|
||||
return world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range), player -> isTruePlayer(player) && !player.isSpectator());
|
||||
}
|
||||
|
||||
private static int getGaiaGuardiansAround(World world, BlockPos source) {
|
||||
private static int countGaiaGuardiansAround(World world, BlockPos source) {
|
||||
float range = 15F;
|
||||
List l = world.getEntitiesWithinAABB(EntityDoppleganger.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range));
|
||||
return l.size();
|
||||
@@ -546,20 +535,31 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
|
||||
}
|
||||
}
|
||||
|
||||
private void smashCheatyBlocks() {
|
||||
int radius = 1;
|
||||
int posXInt = MathHelper.floor(posX);
|
||||
int posYInt = MathHelper.floor(posY);
|
||||
int posZInt = MathHelper.floor(posZ);
|
||||
for(int i = -radius; i < radius + 1; i++)
|
||||
for(int j = -radius; j < radius + 1; j++)
|
||||
for(int k = -radius; k < radius + 1; k++) {
|
||||
int xp = posXInt + i;
|
||||
int yp = posYInt + j;
|
||||
int zp = posZInt + k;
|
||||
BlockPos posp = new BlockPos(xp, yp, zp);
|
||||
if(isCheatyBlock(world, posp)) {
|
||||
world.destroyBlock(posp, true);
|
||||
private void smashBlocksAround(int centerX, int centerY, int centerZ, int radius) {
|
||||
for(int dx = -radius; dx <= radius; dx++)
|
||||
for(int dy = -radius; dy <= radius + 1; dy++)
|
||||
for(int dz = -radius; dz <= radius; dz++) {
|
||||
int x = centerX + dx;
|
||||
int y = centerY + dy;
|
||||
int z = centerZ + dz;
|
||||
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
Block block = state.getBlock();
|
||||
|
||||
if(state.getBlockHardness(world, pos) == -1) continue;
|
||||
|
||||
if(CHEATY_BLOCKS.contains(block.getRegistryName())) {
|
||||
world.destroyBlock(pos, true);
|
||||
} else {
|
||||
//don't break blacklisted blocks
|
||||
if(BotaniaAPI.gaiaBreakBlacklist.contains(block)) continue;
|
||||
//don't break the floor
|
||||
if(y == source.getY() - 1) continue;
|
||||
//don't break blocks in pylon columns
|
||||
if(Math.abs(source.getX() - x) == 4 && Math.abs(source.getZ() - z) == 4) continue;
|
||||
|
||||
world.destroyBlock(pos, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -647,28 +647,28 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
|
||||
|
||||
int invul = getInvulTime();
|
||||
|
||||
if (world.isRemote) {
|
||||
if(world.isRemote) {
|
||||
particles();
|
||||
EntityPlayer player = Botania.proxy.getClientPlayer();
|
||||
if(getPlayersAround().contains(player))
|
||||
player.abilities.isFlying = player.abilities.isFlying && player.abilities.isCreativeMode;
|
||||
player.abilities.isFlying &= player.abilities.isCreativeMode;
|
||||
return;
|
||||
}
|
||||
|
||||
bossInfo.setPercent(getHealth() / getMaxHealth());
|
||||
|
||||
if(!getPassengers().isEmpty())
|
||||
if(isPassenger())
|
||||
stopRiding();
|
||||
|
||||
if(world.getDifficulty() == EnumDifficulty.PEACEFUL)
|
||||
setDead();
|
||||
remove();
|
||||
|
||||
smashCheatyBlocks();
|
||||
smashBlocksAround(MathHelper.floor(posX), MathHelper.floor(posY), MathHelper.floor(posZ), 1);
|
||||
|
||||
List<EntityPlayer> players = getPlayersAround();
|
||||
|
||||
if(players.isEmpty() && !world.playerEntities.isEmpty())
|
||||
setDead();
|
||||
remove();
|
||||
else {
|
||||
for(EntityPlayer player : players) {
|
||||
for(EntityEquipmentSlot e : EntityEquipmentSlot.values()) {
|
||||
@@ -678,9 +678,12 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
|
||||
}
|
||||
}
|
||||
|
||||
//also see SleepingHandler
|
||||
if(player.isPlayerSleeping()) player.wakeUpPlayer(true, true, false);
|
||||
|
||||
clearPotions(player);
|
||||
keepInsideArena(player);
|
||||
player.abilities.isFlying = player.abilities.isFlying && player.abilities.isCreativeMode;
|
||||
player.abilities.isFlying &= player.abilities.isCreativeMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -732,18 +735,14 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
|
||||
|
||||
tpDelay--;
|
||||
if(tpDelay == 0 && getHealth() > 0) {
|
||||
int tries = 0;
|
||||
while(!teleportRandomly() && tries < 50)
|
||||
tries++;
|
||||
if(tries >= 50)
|
||||
teleportTo(source.getX() + 0.5, source.getY() + 1.6, source.getZ() + 0.5);
|
||||
teleportRandomly();
|
||||
|
||||
if(spawnLandmines) {
|
||||
int count = dying && hardMode ? 7 : 6;
|
||||
for(int i = 0; i < count; i++) {
|
||||
int x = source.getX() - 10 + rand.nextInt(20);
|
||||
int y = (int) players.get(rand.nextInt(players.size())).posY;
|
||||
int z = source.getZ() - 10 + rand.nextInt(20);
|
||||
int y = world.getTopSolidOrLiquidBlock(new BlockPos(x, -1, z)).getY();
|
||||
|
||||
EntityMagicLandmine landmine = new EntityMagicLandmine(world);
|
||||
landmine.setPosition(x + 0.5, y, z + 0.5);
|
||||
@@ -779,21 +778,18 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNonBoss()
|
||||
{
|
||||
public boolean isNonBoss() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTrackingPlayer(EntityPlayerMP player)
|
||||
{
|
||||
public void addTrackingPlayer(EntityPlayerMP player) {
|
||||
super.addTrackingPlayer(player);
|
||||
bossInfo.addPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTrackingPlayer(EntityPlayerMP player)
|
||||
{
|
||||
public void removeTrackingPlayer(EntityPlayerMP player) {
|
||||
super.removeTrackingPlayer(player);
|
||||
bossInfo.removePlayer(player);
|
||||
}
|
||||
@@ -818,127 +814,73 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IE
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isCheatyBlock(World world, BlockPos pos) {
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
return CHEATY_BLOCKS.contains(block.getRegistryName());
|
||||
}
|
||||
private void teleportRandomly() {
|
||||
//choose a location to teleport to
|
||||
double oldX = posX, oldY = posY, oldZ = posZ;
|
||||
double newX, newY, newZ;
|
||||
int tries = 0;
|
||||
|
||||
// [VanillaCopy] EntityEnderman.teleportRandomly, edits noted.
|
||||
private boolean teleportRandomly() {
|
||||
double d0 = this.posX + (this.rand.nextDouble() - 0.5D) * 64.0D;
|
||||
double d1 = this.posY + (double)(this.rand.nextInt(64) - 32);
|
||||
double d2 = this.posZ + (this.rand.nextDouble() - 0.5D) * 64.0D;
|
||||
return this.teleportTo(d0, d1, d2);
|
||||
}
|
||||
do {
|
||||
newX = source.getX() + (rand.nextDouble() - .5) * ARENA_RANGE;
|
||||
newY = source.getY();
|
||||
newZ = source.getZ() + (rand.nextDouble() - .5) * ARENA_RANGE;
|
||||
tries++;
|
||||
//ensure it's inside the arena ring, and not just its bounding square
|
||||
}
|
||||
while(tries < 50 && vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(newX, newY, newZ, source.getX(), source.getY(), source.getZ()) > 12);
|
||||
|
||||
// [VanillaCopy] EntityEnderman.teleportTo, edits noted.
|
||||
private boolean teleportTo(double x, double y, double z) {
|
||||
/* Botania - no events
|
||||
net.minecraftforge.event.entity.living.EnderTeleportEvent event = new net.minecraftforge.event.entity.living.EnderTeleportEvent(this, x, y, z, 0);
|
||||
if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) return false;
|
||||
boolean flag = this.attemptTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ());
|
||||
*/
|
||||
|
||||
boolean flag = this.attemptTeleport(x, y, z);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
this.world.playSound((EntityPlayer)null, this.prevPosX, this.prevPosY, this.prevPosZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, this.getSoundCategory(), 1.0F, 1.0F);
|
||||
this.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
|
||||
if(tries == 50) {
|
||||
//failsafe: teleport to the beacon
|
||||
newX = source.getX() + .5;
|
||||
newY = source.getY() + 1.6;
|
||||
newZ = source.getZ() + .5;
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
//teleport there
|
||||
setPositionAndUpdate(newX, newY, newZ);
|
||||
|
||||
// [VanillaCopy] of super, edits noted
|
||||
@Override
|
||||
public boolean attemptTeleport(double x, double y, double z) {
|
||||
double d0 = this.posX;
|
||||
double d1 = this.posY;
|
||||
double d2 = this.posZ;
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
this.posZ = z;
|
||||
boolean flag = false;
|
||||
BlockPos blockpos = new BlockPos(this);
|
||||
World world = this.world;
|
||||
Random random = this.getRNG();
|
||||
//play sound
|
||||
world.playSound(null, oldX, oldY, oldZ, SoundEvents.ENTITY_ENDERMEN_TELEPORT, this.getSoundCategory(), 1.0F, 1.0F);
|
||||
this.playSound(SoundEvents.ENTITY_ENDERMEN_TELEPORT, 1.0F, 1.0F);
|
||||
|
||||
if (world.isBlockLoaded(blockpos))
|
||||
{
|
||||
boolean flag1 = false;
|
||||
Random random = getRNG();
|
||||
|
||||
while (!flag1 && blockpos.getY() > 0)
|
||||
{
|
||||
BlockPos blockpos1 = blockpos.down();
|
||||
IBlockState iblockstate = world.getBlockState(blockpos1);
|
||||
|
||||
if (iblockstate.getMaterial().blocksMovement())
|
||||
{
|
||||
flag1 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
--this.posY;
|
||||
blockpos = blockpos1;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
this.setPositionAndUpdate(this.posX, this.posY, this.posZ);
|
||||
|
||||
if (world.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty() && !world.containsAnyLiquid(this.getEntityBoundingBox()))
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
|
||||
// Botania - Prevent out of bounds teleporting
|
||||
if(vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(posX, posY, posZ, source.getX(), source.getY(), source.getZ()) > 12)
|
||||
flag = false;
|
||||
}
|
||||
//spawn particles along the path
|
||||
int particleCount = 128;
|
||||
for(int i = 0; i < particleCount; ++i) {
|
||||
double progress = i / (double) (particleCount - 1);
|
||||
float vx = (random.nextFloat() - 0.5F) * 0.2F;
|
||||
float vy = (random.nextFloat() - 0.5F) * 0.2F;
|
||||
float vz = (random.nextFloat() - 0.5F) * 0.2F;
|
||||
double px = oldX + (newX - oldX) * progress + (random.nextDouble() - 0.5D) * width * 2.0D;
|
||||
double py = oldY + (newY - oldY) * progress + random.nextDouble() * height;
|
||||
double pz = oldZ + (newZ - oldZ) * progress + (random.nextDouble() - 0.5D) * width * 2.0D;
|
||||
world.spawnParticle(EnumParticleTypes.PORTAL, px, py, pz, vx, vy, vz);
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
this.setPositionAndUpdate(d0, d1, d2);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 128;
|
||||
Vec3d oldPosVec = new Vec3d(oldX, oldY + height / 2, oldZ);
|
||||
Vec3d newPosVec = new Vec3d(newX, newY + height / 2, newZ);
|
||||
|
||||
for (int j = 0; j < 128; ++j)
|
||||
{
|
||||
double d6 = (double)j / 127.0D;
|
||||
float f = (random.nextFloat() - 0.5F) * 0.2F;
|
||||
float f1 = (random.nextFloat() - 0.5F) * 0.2F;
|
||||
float f2 = (random.nextFloat() - 0.5F) * 0.2F;
|
||||
double d3 = d0 + (this.posX - d0) * d6 + (random.nextDouble() - 0.5D) * (double)this.width * 2.0D;
|
||||
double d4 = d1 + (this.posY - d1) * d6 + random.nextDouble() * (double)this.height;
|
||||
double d5 = d2 + (this.posZ - d2) * d6 + (random.nextDouble() - 0.5D) * (double)this.width * 2.0D;
|
||||
world.spawnParticle(EnumParticleTypes.PORTAL, d3, d4, d5, (double)f, (double)f1, (double)f2, new int[0]);
|
||||
if(oldPosVec.squareDistanceTo(newPosVec) > 1) {
|
||||
//damage players in the path of the teleport
|
||||
for(EntityPlayer player : getPlayersAround()) {
|
||||
RayTraceResult rtr = player.getEntityBoundingBox().grow(0.25).calculateIntercept(oldPosVec, newPosVec);
|
||||
if(rtr != null)
|
||||
player.attackEntityFrom(DamageSource.causeMobDamage(this), 6);
|
||||
}
|
||||
|
||||
// Botania - invalid/unneeded check
|
||||
/*if (this instanceof EntityCreature)
|
||||
{
|
||||
((EntityCreature)this).getNavigator().clearPathEntity();
|
||||
}*/
|
||||
//break blocks in the path of the teleport
|
||||
int breakSteps = (int) oldPosVec.distanceTo(newPosVec);
|
||||
if(breakSteps >= 2) {
|
||||
for(int i = 0; i < breakSteps; i++) {
|
||||
float progress = i / (float) (breakSteps - 1);
|
||||
int breakX = MathHelper.floor(oldX + (newX - oldX) * progress);
|
||||
int breakY = MathHelper.floor(oldY + (newY - oldY) * progress);
|
||||
int breakZ = MathHelper.floor(oldZ + (newZ - oldZ) * progress);
|
||||
|
||||
// Botania - damage any players in our way
|
||||
Vec3d origPos = new Vec3d(d0, d1 + height / 2, d2);
|
||||
Vec3d newPos = new Vec3d(posX, posY + height / 2, posZ);
|
||||
|
||||
if(origPos.squareDistanceTo(newPos) > 1) {
|
||||
for(EntityPlayer player : getPlayersAround()) {
|
||||
RayTraceResult rtr = player.getEntityBoundingBox().grow(0.25).calculateIntercept(origPos, newPos);
|
||||
if(rtr != null)
|
||||
player.attackEntityFrom(DamageSource.causeMobDamage(this), 6);
|
||||
smashBlocksAround(breakX, breakY, breakZ, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user