Merge master

This commit is contained in:
Vincent Lee committed 2019-01-16 14:46:30 -06:00
commit eaaa55fdb0
254 files changed
+8593 -1893

No files matched your search

@@ -10,10 +10,11 @@
*/
package vazkii.botania.common.entity;
import com.google.common.base.Optional;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.MovingSound;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureMap;
@@ -34,7 +35,6 @@ import net.minecraft.init.Items;
import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
@@ -47,6 +47,7 @@ import net.minecraft.tileentity.TileEntityBeacon;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
@@ -61,6 +62,7 @@ import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.ARBShaderObjects;
@@ -76,7 +78,6 @@ import vazkii.botania.common.Botania;
import vazkii.botania.common.advancements.DopplegangerNoArmorTrigger;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.core.helper.PlayerHelper;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibEntityNames;
@@ -94,7 +95,7 @@ import java.util.UUID;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss, IEntityAdditionalSpawnData {
public static final float ARENA_RANGE = 12F;
private static final int SPAWN_TICKS = 160;
@@ -117,10 +118,6 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
private static final String TAG_PLAYER_COUNT = "playerCount";
private static final DataParameter<Integer> INVUL_TIME = EntityDataManager.createKey(EntityDoppleganger.class, DataSerializers.VARINT);
private static final DataParameter<Integer> PLAYER_COUNT = EntityDataManager.createKey(EntityDoppleganger.class, DataSerializers.VARINT);
private static final DataParameter<Boolean> HARD_MODE = EntityDataManager.createKey(EntityDoppleganger.class, DataSerializers.BOOLEAN);
private static final DataParameter<BlockPos> SOURCE = EntityDataManager.createKey(EntityDoppleganger.class, DataSerializers.BLOCK_POS);
private static final DataParameter<Optional<UUID>> BOSSINFO_ID = EntityDataManager.createKey(EntityDoppleganger.class, DataSerializers.OPTIONAL_UNIQUE_ID);
private static final BlockPos[] PYLON_LOCATIONS = {
new BlockPos(4, 1, 4),
@@ -134,15 +131,18 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
new ResourceLocation("thaumictinkerer", "magnet")
);
private boolean isPlayingMusic = false;
private boolean spawnLandmines = false;
private boolean spawnPixies = false;
private boolean anyWithArmor = false;
private boolean aggro = false;
private int tpDelay = 0;
private int mobSpawnTicks = 0;
private int playerCount = 0;
private boolean hardMode = false;
private BlockPos source = BlockPos.ORIGIN;
private final List<UUID> playersWhoAttacked = new ArrayList<>();
private final BossInfoServer bossInfo = (BossInfoServer) new BossInfoServer(new TextComponentTranslation("entity." + LibEntityNames.DOPPLEGANGER_REGISTRY + ".name"), BossInfo.Color.PINK, BossInfo.Overlay.PROGRESS).setCreateFog(true);;
private UUID bossInfoUUID = bossInfo.getUniqueId();
public EntityPlayer trueKiller = null;
public EntityDoppleganger(World world) {
@@ -215,12 +215,12 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
e.setPosition(pos.getX() + 0.5, pos.getY() + 3, pos.getZ() + 0.5);
e.setInvulTime(SPAWN_TICKS);
e.setHealth(1F);
e.setSource(pos);
e.source = pos;
e.mobSpawnTicks = MOB_SPAWN_TICKS;
e.setHardMode(hard);
e.hardMode = hard;
int playerCount = (int) e.getPlayersAround().stream().filter(EntityDoppleganger::isTruePlayer).count();
e.setPlayerCount(playerCount);
e.playerCount = playerCount;
e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(MAX_HP * playerCount);
if (hard)
e.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.ARMOR).setBaseValue(15);
@@ -277,10 +277,8 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
if(tripped) {
Botania.proxy.setWispFXDepthTest(false);
for(BlockPos pos : trippedPositions) {
System.out.println(world.isRemote);
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;
@@ -299,10 +297,6 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
protected void entityInit() {
super.entityInit();
dataManager.register(INVUL_TIME, 0);
dataManager.register(SOURCE, BlockPos.ORIGIN);
dataManager.register(HARD_MODE, false);
dataManager.register(PLAYER_COUNT, 0);
dataManager.register(BOSSINFO_ID, Optional.absent());
}
public int getInvulTime() {
@@ -310,33 +304,13 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
}
public BlockPos getSource() {
return dataManager.get(SOURCE);
}
public boolean isHardMode() {
return dataManager.get(HARD_MODE);
}
public int getPlayerCount() {
return dataManager.get(PLAYER_COUNT);
return source;
}
public void setInvulTime(int time) {
dataManager.set(INVUL_TIME, time);
}
public void setSource(BlockPos pos) {
dataManager.set(SOURCE, pos);
}
public void setHardMode(boolean hardMode) {
dataManager.set(HARD_MODE, hardMode);
}
public void setPlayerCount(int count) {
dataManager.set(PLAYER_COUNT, count);
}
@Override
public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) {
super.writeEntityToNBT(par1nbtTagCompound);
@@ -344,13 +318,12 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
par1nbtTagCompound.setBoolean(TAG_AGGRO, aggro);
par1nbtTagCompound.setInteger(TAG_MOB_SPAWN_TICKS, mobSpawnTicks);
BlockPos source = getSource();
par1nbtTagCompound.setInteger(TAG_SOURCE_X, source.getX());
par1nbtTagCompound.setInteger(TAG_SOURCE_Y, source.getY());
par1nbtTagCompound.setInteger(TAG_SOURCE_Z, source.getZ());
par1nbtTagCompound.setBoolean(TAG_HARD_MODE, isHardMode());
par1nbtTagCompound.setInteger(TAG_PLAYER_COUNT, getPlayerCount());
par1nbtTagCompound.setBoolean(TAG_HARD_MODE, hardMode);
par1nbtTagCompound.setInteger(TAG_PLAYER_COUNT, playerCount);
}
@Override
@@ -363,12 +336,12 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
int x = par1nbtTagCompound.getInteger(TAG_SOURCE_X);
int y = par1nbtTagCompound.getInteger(TAG_SOURCE_Y);
int z = par1nbtTagCompound.getInteger(TAG_SOURCE_Z);
setSource(new BlockPos(x, y, z));
source = new BlockPos(x, y, z);
setHardMode(par1nbtTagCompound.getBoolean(TAG_HARD_MODE));
hardMode = par1nbtTagCompound.getBoolean(TAG_HARD_MODE);
if(par1nbtTagCompound.hasKey(TAG_PLAYER_COUNT))
setPlayerCount(par1nbtTagCompound.getInteger(TAG_PLAYER_COUNT));
else setPlayerCount(1);
playerCount = par1nbtTagCompound.getInteger(TAG_PLAYER_COUNT);
else playerCount = 1;
if (this.hasCustomName()) {
this.bossInfo.setName(this.getDisplayName());
@@ -388,10 +361,14 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
}
}
@Override
public void onKillCommand() {
this.setHealth(0.0F);
}
@Override
public boolean attackEntityFrom(@Nonnull DamageSource source, float par2) {
Entity e = source.getTrueSource();
if (e instanceof EntityPlayer && isTruePlayer(e) && getInvulTime() == 0) {
EntityPlayer player = (EntityPlayer) e;
@@ -465,15 +442,14 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
@Override
public ResourceLocation getLootTable() {
return new ResourceLocation(LibMisc.MOD_ID, isHardMode() ? "gaia_guardian_2" : "gaia_guardian");
return new ResourceLocation(LibMisc.MOD_ID, hardMode ? "gaia_guardian_2" : "gaia_guardian");
}
@Override
protected void dropLoot(boolean wasRecentlyHit, int lootingModifier, @Nonnull DamageSource source)
{
// Save true killer, they get extra loot
if ("player".equals(source.getDamageType())
&& source.getTrueSource() instanceof EntityPlayer) {
if (wasRecentlyHit && source.getTrueSource() instanceof EntityPlayer) {
trueKiller = (EntityPlayer) source.getTrueSource();
}
@@ -514,13 +490,10 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
if(world.isRemote) {
Botania.proxy.removeBoss(this);
}
world.playEvent(1010, getSource(), 0);
isPlayingMusic = false;
super.setDead();
}
private List<EntityPlayer> getPlayersAround() {
BlockPos source = getSource();
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));
}
@@ -532,8 +505,6 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
}
private void particles() {
BlockPos source = getSource();
for(int i = 0; i < 360; i += 8) {
float r = 0.6F;
float g = 0F;
@@ -573,13 +544,6 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
}
}
private void playMusic() {
if(!isPlayingMusic && !isDead && !getPlayersAround().isEmpty()) {
world.playEvent(1010, getSource(), Item.getIdFromItem(isHardMode() ? ModItems.recordGaia2 : ModItems.recordGaia1));
isPlayingMusic = true;
}
}
private void smashCheatyBlocks() {
int radius = 1;
int posXInt = MathHelper.floor(posX);
@@ -615,7 +579,6 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
}
private void keepInsideArena(EntityPlayer player) {
BlockPos source = getSource();
if(vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(player.posX, player.posY, player.posZ, source.getX() + 0.5, source.getY() + 0.5, source.getZ() + 0.5) >= ARENA_RANGE) {
Vector3 sourceVector = new Vector3(source.getX() + 0.5, source.getY() + 0.5, source.getZ() + 0.5);
Vector3 playerVector = Vector3.fromEntityCenter(player);
@@ -629,14 +592,13 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
}
private void spawnMobs(List<EntityPlayer> players) {
int playerCount = getPlayerCount();
for(int pl = 0; pl < playerCount; pl++) {
for(int i = 0; i < 3 + world.rand.nextInt(2); i++) {
EntityLiving entity = null;
switch (world.rand.nextInt(2)) {
case 0: {
entity = new EntityZombie(world);
if(world.rand.nextInt(isHardMode() ? 3 : 12) == 0) {
if(world.rand.nextInt(hardMode ? 3 : 12) == 0) {
entity = new EntityWitch(world);
}
break;
@@ -650,7 +612,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
}
case 3: {
if(!players.isEmpty()) {
for(int j = 0; j < 1 + world.rand.nextInt(isHardMode() ? 8 : 5); j++) {
for(int j = 0; j < 1 + world.rand.nextInt(hardMode ? 8 : 5); j++) {
EntityPixie pixie = new EntityPixie(world);
pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8);
pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2);
@@ -668,7 +630,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
float range = 6F;
entity.setPosition(posX + 0.5 + Math.random() * range - range / 2, posY - 1, posZ + 0.5 + Math.random() * range - range / 2);
entity.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(entity)), null);
if(entity instanceof EntityWitherSkeleton && isHardMode()) {
if(entity instanceof EntityWitherSkeleton && hardMode) {
entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(ModItems.elementiumSword));
}
world.spawnEntity(entity);
@@ -681,7 +643,6 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
public void onLivingUpdate() {
super.onLivingUpdate();
BlockPos source = getSource();
int invul = getInvulTime();
if (world.isRemote) {
@@ -692,9 +653,6 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
return;
}
playMusic();
dataManager.set(BOSSINFO_ID, Optional.of(bossInfo.getUniqueId()));
bossInfo.setPercent(getHealth() / getMaxHealth());
if(!getPassengers().isEmpty())
@@ -705,9 +663,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
smashCheatyBlocks();
boolean hard = isHardMode();
List<EntityPlayer> players = getPlayersAround();
int playerCount = getPlayerCount();
if(players.isEmpty() && !world.playerEntities.isEmpty())
setDead();
@@ -729,7 +685,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
if(isDead)
return;
boolean spawnMissiles = hard && ticksExisted % 15 < 4;
boolean spawnMissiles = hardMode && ticksExisted % 15 < 4;
if(invul > 0 && mobSpawnTicks == MOB_SPAWN_TICKS) {
if(invul < SPAWN_TICKS) {
@@ -759,7 +715,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
if(reverseTicks > MOB_SPAWN_START_TICKS * 2 && mobSpawnTicks > MOB_SPAWN_END_TICKS && mobSpawnTicks % MOB_SPAWN_WAVE_TIME == 0) {
spawnMobs(players);
if(hard && ticksExisted % 3 < 2) {
if(hardMode && ticksExisted % 3 < 2) {
for(int i = 0; i < playerCount; i++)
spawnMissile();
spawnMissiles = false;
@@ -781,7 +737,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
teleportTo(source.getX() + 0.5, source.getY() + 1.6, source.getZ() + 0.5);
if(spawnLandmines) {
int count = dying && hard ? 7 : 6;
int count = dying && hardMode ? 7 : 6;
for(int i = 0; i < count; i++) {
int x = source.getX() - 10 + rand.nextInt(20);
int z = source.getZ() - 10 + rand.nextInt(20);
@@ -797,7 +753,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
if(!players.isEmpty())
for(int pl = 0; pl < playerCount; pl++)
for(int i = 0; i < (spawnPixies ? world.rand.nextInt(hard ? 6 : 3) : 1); i++) {
for(int i = 0; i < (spawnPixies ? world.rand.nextInt(hardMode ? 6 : 3) : 1); i++) {
EntityPixie pixie = new EntityPixie(world);
pixie.setProps(players.get(rand.nextInt(players.size())), this, 1, 8);
pixie.setPosition(posX + width / 2, posY + 2, posZ + width / 2);
@@ -805,7 +761,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
world.spawnEntity(pixie);
}
tpDelay = hard ? dying ? 35 : 45 : dying ? 40 : 60;
tpDelay = hardMode ? dying ? 35 : 45 : dying ? 40 : 60;
spawnLandmines = true;
spawnPixies = false;
}
@@ -936,7 +892,6 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
}
// Botania - Prevent out of bounds teleporting
BlockPos source = getSource();
if(vazkii.botania.common.core.helper.MathHelper.pointDistanceSpace(posX, posY, posZ, source.getX(), source.getY(), source.getZ()) > 12)
flag = false;
}
@@ -1029,7 +984,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
boolean unicode = mc.fontRenderer.getUnicodeFlag();
mc.fontRenderer.setUnicodeFlag(true);
mc.fontRenderer.drawStringWithShadow("" + getPlayerCount(), px + 15, py + 4, 0xFFFFFF);
mc.fontRenderer.drawStringWithShadow("" + playerCount, px + 15, py + 4, 0xFFFFFF);
mc.fontRenderer.setUnicodeFlag(unicode);
GlStateManager.popMatrix();
@@ -1038,7 +993,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
@Override
public UUID getBossInfoUuid() {
return dataManager.get(BOSSINFO_ID).or(new UUID(0, 0));
return bossInfoUUID;
}
@Override
@@ -1059,7 +1014,7 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
int hpFractUniform = ARBShaderObjects.glGetUniformLocationARB(shader1, "hpFract");
float time = getInvulTime();
float grainIntensity = time > 20 ? 1F : Math.max(isHardMode() ? 0.5F : 0F, time / 20F);
float grainIntensity = time > 20 ? 1F : Math.max(hardMode ? 0.5F : 0F, time / 20F);
ARBShaderObjects.glUniform1fARB(grainIntensityUniform, grainIntensity);
ARBShaderObjects.glUniform1fARB(hpFractUniform, getHealth() / getMaxHealth());
@@ -1068,6 +1023,48 @@ public class EntityDoppleganger extends EntityLiving implements IBotaniaBoss {
return background ? null : shaderCallback;
}
@Override
public void writeSpawnData(ByteBuf buffer) {
buffer.writeInt(playerCount);
buffer.writeBoolean(hardMode);
buffer.writeLong(source.toLong());
buffer.writeLong(bossInfoUUID.getMostSignificantBits());
buffer.writeLong(bossInfoUUID.getLeastSignificantBits());
}
@Override
@SideOnly(Side.CLIENT)
public void readSpawnData(ByteBuf additionalData) {
playerCount = additionalData.readInt();
hardMode = additionalData.readBoolean();
source = BlockPos.fromLong(additionalData.readLong());
long msb = additionalData.readLong();
long lsb = additionalData.readLong();
bossInfoUUID = new UUID(msb, lsb);
Minecraft.getMinecraft().getSoundHandler().playSound(new DopplegangerMusic(this));
}
@SideOnly(Side.CLIENT)
private static class DopplegangerMusic extends MovingSound {
private final EntityDoppleganger guardian;
public DopplegangerMusic(EntityDoppleganger guardian) {
super(guardian.hardMode ? ModSounds.gaiaMusic2 : ModSounds.gaiaMusic1, SoundCategory.RECORDS);
this.guardian = guardian;
this.xPosF = guardian.getSource().getX();
this.yPosF = guardian.getSource().getY();
this.zPosF = guardian.getSource().getZ();
this.repeat = true;
}
@Override
public void update() {
if (!guardian.isEntityAlive()) {
donePlaying = true;
}
}
}
private static class BeaconComponent extends MultiblockComponent {
public BeaconComponent(BlockPos relPos) {