Err too much.
This commit is contained in:
+109
-26
@@ -13,6 +13,7 @@ import java.util.WeakHashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -35,7 +36,9 @@ import net.minecraft.nbt.NBTTagLong;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -64,9 +67,7 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AEItemDefinition;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.Configuration;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.me.cache.NetworkMonitor;
|
||||
import appeng.server.AccessType;
|
||||
import appeng.server.Security;
|
||||
import appeng.util.item.AEItemStack;
|
||||
@@ -278,8 +279,15 @@ public class Platform
|
||||
if ( isClient() )
|
||||
return;
|
||||
|
||||
if ( Security.hasPermissions( tile, p, AccessType.BLOCK_ACCESS ) )
|
||||
p.openGui( AppEng.instance, type.ordinal() << 3 | (side.ordinal()), tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord );
|
||||
if ( tile == null )
|
||||
{
|
||||
p.openGui( AppEng.instance, type.ordinal() << 3, p.getEntityWorld(), (int) p.posX, (int) p.posY, (int) p.posZ );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( Security.hasPermissions( tile, p, AccessType.BLOCK_ACCESS ) )
|
||||
p.openGui( AppEng.instance, type.ordinal() << 3 | (side.ordinal()), tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1137,19 +1145,103 @@ public class Platform
|
||||
return new LookDirection( vec3, vec31 );
|
||||
}
|
||||
|
||||
public static MovingObjectPosition rayTrace(EntityPlayer p, boolean hitBlocks, boolean hitEntities)
|
||||
{
|
||||
World w = p.getEntityWorld();
|
||||
|
||||
float f = 1.0F;
|
||||
float f1 = p.prevRotationPitch + (p.rotationPitch - p.prevRotationPitch) * f;
|
||||
float f2 = p.prevRotationYaw + (p.rotationYaw - p.prevRotationYaw) * f;
|
||||
double d0 = p.prevPosX + (p.posX - p.prevPosX) * (double) f;
|
||||
double d1 = p.prevPosY + (p.posY - p.prevPosY) * (double) f + 1.62D - (double) p.yOffset;
|
||||
double d2 = p.prevPosZ + (p.posZ - p.prevPosZ) * (double) f;
|
||||
Vec3 vec3 = w.getWorldVec3Pool().getVecFromPool( d0, d1, d2 );
|
||||
float f3 = MathHelper.cos( -f2 * 0.017453292F - (float) Math.PI );
|
||||
float f4 = MathHelper.sin( -f2 * 0.017453292F - (float) Math.PI );
|
||||
float f5 = -MathHelper.cos( -f1 * 0.017453292F );
|
||||
float f6 = MathHelper.sin( -f1 * 0.017453292F );
|
||||
float f7 = f4 * f5;
|
||||
float f8 = f3 * f5;
|
||||
double d3 = 32.0D;
|
||||
|
||||
Vec3 vec31 = vec3.addVector( (double) f7 * d3, (double) f6 * d3, (double) f8 * d3 );
|
||||
|
||||
AxisAlignedBB bb = AxisAlignedBB
|
||||
.getAABBPool()
|
||||
.getAABB( Math.min( vec3.xCoord, vec31.xCoord ), Math.min( vec3.yCoord, vec31.yCoord ), Math.min( vec3.zCoord, vec31.zCoord ),
|
||||
Math.max( vec3.xCoord, vec31.xCoord ), Math.max( vec3.yCoord, vec31.yCoord ), Math.max( vec3.zCoord, vec31.zCoord ) )
|
||||
.expand( 16, 16, 16 );
|
||||
|
||||
Entity entity = null;
|
||||
double Closeest = 9999999.0D;
|
||||
if ( hitEntities )
|
||||
{
|
||||
List list = w.getEntitiesWithinAABBExcludingEntity( p, bb );
|
||||
int l;
|
||||
|
||||
for (l = 0; l < list.size(); ++l)
|
||||
{
|
||||
Entity entity1 = (Entity) list.get( l );
|
||||
|
||||
if ( entity1.isDead == false && entity1 != p && !(entity1 instanceof EntityItem) )
|
||||
{
|
||||
if ( entity1.isEntityAlive() )
|
||||
{
|
||||
// prevent killing / flying of mounts.
|
||||
if ( entity1.riddenByEntity == p )
|
||||
continue;
|
||||
|
||||
f1 = 0.3F;
|
||||
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand( (double) f1, (double) f1, (double) f1 );
|
||||
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept( vec3, vec31 );
|
||||
|
||||
if ( movingobjectposition1 != null )
|
||||
{
|
||||
double nd = vec3.squareDistanceTo( movingobjectposition1.hitVec );
|
||||
|
||||
if ( nd < Closeest )
|
||||
{
|
||||
entity = entity1;
|
||||
Closeest = nd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MovingObjectPosition pos = null;
|
||||
Vec3 Srec = null;
|
||||
|
||||
if ( hitBlocks )
|
||||
{
|
||||
Srec = w.getWorldVec3Pool().getVecFromPool( d0, d1, d2 );
|
||||
pos = w.rayTraceBlocks_do_do( vec3, vec31, true, false );
|
||||
}
|
||||
|
||||
if ( entity != null && pos != null && pos.hitVec.squareDistanceTo( Srec ) > Closeest )
|
||||
{
|
||||
pos = new MovingObjectPosition( entity );
|
||||
}
|
||||
else if ( entity != null && pos == null )
|
||||
{
|
||||
pos = new MovingObjectPosition( entity );
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
public static long nanoTime()
|
||||
{
|
||||
if ( Configuration.instance.enableNetworkProfiler )
|
||||
return System.nanoTime();
|
||||
// if ( Configuration.instance.enableNetworkProfiler )
|
||||
// return System.nanoTime();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static IAEItemStack poweredExtraction(IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack request, BaseActionSource src)
|
||||
public static <StackType extends IAEStack> StackType poweredExtraction(IEnergySource energy, IMEInventory<StackType> cell, StackType request,
|
||||
BaseActionSource src)
|
||||
{
|
||||
if ( cell instanceof NetworkMonitor )
|
||||
((NetworkMonitor) cell).setSource( src );
|
||||
|
||||
IAEItemStack possible = cell.extractItems( request.copy(), Actionable.SIMULATE );
|
||||
StackType possible = cell.extractItems( (StackType) request.copy(), Actionable.SIMULATE, src );
|
||||
|
||||
long retrieved = 0;
|
||||
if ( possible != null )
|
||||
@@ -1164,10 +1256,7 @@ public class Platform
|
||||
energy.extractAEPower( retrieved, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||
|
||||
possible.setStackSize( itemToExtract );
|
||||
IAEItemStack ret = cell.extractItems( possible, Actionable.MODULATE );
|
||||
|
||||
if ( cell instanceof NetworkMonitor )
|
||||
((NetworkMonitor) cell).setSource( null );
|
||||
StackType ret = cell.extractItems( possible, Actionable.MODULATE, src );
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1175,12 +1264,9 @@ public class Platform
|
||||
return null;
|
||||
}
|
||||
|
||||
public static IAEItemStack poweredInsert(IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack input, BaseActionSource src)
|
||||
public static <StackType extends IAEStack> StackType poweredInsert(IEnergySource energy, IMEInventory<StackType> cell, StackType input, BaseActionSource src)
|
||||
{
|
||||
if ( cell instanceof NetworkMonitor )
|
||||
((NetworkMonitor) cell).setSource( src );
|
||||
|
||||
IAEItemStack possible = cell.injectItems( input.copy(), Actionable.SIMULATE );
|
||||
StackType possible = cell.injectItems( (StackType) input.copy(), Actionable.SIMULATE, src );
|
||||
|
||||
long stored = input.getStackSize();
|
||||
if ( possible != null )
|
||||
@@ -1196,17 +1282,14 @@ public class Platform
|
||||
|
||||
if ( itemToAdd < input.getStackSize() )
|
||||
{
|
||||
IAEItemStack split = input.copy();
|
||||
StackType split = (StackType) input.copy();
|
||||
split.decStackSize( itemToAdd );
|
||||
input.setStackSize( itemToAdd );
|
||||
split.add( cell.injectItems( input, Actionable.MODULATE ) );
|
||||
split.add( cell.injectItems( input, Actionable.MODULATE, src ) );
|
||||
return split;
|
||||
}
|
||||
|
||||
IAEItemStack ret = cell.injectItems( input, Actionable.MODULATE );
|
||||
|
||||
if ( cell instanceof NetworkMonitor )
|
||||
((NetworkMonitor) cell).setSource( null );
|
||||
StackType ret = cell.injectItems( input, Actionable.MODULATE, src );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
|
||||
if ( rv != null )
|
||||
{
|
||||
i.onInventoryChanged();
|
||||
// i.onInventoryChanged();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
@@ -150,8 +150,8 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
}
|
||||
}
|
||||
|
||||
if ( rv != null )
|
||||
i.onInventoryChanged();
|
||||
// if ( rv != null )
|
||||
// i.onInventoryChanged();
|
||||
|
||||
return rv;
|
||||
}
|
||||
@@ -226,7 +226,7 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
|
||||
if ( left.stackSize <= 0 )
|
||||
{
|
||||
i.onInventoryChanged();
|
||||
// i.onInventoryChanged();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -247,7 +247,7 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
left.stackSize -= used;
|
||||
if ( left.stackSize <= 0 )
|
||||
{
|
||||
i.onInventoryChanged();
|
||||
// i.onInventoryChanged();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -257,8 +257,8 @@ public class AdaptorIInventory extends InventoryAdaptor
|
||||
}
|
||||
}
|
||||
|
||||
if ( left.stackSize != A.stackSize )
|
||||
i.onInventoryChanged();
|
||||
// if ( left.stackSize != A.stackSize )
|
||||
// i.onInventoryChanged();
|
||||
|
||||
return left;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class IMEInventoryDestination implements IInventoryDestination
|
||||
if ( stack == null )
|
||||
return false;
|
||||
|
||||
IAEItemStack failed = me.injectItems( AEItemStack.create( stack ), Actionable.SIMULATE );
|
||||
IAEItemStack failed = me.injectItems( AEItemStack.create( stack ), Actionable.SIMULATE, null );
|
||||
|
||||
if ( failed == null )
|
||||
return true;
|
||||
|
||||
@@ -7,13 +7,13 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.integration.modules.BC;
|
||||
|
||||
public class WrapperPipe implements IInventory
|
||||
public class WrapperBCPipe implements IInventory
|
||||
{
|
||||
|
||||
TileEntity ad;
|
||||
ForgeDirection dir;
|
||||
|
||||
public WrapperPipe(TileEntity te, ForgeDirection d) {
|
||||
public WrapperBCPipe(TileEntity te, ForgeDirection d) {
|
||||
ad = te;
|
||||
dir = d;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package appeng.util.inv;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import appeng.integration.modules.TE;
|
||||
|
||||
public class WrapperTEPipe implements IInventory
|
||||
{
|
||||
|
||||
TileEntity ad;
|
||||
ForgeDirection dir;
|
||||
|
||||
public WrapperTEPipe(TileEntity te, ForgeDirection d) {
|
||||
ad = te;
|
||||
dir = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack)
|
||||
{
|
||||
TE.instance.addItemsToPipe( ad, itemstack, dir );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvNameLocalized()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInventoryChanged()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||
{
|
||||
return TE.instance.canAddItemsToPipe( ad, itemstack, dir );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import java.util.List;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import appeng.api.storage.data.IAETagCompound;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -23,7 +22,7 @@ public class AEItemDef
|
||||
public int dspDamage;
|
||||
public int maxDamage;
|
||||
|
||||
public IAETagCompound tagCompound;
|
||||
public AESharedNBT tagCompound;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String displayName;
|
||||
|
||||
@@ -78,7 +78,7 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
||||
|
||||
NBTTagCompound tagCompound = is.getTagCompound();
|
||||
if ( tagCompound != null )
|
||||
def.tagCompound = (IAETagCompound) AESharedNBT.getSharedTagCompound( tagCompound, is );
|
||||
def.tagCompound = (AESharedNBT) AESharedNBT.getSharedTagCompound( tagCompound, is );
|
||||
|
||||
stackSize = is.stackSize;
|
||||
setCraftable( false );
|
||||
@@ -241,8 +241,8 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
|
||||
int dv = def.damageValue - b.def.damageValue;
|
||||
int dspv = def.dspDamage - b.def.dspDamage;
|
||||
|
||||
return id == 0 ? (dv == 0 ? (dspv == 0 ? ((def.tagCompound == null ? 0 : def.tagCompound.hashCode()) - (b.def.tagCompound == null ? 0
|
||||
: b.def.tagCompound.hashCode())) : dspv) : dv) : id;
|
||||
return id == 0 ? (dv == 0 ? (dspv == 0 ? ((def.tagCompound == null ? 0 : def.tagCompound.getHash()) - (b.def.tagCompound == null ? 0
|
||||
: b.def.tagCompound.getHash())) : dspv) : dv) : id;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -22,6 +22,11 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound
|
||||
public SharedSearchObject sso;
|
||||
private IItemComparison comp;
|
||||
|
||||
public int getHash()
|
||||
{
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemComparison getSpecialComparison()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user