Backported portal fixes and also fixed a multiplayer crash.
This commit is contained in:
parent
faa6d08e65
commit
d3daccfd0d
|
@ -398,70 +398,6 @@ AetherEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onLeftClick(InputEvent.MouseInputEvent event)
|
||||
{
|
||||
if (Mouse.getEventButton() == 0)
|
||||
{
|
||||
if (Mouse.getEventButtonState())
|
||||
{
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
ItemStack stack = player.getHeldItem();
|
||||
|
||||
if (stack != null)
|
||||
{
|
||||
if (isValkyrieItem(stack.getItem()))
|
||||
{
|
||||
Vec3 playerVision = player.getLookVec();
|
||||
AxisAlignedBB reachDistance = player.boundingBox.expand(10.0D, 10.0D, 10.0D);
|
||||
|
||||
List<Entity> locatedEntities = player.worldObj.getEntitiesWithinAABB(Entity.class, reachDistance);
|
||||
|
||||
Entity found = null;
|
||||
double foundLen = 0.0D;
|
||||
|
||||
for (Object o : locatedEntities) {
|
||||
if (o == player) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Entity ent = (Entity) o;
|
||||
|
||||
if (!ent.canBeCollidedWith()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Vec3 vec = Vec3.createVectorHelper(ent.posX - player.posX, ent.boundingBox.minY + ent.height / 2f - player.posY - player.getEyeHeight(), ent.posZ - player.posZ);
|
||||
double len = vec.lengthVector();
|
||||
|
||||
if (len > 8.0F) {
|
||||
continue;
|
||||
}
|
||||
|
||||
vec = vec.normalize();
|
||||
double dot = playerVision.dotProduct(vec);
|
||||
|
||||
if (dot < 1.0 - 0.125 / len || !player.canEntityBeSeen(ent)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (foundLen == 0.0 || len < foundLen) {
|
||||
found = ent;
|
||||
foundLen = len;
|
||||
}
|
||||
}
|
||||
|
||||
if (found != null && player.ridingEntity != found) {
|
||||
stack.damageItem(1, player);
|
||||
|
||||
AetherNetwork.sendToServer(new PacketExtendedAttack(found.getEntityId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void performTimeSet(PlayerWakeUpEvent event, World world, WorldServer worldServer)
|
||||
{
|
||||
if (world.getGameRules().getGameRuleBooleanValue("doDaylightCycle") && event.entityPlayer.isPlayerFullyAsleep())
|
||||
|
@ -473,9 +409,4 @@ AetherEventHandler {
|
|||
PlayerAether.get(event.entityPlayer).setBedLocation(event.entityPlayer.getBedLocation(AetherConfig.getAetherDimensionID()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValkyrieItem(Item stackID)
|
||||
{
|
||||
return stackID == ItemsAether.valkyrie_shovel || stackID == ItemsAether.valkyrie_axe || stackID == ItemsAether.valkyrie_pickaxe || stackID == ItemsAether.valkyrie_lance;
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import com.legacy.aether.client.gui.button.*;
|
|||
import com.legacy.aether.client.gui.menu.AetherMainMenu;
|
||||
import com.legacy.aether.client.gui.menu.GuiMenuToggleButton;
|
||||
import com.legacy.aether.network.packets.PacketCapeChanged;
|
||||
import com.legacy.aether.network.packets.PacketExtendedAttack;
|
||||
import com.legacy.aether.network.packets.PacketPerkChanged;
|
||||
import com.legacy.aether.player.perks.AetherRankings;
|
||||
import com.legacy.aether.player.perks.util.EnumAetherPerkType;
|
||||
|
@ -21,10 +22,13 @@ import net.minecraft.client.renderer.entity.RenderPlayer;
|
|||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.*;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent;
|
||||
|
@ -45,6 +49,7 @@ import com.legacy.aether.player.PlayerAether;
|
|||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
public class AetherClientEvents {
|
||||
|
||||
|
@ -67,6 +72,8 @@ public class AetherClientEvents {
|
|||
if (mc.thePlayer != null && !(mc.thePlayer.movementInput instanceof AetherMovementInput)) {
|
||||
mc.thePlayer.movementInput = new AetherMovementInput(mc, mc.gameSettings);
|
||||
}
|
||||
|
||||
handleExtendedReach(mc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,6 +90,73 @@ public class AetherClientEvents {
|
|||
}
|
||||
}
|
||||
|
||||
private void handleExtendedReach(Minecraft mc)
|
||||
{
|
||||
EntityPlayer player = mc.thePlayer;
|
||||
|
||||
if (player != null) {
|
||||
if (Mouse.getEventButton() == 0) {
|
||||
if (Mouse.getEventButtonState()) {
|
||||
ItemStack stack = player.getHeldItem();
|
||||
|
||||
if (stack != null) {
|
||||
if (isValkyrieItem(stack.getItem())) {
|
||||
Vec3 playerVision = player.getLookVec();
|
||||
AxisAlignedBB reachDistance = player.boundingBox.expand(10.0D, 10.0D, 10.0D);
|
||||
|
||||
List<Entity> locatedEntities = player.worldObj.getEntitiesWithinAABB(Entity.class, reachDistance);
|
||||
|
||||
Entity found = null;
|
||||
double foundLen = 0.0D;
|
||||
|
||||
for (Object o : locatedEntities) {
|
||||
if (o == player) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Entity ent = (Entity) o;
|
||||
|
||||
if (!ent.canBeCollidedWith()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Vec3 vec = Vec3.createVectorHelper(ent.posX - player.posX, ent.boundingBox.minY + ent.height / 2f - player.posY - player.getEyeHeight(), ent.posZ - player.posZ);
|
||||
double len = vec.lengthVector();
|
||||
|
||||
if (len > 8.0F) {
|
||||
continue;
|
||||
}
|
||||
|
||||
vec = vec.normalize();
|
||||
double dot = playerVision.dotProduct(vec);
|
||||
|
||||
if (dot < 1.0 - 0.125 / len || !player.canEntityBeSeen(ent)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (foundLen == 0.0 || len < foundLen) {
|
||||
found = ent;
|
||||
foundLen = len;
|
||||
}
|
||||
}
|
||||
|
||||
if (found != null && player.ridingEntity != found) {
|
||||
stack.damageItem(1, player);
|
||||
|
||||
AetherNetwork.sendToServer(new PacketExtendedAttack(found.getEntityId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValkyrieItem(Item stackID)
|
||||
{
|
||||
return stackID == ItemsAether.valkyrie_shovel || stackID == ItemsAether.valkyrie_axe || stackID == ItemsAether.valkyrie_pickaxe || stackID == ItemsAether.valkyrie_lance;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onOpenGui(GuiOpenEvent event)
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ import net.minecraft.entity.SharedMonsterAttributes;
|
|||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
|
@ -195,8 +196,6 @@ public class PlayerAether implements IPlayerAether {
|
|||
|
||||
this.getEntity().worldObj.theProfiler.startSection("portal");
|
||||
|
||||
int i = this.getEntity().getMaxInPortalTime();
|
||||
|
||||
if (this.getEntity().dimension == AetherConfig.getAetherDimensionID()) {
|
||||
if (this.getEntity().posY < -2) {
|
||||
this.teleportPlayer(false);
|
||||
|
@ -210,17 +209,41 @@ public class PlayerAether implements IPlayerAether {
|
|||
}
|
||||
|
||||
if (this.inPortal) {
|
||||
if (this.getEntity().ridingEntity == null && this.portalCounter++ >= i) {
|
||||
this.portalCounter = i;
|
||||
this.getEntity().timeUntilPortal = this.getEntity().getPortalCooldown();
|
||||
if (this.getEntity().timeUntilPortal <= 0) {
|
||||
int limit = this.getEntity().getMaxInPortalTime();
|
||||
|
||||
if (!this.getEntity().worldObj.isRemote) {
|
||||
this.teleportPlayer(true);
|
||||
this.getEntity().triggerAchievement(AchievementsAether.enter_aether);
|
||||
if (this.getEntity().ridingEntity == null) {
|
||||
if (this.portalCounter >= limit)
|
||||
{
|
||||
this.portalCounter = 0;
|
||||
this.getEntity().timeUntilPortal = this.getEntity().getPortalCooldown();
|
||||
|
||||
if (!this.getEntity().worldObj.isRemote) {
|
||||
this.teleportPlayer(true);
|
||||
this.getEntity().triggerAchievement(AchievementsAether.enter_aether);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.portalCounter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getEntity().timeUntilPortal = this.getEntity().getPortalCooldown();
|
||||
}
|
||||
|
||||
this.inPortal = false;
|
||||
if (this.getEntity().worldObj.getBlock((int) this.getEntity().posX, (int) this.getEntity().posY - 1, (int) this.getEntity().posZ) != Blocks.air)
|
||||
{
|
||||
AxisAlignedBB playerBounding = this.getEntity().boundingBox;
|
||||
|
||||
if (this.getEntity().worldObj.getBlock((int) playerBounding.minX, (int) playerBounding.minY, (int) playerBounding.minZ) != BlocksAether.aether_portal
|
||||
&& this.getEntity().worldObj.getBlock((int) playerBounding.minX, (int) playerBounding.minY, (int) playerBounding.minZ) != BlocksAether.aether_portal)
|
||||
{
|
||||
this.inPortal = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this.portalCounter > 0) {
|
||||
this.portalCounter -= 4;
|
||||
|
@ -229,10 +252,10 @@ public class PlayerAether implements IPlayerAether {
|
|||
if (this.portalCounter < 0) {
|
||||
this.portalCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getEntity().timeUntilPortal > 0) {
|
||||
--this.getEntity().timeUntilPortal;
|
||||
if (this.getEntity().timeUntilPortal > 0) {
|
||||
--this.getEntity().timeUntilPortal;
|
||||
}
|
||||
}
|
||||
|
||||
this.getEntity().worldObj.theProfiler.endSection();
|
||||
|
@ -243,7 +266,7 @@ public class PlayerAether implements IPlayerAether {
|
|||
double distance = this.getEntity().capabilities.isCreativeMode ? 5.0D : 4.5D;
|
||||
|
||||
if (stack != null && stack.getItem() instanceof ItemValkyrieTool) {
|
||||
distance = 10.0D;
|
||||
distance = 8.0D;
|
||||
}
|
||||
|
||||
((EntityPlayerMP) this.getEntity()).theItemInWorldManager.setBlockReachDistance(distance);
|
||||
|
@ -300,18 +323,14 @@ public class PlayerAether implements IPlayerAether {
|
|||
|
||||
@Override
|
||||
public void setInPortal() {
|
||||
if (this.getEntity().timeUntilPortal > 0) {
|
||||
this.getEntity().timeUntilPortal = this.getEntity().getPortalCooldown();
|
||||
} else {
|
||||
double d0 = this.getEntity().prevPosX - this.getEntity().posX;
|
||||
double d1 = this.getEntity().prevPosZ - this.getEntity().posZ;
|
||||
double d0 = this.getEntity().prevPosX - this.getEntity().posX;
|
||||
double d1 = this.getEntity().prevPosZ - this.getEntity().posZ;
|
||||
|
||||
if (!this.getEntity().worldObj.isRemote && !this.inPortal) {
|
||||
this.teleportDirection = Direction.getMovementDirection(d0, d1);
|
||||
}
|
||||
|
||||
this.inPortal = true;
|
||||
if (!this.getEntity().worldObj.isRemote && !this.inPortal) {
|
||||
this.teleportDirection = Direction.getMovementDirection(d0, d1);
|
||||
}
|
||||
|
||||
this.inPortal = true;
|
||||
}
|
||||
|
||||
private void activateParachute()
|
||||
|
|
Loading…
Reference in a new issue