use of net.tropicraft.core.common.entity.underdasea.atlantoku.EntityTropicraftWaterBase in project Tropicraft by Tropicraft.
the class ScubaHandler method clearPlayerRenderAngles.
public void clearPlayerRenderAngles(EntityPlayer p) {
PlayerSwimData d = getData(p);
if (p.isRiding() && p.getRidingEntity() instanceof EntityTropicraftWaterBase) {
EntityTropicraftWaterBase fish = (EntityTropicraftWaterBase) p.getRidingEntity();
p.rotationYawHead = fish.rotationYawHead;
p.prevRotationYawHead = fish.prevRotationYawHead;
} else {
p.rotationYawHead = 0f;
p.prevRotationYawHead = 0f;
p.rotationYaw = 0f;
p.prevRotationYaw = 0f;
}
p.renderYawOffset = 0f;
p.prevRenderYawOffset = 0f;
p.rotationPitch = -MathHelper.wrapDegrees(d.currentHeadPitchOffset);
p.prevRotationPitch = -MathHelper.wrapDegrees(d.currentHeadPitchOffset);
}
use of net.tropicraft.core.common.entity.underdasea.atlantoku.EntityTropicraftWaterBase in project Tropicraft by Tropicraft.
the class ScubaHandler method onRenderPlayer.
@SubscribeEvent
public void onRenderPlayer(RenderPlayerEvent.Pre event) {
if (inGUI) {
return;
}
EntityPlayer p = event.getEntityPlayer();
PlayerSwimData d = getData(p);
if (p.isElytraFlying() || p.getRidingEntity() instanceof EntityBeachFloat) {
return;
}
updateSwimRenderAngles(p);
boolean inLiquid = isInWater(p) && isInWater(p, 0, 0.4D, 0);
if (inLiquid) {
if (!p.onGround && isPlayerWearingFlippers(p)) {
p.limbSwingAmount = 0.2f + (d.currentSwimSpeed / 20);
}
} else {
if (d.currentRotationPitch == 0f && d.currentRotationRoll == 0f) {
return;
}
}
GlStateManager.pushMatrix();
boolean isSelf = d.playerUUID.equals(Minecraft.getMinecraft().player.getUniqueID());
GlStateManager.translate(0, 1.5f, 0f);
if (p.isRiding() && p.getRidingEntity() instanceof EntityTropicraftWaterBase) {
d.currentRotationYaw = 0f;
d.currentRotationRoll = 0f;
d.currentHeadPitchOffset = 0f;
d.currentRotationPitch = 0f;
d.rotationYawHead = 90f;
}
if (isSelf) {
GlStateManager.rotate(d.currentRotationYaw, 0f, -1f, 0f);
GlStateManager.rotate(d.currentRotationPitch, 1f, 0f, 0f);
GlStateManager.rotate(d.currentRotationRoll, 0f, 0f, -1f);
} else {
GlStateManager.translate(event.getX(), event.getY(), event.getZ());
GlStateManager.rotate(d.currentRotationYaw, 0f, -1f, 0f);
GlStateManager.rotate(d.currentRotationPitch, 1f, 0f, 0f);
GlStateManager.rotate(d.currentRotationRoll, 0f, 0f, -1f);
GlStateManager.translate(-event.getX(), -event.getY(), -event.getZ());
}
GlStateManager.translate(0, -1.5f, 0f);
updateSwimDataAngles(p);
clearPlayerRenderAngles(p);
}
use of net.tropicraft.core.common.entity.underdasea.atlantoku.EntityTropicraftWaterBase in project Tropicraft by Tropicraft.
the class EntityAISwimTargetPrey method updateTask.
@Override
public void updateTask() {
super.updateTask();
// Target selection
if (entity.ticksExisted % 80 == 0 && entity.aggressTarget == null || !entity.world.loadedEntityList.contains(entity.aggressTarget)) {
List<Entity> list = entity.world.getEntitiesInAABBexcluding(entity, entity.getEntityBoundingBox().grow(20D, 20D, 20D).offset(0.0D, -8.0D, 0.0D), EntitySelectors.IS_ALIVE);
if (list.size() > 0) {
Entity ent = list.get(rand.nextInt(list.size()));
boolean skip = false;
if (ent.equals(entity))
skip = true;
if (ent.getClass().getName().equals(entity.getClass().getName()))
skip = true;
if (entity instanceof IPredatorDiet) {
Class[] prey = ((IPredatorDiet) entity).getPreyClasses();
boolean contains = false;
for (int i = 0; i < prey.length; i++) {
if (prey[i].getName().equals(ent.getClass().getName())) {
contains = true;
}
}
if (!contains) {
skip = true;
}
}
if (!ent.isInWater())
skip = true;
if (!entity.canEntityBeSeen(ent))
skip = true;
if (!skip) {
if (ent instanceof EntityLivingBase) {
if (((EntityLivingBase) ent).isInWater()) {
entity.aggressTarget = ent;
}
}
}
}
}
if (rand.nextInt(200) == 0) {
entity.aggressTarget = null;
entity.setRandomTargetHeading();
}
// Hunt Target and/or Do damage
if (entity.aggressTarget != null) {
if (entity.getDistanceSq(entity.aggressTarget) <= entity.width) {
if (entity.aggressTarget instanceof EntityLivingBase) {
((EntityLivingBase) entity.aggressTarget).attackEntityFrom(DamageSource.causeMobDamage(entity), entity.attackDamage);
}
if (entity.aggressTarget instanceof EntityTropicraftWaterBase) {
if (entity.getEntityBoundingBox().maxY - entity.getEntityBoundingBox().minY > entity.aggressTarget.getEntityBoundingBox().maxY - entity.aggressTarget.getEntityBoundingBox().minY) {
((EntityTropicraftWaterBase) entity.aggressTarget).setExpRate(0);
entity.aggressTarget.setDropItemsWhenDead(false);
entity.aggressTarget.setDead();
entity.heal(1);
entity.eatenFishAmount++;
}
}
entity.setRandomTargetHeading();
} else {
if (entity.canEntityBeSeen(entity.aggressTarget) && entity.ticksExisted % 20 == 0) {
entity.setTargetHeading(entity.aggressTarget.posX, entity.aggressTarget.posY, entity.aggressTarget.posZ, true);
}
}
if (entity.aggressTarget != null) {
if (!entity.canEntityBeSeen(entity.aggressTarget) || !entity.aggressTarget.isInWater()) {
entity.aggressTarget = null;
entity.setRandomTargetHeading();
}
}
}
if (!entity.world.loadedEntityList.contains(entity.aggressTarget) || entity.aggressTarget.isDead) {
entity.aggressTarget = null;
entity.setRandomTargetHeading();
}
}
use of net.tropicraft.core.common.entity.underdasea.atlantoku.EntityTropicraftWaterBase in project Tropicraft by Tropicraft.
the class GuiTropicsLoading method drawScreenEntity.
private void drawScreenEntity(Entity ent, float x, float y, float scale, float yaw, float pitch) {
if (ent == null)
return;
GlStateManager.enableColorMaterial();
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, 500.0F);
GlStateManager.scale(-scale, scale, scale);
GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
float f, f1, f2, f3, f4;
f = f1 = f2 = f3 = f4 = 0;
if (ent instanceof EntityTropicraftWaterBase) {
EntityTropicraftWaterBase fish = (EntityTropicraftWaterBase) ent;
fish.swimYaw = -yaw;
fish.swimPitch = pitch * 0.25f;
}
if (ent instanceof EntityLivingBase) {
EntityLivingBase liv = (EntityLivingBase) ent;
f = liv.renderYawOffset;
f1 = liv.rotationYaw;
f2 = liv.rotationPitch;
f3 = liv.prevRotationYawHead;
f4 = liv.rotationYawHead;
liv.renderYawOffset = yaw;
liv.rotationYaw = yaw;
liv.rotationPitch = pitch;
liv.rotationYawHead = ent.rotationYaw;
liv.prevRotationYawHead = ent.rotationYaw;
}
GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
// RenderHelper.enableGUIStandardItemLighting();
RenderHelper.enableStandardItemLighting();
GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-((float) Math.atan((double) (pitch / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.translate(0.0F, 0.0F, 0.0F);
RenderManager rendermanager = mc.getRenderManager();
rendermanager.setPlayerViewY(180.0F);
rendermanager.setRenderShadow(false);
rendermanager.renderEntity(ent, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
rendermanager.setRenderShadow(true);
if (ent instanceof EntityLivingBase) {
EntityLivingBase liv = (EntityLivingBase) ent;
liv.renderYawOffset = f;
liv.rotationYaw = f1;
liv.rotationPitch = f2;
liv.prevRotationYawHead = f3;
liv.rotationYawHead = f4;
}
GlStateManager.popMatrix();
RenderHelper.disableStandardItemLighting();
GlStateManager.disableRescaleNormal();
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
GlStateManager.disableTexture2D();
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
}
use of net.tropicraft.core.common.entity.underdasea.atlantoku.EntityTropicraftWaterBase in project Tropicraft by Tropicraft.
the class GuiTropicsLoading method assignScreenContent.
public void assignScreenContent() {
// Pick random subtitle
String cat = CATEGORIES[rand.nextInt(CATEGORIES.length)];
int count = 0;
String key = "tropicraft.loading." + cat + ".1";
while (!(I18n.format(key)).equals(key)) {
key = "tropicraft.loading." + cat + "." + count++;
}
screenTitle = "tropicraft.loading." + cat + "." + String.valueOf(rand.nextInt(count + 1) + 1);
if (cat.equals("knowledge") || cat.equals("hint")) {
String prepend = I18n.format("tropicraft.loading." + cat + ".pre");
screenTitle = I18n.format(screenTitle, prepend);
} else {
screenTitle = I18n.format(screenTitle);
}
// Pick random background
screenBackground = BACKGROUNDS[rand.nextInt(BACKGROUNDS.length)];
// Assign random entities from the associated background
ArrayList<Class<? extends Entity>> ta = new ArrayList<>(Arrays.asList(backgroundToEntityMap.get(screenBackground)));
Class<? extends Entity> firstEntClass = ta.get(rand.nextInt(ta.size()));
ResourceLocation firstEnt = EntityList.getKey(firstEntClass);
Entity ent1 = eggWrap(EntityList.createEntityByIDFromName(firstEnt, mc.world), 0);
ta.remove(firstEntClass);
Entity ent2 = eggWrap(EntityList.createEntityByIDFromName(EntityList.getKey(ta.get(rand.nextInt(ta.size()))), mc.world), 1);
if (ent1 instanceof EntityTropicraftWaterBase) {
((EntityTropicraftWaterBase) ent1).assignRandomTexture();
((EntityTropicraftWaterBase) ent1).isInGui = true;
}
if (ent2 instanceof EntityTropicraftWaterBase) {
((EntityTropicraftWaterBase) ent2).assignRandomTexture();
((EntityTropicraftWaterBase) ent2).isInGui = true;
}
screenEntities = Pair.of(ent1, ent2);
// Assign random items
ArrayList<ItemStack> possibleStacks = new ArrayList<ItemStack>(Arrays.asList(ITEMS));
ItemStack left = possibleStacks.get(rand.nextInt(possibleStacks.size()));
possibleStacks.remove(left);
ItemStack mid = possibleStacks.get(rand.nextInt(possibleStacks.size()));
possibleStacks.remove(mid);
ItemStack right = possibleStacks.get(rand.nextInt(possibleStacks.size()));
screenItems = Triple.of(left, mid, right);
}
Aggregations