Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reformatting PR #1366

Open
wants to merge 6 commits into
base: 1.12-fixes
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 38 additions & 32 deletions src/main/java/thebetweenlands/client/gui/GuiFishStaminaBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,45 @@ public class GuiFishStaminaBar extends Gui {
@SubscribeEvent
public void onRenderHUD(RenderGameOverlayEvent.Post event) {
Minecraft mc = Minecraft.getMinecraft();
if (event.getType().equals(RenderGameOverlayEvent.ElementType.HOTBAR)) {
EntityPlayerSP player = mc.player;
if (player != null && player.fishEntity != null && player.fishEntity instanceof EntityBLFishHook) {
if (player.fishEntity.isRiding() && player.fishEntity.getRidingEntity() instanceof EntityAnadia) {
if (!event.getType().equals(RenderGameOverlayEvent.ElementType.HOTBAR)) {
return;
}

EntityPlayerSP player = mc.player;
if (player == null || player.fishEntity == null || player.fishEntity instanceof EntityBLFishHook == false) {
return;
}

if (player.fishEntity.isRiding() && player.fishEntity.getRidingEntity() instanceof EntityAnadia) {

final EntityAnadia fish = ((EntityAnadia) player.fishEntity.getRidingEntity());

int fishpos = ((EntityAnadia) player.fishEntity.getRidingEntity()).getStaminaTicks() * 256 / 180;
int escapepos = ((EntityAnadia) player.fishEntity.getRidingEntity()).getEscapeTicks() * 256 / 1024;
int helpMe = (int) ((EntityAnadia) player.fishEntity.getRidingEntity()).getStaminaMods() * 30;
int escapeDelay = ((EntityAnadia) player.fishEntity.getRidingEntity()).getEscapeDelay();
int obstructpos1 = ((EntityAnadia) player.fishEntity.getRidingEntity()).getObstruction1Ticks();
int obstructpos2 = ((EntityAnadia) player.fishEntity.getRidingEntity()).getObstruction2Ticks();
int obstructpos3 = ((EntityAnadia) player.fishEntity.getRidingEntity()).getObstruction3Ticks();
int obstructpos4 = ((EntityAnadia) player.fishEntity.getRidingEntity()).getObstruction4Ticks() * 256 / 512;
int treasurePos = ((EntityAnadia) player.fishEntity.getRidingEntity()).getTreasureTicks() * 256 / 1024;
boolean showTreasure = ((EntityAnadia) player.fishEntity.getRidingEntity()).isTreasureFish();
boolean treasureUnlocked = ((EntityAnadia) player.fishEntity.getRidingEntity()).getTreasureUnlocked();
int aniFrame = ((EntityAnadia) player.fishEntity.getRidingEntity()).animationFrame;
int aniFrameCrab = ((EntityAnadia) player.fishEntity.getRidingEntity()).animationFrameCrab;

mc.renderEngine.bindTexture(GUI_TEXTURE);

GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
GlStateManager.color(1F, 1F, 1F, 1F);

ScaledResolution res = new ScaledResolution(mc);
if(((EntityAnadia) player.fishEntity.getRidingEntity()).getStaminaTicks() <= 0)
renderNetBar((float)res.getScaledWidth() * 0.5F - 128F, (float)res.getScaledHeight() * 0.5F - 120F, 240, 4, aniFrame);
else
renderStaminaBar(-256 + fishpos, -256 + Math.min(256, escapepos), escapeDelay < 10 ? escapeDelay: 10, 0 - obstructpos1, 0 - obstructpos2, 0 - obstructpos3, 0 - obstructpos4, 0 - treasurePos, showTreasure, treasureUnlocked, (float)res.getScaledWidth() * 0.5F - 128F, (float)res.getScaledHeight() * 0.5F - 120F, aniFrame, aniFrameCrab);
}
}
int fishpos = fish.getStaminaTicks() * 256 / 180;
int escapepos = fish.getEscapeTicks() * 256 / 1024;
int helpMe = (int) fish.getStaminaMods() * 30;
int escapeDelay = fish.getEscapeDelay();
int obstructpos1 = fish.getObstruction1Ticks();
int obstructpos2 = fish.getObstruction2Ticks();
int obstructpos3 = fish.getObstruction3Ticks();
int obstructpos4 = fish.getObstruction4Ticks() * 256 / 512;
int treasurePos = fish.getTreasureTicks() * 256 / 1024;
boolean showTreasure = fish.isTreasureFish();
boolean treasureUnlocked = fish.getTreasureUnlocked();
int aniFrame = fish.animationFrame;
int aniFrameCrab = fish.animationFrameCrab;

mc.renderEngine.bindTexture(GUI_TEXTURE);

GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
GlStateManager.color(1F, 1F, 1F, 1F);

ScaledResolution res = new ScaledResolution(mc);
if(fish.getStaminaTicks() <= 0)
renderNetBar((float)res.getScaledWidth() * 0.5F - 128F, (float)res.getScaledHeight() * 0.5F - 120F, 240, 4, aniFrame);
else
renderStaminaBar(-256 + fishpos, -256 + Math.min(256, escapepos), escapeDelay < 10 ? escapeDelay: 10, 0 - obstructpos1, 0 - obstructpos2, 0 - obstructpos3, 0 - obstructpos4, 0 - treasurePos, showTreasure, treasureUnlocked, (float)res.getScaledWidth() * 0.5F - 128F, (float)res.getScaledHeight() * 0.5F - 120F, aniFrame, aniFrameCrab);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,67 +343,78 @@ protected boolean isBridgableSpot(BlockPos pos) {
protected void placeBridge() {
Path path = this.getNavigator().getPath();

if(path != null && path.getCurrentPathIndex() < path.getCurrentPathLength()) {
PathPoint nextPoint = path.getPathPointFromIndex(path.getCurrentPathIndex());

if(nextPoint.y == MathHelper.floor(this.posY + 0.5f)) {
BlockPos pos = new BlockPos(this);
pos = pos.add(0, nextPoint.y - pos.getY() - 1, 0);

if(this.getDistanceSq(pos) <= 2 && this.isBridgableSpot(pos)) {
if(ForgeEventFactory.getMobGriefingEvent(this.world, this)) {

int nx = -2;
int nz = -2;

if(path.getCurrentPathIndex() < path.getCurrentPathLength() - 1) {
PathPoint secondNextPoint = path.getPathPointFromIndex(path.getCurrentPathIndex() + 1);
nx = MathHelper.clamp(secondNextPoint.x - nextPoint.x, -1, 1);
nz = MathHelper.clamp(secondNextPoint.z - nextPoint.z, -1, 1);
if(nx == 0) nx = -2;
if(nz == 0) nz = -2;
}

for(int xo = -1; xo <= 1; xo++) {
for(int zo = -1; zo <= 1; zo++) {
if(xo != nx && zo != nz) {
BlockPos offsetPos = pos.add(xo, 0, zo);

if(this.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(offsetPos), e -> e != this).isEmpty() && this.isBridgableSpot(offsetPos)) {
if(path == null || path.getCurrentPathIndex() >= path.getCurrentPathLength()) {
return;
}

PathPoint nextPoint = path.getPathPointFromIndex(path.getCurrentPathIndex());
if(nextPoint.y != MathHelper.floor(this.posY + 0.5f)) {
return;
}


BlockPos pos = new BlockPos(this);
pos = pos.add(0, nextPoint.y - pos.getY() - 1, 0);

boolean canReplace = false;
if(this.getDistanceSq(pos) > 2 || !this.isBridgableSpot(pos)) {
return;
}

if(!ForgeEventFactory.getMobGriefingEvent(this.world, this)) {
return;
}

int nx = -2;
int nz = -2;

if(path.getCurrentPathIndex() < path.getCurrentPathLength() - 1) {
PathPoint secondNextPoint = path.getPathPointFromIndex(path.getCurrentPathIndex() + 1);
nx = MathHelper.clamp(secondNextPoint.x - nextPoint.x, -1, 1);
nz = MathHelper.clamp(secondNextPoint.z - nextPoint.z, -1, 1);
if(nx == 0) nx = -2;
if(nz == 0) nz = -2;
}

if(this.world.getBlockState(offsetPos).getBlock().isReplaceable(this.world, offsetPos)) {
canReplace = true;
} else {
IBlockState hitState = this.world.getBlockState(offsetPos);
float hardness = hitState.getBlockHardness(this.world, offsetPos);
for(int xo = -1; xo <= 1; xo++) {
for(int zo = -1; zo <= 1; zo++) {
if(xo == nx || zo == nz) {
continue;
}


BlockPos offsetPos = pos.add(xo, 0, zo);

if(hardness >= 0
&& hitState.getBlock().canEntityDestroy(hitState, this.world, offsetPos, this)
&& ForgeEventFactory.onEntityDestroyBlock(this, offsetPos, hitState)) {
if(!(this.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(offsetPos), e -> e != this).isEmpty()) || !this.isBridgableSpot(offsetPos)) {
continue;
}

boolean canReplace = false;

canReplace = true;
if(!hitState.getMaterial().isLiquid() && hitState.getCollisionBoundingBox(this.world, pos) != null) {
this.world.playEvent(2001, offsetPos, Block.getStateId(hitState));
}
this.world.setBlockToAir(offsetPos);
}
}
if(this.world.getBlockState(offsetPos).getBlock().isReplaceable(this.world, offsetPos)) {
canReplace = true;
} else {
IBlockState hitState = this.world.getBlockState(offsetPos);
float hardness = hitState.getBlockHardness(this.world, offsetPos);

if(canReplace) {
this.world.setBlockState(offsetPos, BlockRegistry.PEAT.getDefaultState());
}
if(hardness >= 0
&& hitState.getBlock().canEntityDestroy(hitState, this.world, offsetPos, this)
&& ForgeEventFactory.onEntityDestroyBlock(this, offsetPos, hitState)) {

}
}
}
canReplace = true;
if(!hitState.getMaterial().isLiquid() && hitState.getCollisionBoundingBox(this.world, pos) != null) {
this.world.playEvent(2001, offsetPos, Block.getStateId(hitState));
}

this.world.setBlockToAir(offsetPos);
}
}

if(canReplace) {
this.world.setBlockState(offsetPos, BlockRegistry.PEAT.getDefaultState());
}
}
}


}

@Override
Expand Down Expand Up @@ -1081,4 +1092,4 @@ public int getMusicLayer(EntityPlayer listener) {
public UUID getBossInfoUuid() {
return dataManager.get(BOSSINFO_ID).or(new UUID(0, 0));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,41 @@ protected void checkAndPerformAttack(EntityLivingBase enemy, double distToEnemyS
this.tasks.addTask(2, new EntityAIWander(this, 0.5D, 20));
this.targetTasks.addTask(0, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, true));
}

private void tryDamagingTarget() {
if(this.world.getDifficulty() == EnumDifficulty.PEACEFUL) {
return;
}

EntityLivingBase target = this.getAttackTarget();

@Override
public void onUpdate() {
super.onUpdate();

if(this.world.getDifficulty() != EnumDifficulty.PEACEFUL) {
EntityLivingBase target = this.getAttackTarget();

if(target != null) {
double dst = this.getDistance(target);
if(target == null) {
return;
}

double dst = this.getDistance(target);

if(dst < 6.0f && this.world.rand.nextInt(20) == 0) {
this.world.setEntityState(this, EVENT_SPARK);
}
if(dst < 6.0f && this.world.rand.nextInt(20) == 0) {
this.world.setEntityState(this, EVENT_SPARK);
}

if(dst < 3.0f && this.ticksExisted % 20 == 0) {
if(canEntityBeSeen(target) && target.isInWater()) {
this.world.spawnEntity(new EntityShock(this.world, this, this, (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() * 0.75f, true));
getEntityWorld().playSound(null, getPosition(), SoundRegistry.JELLYFISH_ZAP, SoundCategory.HOSTILE, 1F, 0.8F + rand.nextFloat());
}
}
if(dst < 3.0f && this.ticksExisted % 20 == 0) {
if(canEntityBeSeen(target) && target.isInWater()) {
this.world.spawnEntity(new EntityShock(this.world, this, this, (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() * 0.75f, true));
getEntityWorld().playSound(null, getPosition(), SoundRegistry.JELLYFISH_ZAP, SoundCategory.HOSTILE, 1F, 0.8F + rand.nextFloat());
}
}
}

@Override
public void onUpdate() {
super.onUpdate();

tryDamagingTarget();

//other AI goes here
}

@SideOnly(Side.CLIENT)
@Override
public void handleStatusUpdate(byte id) {
Expand All @@ -81,18 +91,21 @@ public void handleStatusUpdate(byte id) {
@SideOnly(Side.CLIENT)
private void spawnLightningArcs() {
Entity view = Minecraft.getMinecraft().getRenderViewEntity();
if(view != null && view.getDistance(this) < 16) {
float ox = this.world.rand.nextFloat() - 0.5f + (float)this.motionX;
float oy = this.world.rand.nextFloat() - 0.5f + (float)this.motionY;
float oz = this.world.rand.nextFloat() - 0.5f + (float)this.motionZ;
if(view == null || view.getDistance(this) > 16) {
return;
}


float ox = this.world.rand.nextFloat() - 0.5f + (float)this.motionX;
float oy = this.world.rand.nextFloat() - 0.5f + (float)this.motionY;
float oz = this.world.rand.nextFloat() - 0.5f + (float)this.motionZ;

Particle particle = BLParticles.LIGHTNING_ARC.create(this.world, this.posX, this.posY + this.height * 0.5f, this.posZ,
ParticleArgs.get()
.withMotion(this.motionX, this.motionY, this.motionZ)
.withColor(0.3f, 0.5f, 1.0f, 0.9f)
.withData(new Vec3d(this.posX + ox, this.posY + this.height * 0.5f + oy, this.posZ + oz)));
Particle particle = BLParticles.LIGHTNING_ARC.create(this.world, this.posX, this.posY + this.height * 0.5f, this.posZ,
ParticleArgs.get()
.withMotion(this.motionX, this.motionY, this.motionZ)
.withColor(0.3f, 0.5f, 1.0f, 0.9f)
.withData(new Vec3d(this.posX + ox, this.posY + this.height * 0.5f + oy, this.posZ + oz)));

BatchedParticleRenderer.INSTANCE.addParticle(DefaultParticleBatches.BEAM, particle);
}
BatchedParticleRenderer.INSTANCE.addParticle(DefaultParticleBatches.BEAM, particle);
}
}
Loading