Merge branch 'nightly' into marmot

This commit is contained in:
SpaceToad 2014-01-11 10:49:34 +01:00
commit c0cbc7f841
7 changed files with 36 additions and 7 deletions

View file

@ -102,7 +102,7 @@ public class BlockArchitect extends BlockContainer {
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) {
super.onBlockPlacedBy(world, i, j, k, entityliving, stack);
ForgeDirection orientation = Utils.get2dOrientation(new Position(entityliving.posX, entityliving.posY, entityliving.posZ), new Position(i, j, k));
ForgeDirection orientation = Utils.get2dOrientation(entityliving);
world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(),1);
}

View file

@ -105,7 +105,7 @@ public class BlockBuilder extends BlockContainer {
@Override
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) {
super.onBlockPlacedBy(world, i, j, k, entityliving, stack);
ForgeDirection orientation = Utils.get2dOrientation(new Position(entityliving.posX, entityliving.posY, entityliving.posZ), new Position(i, j, k));
ForgeDirection orientation = Utils.get2dOrientation(entityliving);
world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(), 1);
}

View file

@ -25,13 +25,16 @@ import buildcraft.core.network.ISynchronizedTile;
import buildcraft.core.network.PacketUpdate;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.energy.TileEngine;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryLargeChest;
import net.minecraft.item.ItemStack;
@ -40,6 +43,7 @@ import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
@ -77,7 +81,23 @@ public class Utils {
}
public static ForgeDirection get2dOrientation(Position pos1, Position pos2) {
/**
* Returns the cardinal direction of the entity depending on its
* rotationYaw
*/
public static ForgeDirection get2dOrientation(EntityLivingBase entityliving) {
ForgeDirection[] orientationTable = { ForgeDirection.SOUTH,
ForgeDirection.WEST, ForgeDirection.NORTH, ForgeDirection.EAST };
int orientationIndex = MathHelper
.floor_double((entityliving.rotationYaw + 45.0) / 90.0) & 3;
return orientationTable[orientationIndex];
}
/*
* FIXME This is only kept here for the purpose of get3dOrientation, which
* should probably be removed following the same principles
*/
private static ForgeDirection get2dOrientation(Position pos1, Position pos2) {
double Dx = pos1.x - pos2.x;
double Dz = pos1.z - pos2.z;
double angle = Math.atan2(Dz, Dx) / Math.PI * 180 + 180;

View file

@ -56,7 +56,7 @@ public class BlockMiningWell extends BlockBuildCraft {
@Override
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) {
ForgeDirection orientation = Utils.get2dOrientation(new Position(entityliving.posX, entityliving.posY, entityliving.posZ), new Position(i, j, k));
ForgeDirection orientation = Utils.get2dOrientation(entityliving);
world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(),1);
}

View file

@ -25,6 +25,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
@ -46,7 +47,7 @@ public class BlockQuarry extends BlockBuildCraft {
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) {
super.onBlockPlacedBy(world, i, j, k, entityliving, stack);
ForgeDirection orientation = Utils.get2dOrientation(new Position(entityliving.posX, entityliving.posY, entityliving.posZ), new Position(i, j, k));
ForgeDirection orientation = Utils.get2dOrientation(entityliving);
world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(), 1);
if (entityliving instanceof EntityPlayer) {

View file

@ -74,7 +74,7 @@ public class BlockRefinery extends BlockContainer {
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) {
super.onBlockPlacedBy(world, i, j, k, entityliving, stack);
ForgeDirection orientation = Utils.get2dOrientation(new Position(entityliving.posX, entityliving.posY, entityliving.posZ), new Position(i, j, k));
ForgeDirection orientation = Utils.get2dOrientation(entityliving);
world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(), 1);
}

View file

@ -110,7 +110,9 @@ public class ContainerGateInterface extends BuildCraftContainer {
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
public boolean canInteractWith(EntityPlayer player) {
if (pipe == null || pipe.gate == null)
return false;
return true;
}
@ -364,10 +366,14 @@ public class ContainerGateInterface extends BuildCraftContainer {
}
public boolean isNearbyTriggerActive(ITrigger trigger, ITriggerParameter parameter) {
if (pipe.gate == null)
return false;
return pipe.gate.isNearbyTriggerActive(trigger, parameter);
}
public void setTrigger(int position, ITrigger trigger, boolean notify) {
if (pipe.gate == null)
return;
pipe.gate.setTrigger(position, trigger);
if (CoreProxy.proxy.isRenderWorld(pipe.container.worldObj) && notify) {
sendSelectionChange(position);
@ -375,6 +381,8 @@ public class ContainerGateInterface extends BuildCraftContainer {
}
public void setTriggerParameter(int position, ITriggerParameter parameter, boolean notify) {
if (pipe.gate == null)
return;
pipe.gate.setTriggerParameter(position, parameter);
if (CoreProxy.proxy.isRenderWorld(pipe.container.worldObj) && notify) {
sendSelectionChange(position);