use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class ModelConveyor method getQuads.
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState blockState, @Nullable EnumFacing side, long rand) {
TileEntity tile = null;
String key = "default";
EnumFacing facing = EnumFacing.NORTH;
if (blockState == null)
key = conveyor != null ? ConveyorHandler.reverseClassRegistry.get(conveyor.getClass()).toString() : "immersiveengineering:conveyor";
else {
facing = blockState.getValue(IEProperties.FACING_ALL);
if (blockState instanceof IExtendedBlockState) {
IExtendedBlockState exState = (IExtendedBlockState) blockState;
if (exState.getUnlistedNames().contains(BlockConveyor.ICONEYOR_PASSTHROUGH))
conveyor = ((IExtendedBlockState) blockState).getValue(BlockConveyor.ICONEYOR_PASSTHROUGH);
if (exState.getUnlistedNames().contains(IEProperties.TILEENTITY_PASSTHROUGH))
tile = ((IExtendedBlockState) blockState).getValue(IEProperties.TILEENTITY_PASSTHROUGH);
if (conveyor != null && tile != null)
key = conveyor.getModelCacheKey(tile, facing);
}
}
List<BakedQuad> cachedQuads = modelCache.get(key);
if (cachedQuads != null)
return Collections.synchronizedList(Lists.newArrayList(cachedQuads));
else {
cachedQuads = Collections.synchronizedList(Lists.newArrayList());
Matrix4f facingMatrix = TRSRTransformation.getMatrix(facing);
if (conveyor != null)
facingMatrix = conveyor.modifyBaseRotationMatrix(facingMatrix, tile, facing);
Matrix4 matrix = new Matrix4(facingMatrix);
ConveyorDirection conDir = conveyor != null ? conveyor.getConveyorDirection() : ConveyorDirection.HORIZONTAL;
boolean[] walls = conveyor != null && tile != null ? new boolean[] { conveyor.renderWall(tile, facing, 0), conveyor.renderWall(tile, facing, 1) } : new boolean[] { true, true };
TextureAtlasSprite tex_conveyor = ClientUtils.mc().getTextureMapBlocks().getMissingSprite();
TextureAtlasSprite tex_conveyor_colour = null;
int colourStripes = -1;
if (conveyor != null) {
tex_conveyor = ClientUtils.getSprite(tile != null ? (conveyor.isActive(tile) ? conveyor.getActiveTexture() : conveyor.getInactiveTexture()) : conveyor.getActiveTexture());
if ((colourStripes = conveyor.getDyeColour()) >= 0)
tex_conveyor_colour = ClientUtils.getSprite(conveyor.getColouredStripesTexture());
}
cachedQuads.addAll(getBaseConveyor(facing, 1, matrix, conDir, tex_conveyor, walls, new boolean[] { true, true }, tex_conveyor_colour, colourStripes));
if (conveyor != null)
cachedQuads = conveyor.modifyQuads(cachedQuads, tile, facing);
modelCache.put(key, cachedQuads);
return Collections.synchronizedList(Lists.newArrayList(cachedQuads));
}
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileEntitySorter method routeItem.
public ItemStack routeItem(EnumFacing inputSide, ItemStack stack, boolean simulate) {
if (!worldObj.isRemote) {
Integer[][] validOutputs = getValidOutputs(inputSide, stack, true, false);
if (validOutputs[0].length > 0) {
int rand = worldObj.rand.nextInt(validOutputs[0].length);
stack = this.outputItemToInv(stack, EnumFacing.getFront(validOutputs[0][rand]), simulate);
if (stack != null)
for (int i = 0; i < validOutputs[0].length; i++) if (i != rand) {
stack = this.outputItemToInv(stack, EnumFacing.getFront(validOutputs[0][i]), simulate);
if (stack == null)
return null;
}
}
if (stack != null && validOutputs[1].length > 0) {
if (!simulate) {
int rand = worldObj.rand.nextInt(validOutputs[1].length);
EnumFacing fd = EnumFacing.getFront(validOutputs[1][rand]);
EntityItem ei = new EntityItem(worldObj, getPos().getX() + .5 + fd.getFrontOffsetX(), getPos().getY() + .5 + fd.getFrontOffsetY(), getPos().getZ() + .5 + fd.getFrontOffsetZ(), stack.copy());
ei.motionX = (0.075F * fd.getFrontOffsetX());
ei.motionY = 0.025000000372529D;
ei.motionZ = (0.075F * fd.getFrontOffsetZ());
this.worldObj.spawnEntityInWorld(ei);
}
return null;
}
if (validOutputs[2].length > 0) {
int rand = worldObj.rand.nextInt(validOutputs[2].length);
stack = this.outputItemToInv(stack, EnumFacing.getFront(validOutputs[2][rand]), simulate);
if (stack != null)
for (int i = 0; i < validOutputs[2].length; i++) if (i != rand) {
stack = this.outputItemToInv(stack, EnumFacing.getFront(validOutputs[2][i]), simulate);
if (stack == null)
return null;
}
}
if (stack != null && validOutputs[3].length > 0) {
if (!simulate) {
int rand = worldObj.rand.nextInt(validOutputs[3].length);
EnumFacing fd = EnumFacing.getFront(validOutputs[1][rand]);
EntityItem ei = new EntityItem(worldObj, getPos().getX() + .5 + fd.getFrontOffsetX(), getPos().getY() + .5 + fd.getFrontOffsetY(), getPos().getZ() + .5 + fd.getFrontOffsetZ(), stack.copy());
ei.motionX = (0.075F * fd.getFrontOffsetX());
ei.motionY = 0.025000000372529D;
ei.motionZ = (0.075F * fd.getFrontOffsetZ());
this.worldObj.spawnEntityInWorld(ei);
}
return null;
}
}
return stack;
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileEntityWallmount method getBlockBounds.
@Override
public float[] getBlockBounds() {
EnumFacing towards = orientation > 1 ? facing.getOpposite() : facing;
float minX = towards == EnumFacing.WEST ? 0 : .3125f;
float minY = orientation == 0 ? .375f : orientation == 2 ? .3125f : 0;
float minZ = towards == EnumFacing.NORTH ? 0 : .3125f;
float maxX = towards == EnumFacing.EAST ? 1 : .6875f;
float maxY = orientation == 1 ? .625f : orientation == 3 ? .6875f : 1;
float maxZ = towards == EnumFacing.SOUTH ? 1 : .6875f;
return new float[] { minX, minY, minZ, maxX, maxY, maxZ };
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileEntityWoodenPost method compileDisplayList.
@Override
public ArrayList<String> compileDisplayList() {
if (dummy != 0)
return emptyDisplayList;
ArrayList<String> list = new ArrayList();
list.add("base");
TileEntity te;
for (int i = 0; i <= 2; i++) {
te = worldObj.getTileEntity(getPos().add(0, 1 + i, 0));
if (//Stacked pieces
te instanceof TileEntityWoodenPost) {
for (EnumFacing f : EnumFacing.HORIZONTALS) if (((TileEntityWoodenPost) te).hasConnection(f)) {
if (//Arms
i == 2) {
TileEntityWoodenPost arm = (TileEntityWoodenPost) worldObj.getTileEntity(pos.add(0, 1 + i, 0).offset(f));
boolean up = arm.hasConnection(EnumFacing.UP);
boolean down = arm.hasConnection(EnumFacing.DOWN);
if (up || (!up && !down))
list.add("arm_" + f.getName2() + "_up");
if (down)
list.add("arm_" + f.getName2() + "_down");
} else
//Simple Connectors
list.add("con_" + i + "_" + f.getName2());
}
}
}
return list;
}
use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.
the class TileEntitySorter method getValidOutputs.
public Integer[][] getValidOutputs(EnumFacing inputSide, ItemStack stack, boolean allowUnmapped, boolean allowThrowing) {
if (isRouting || stack == null)
return new Integer[][] { {}, {}, {}, {} };
this.isRouting = true;
ArrayList<Integer> validFilteredInvOuts = new ArrayList<Integer>(6);
ArrayList<Integer> validFilteredEntityOuts = new ArrayList<Integer>(6);
ArrayList<Integer> validUnfilteredInvOuts = new ArrayList<Integer>(6);
ArrayList<Integer> validUnfilteredEntityOuts = new ArrayList<Integer>(6);
for (EnumFacing side : EnumFacing.values()) if (side != inputSide) {
boolean unmapped = true;
boolean allowed = false;
filterIteration: {
for (ItemStack filterStack : filter.filters[side.ordinal()]) if (filterStack != null) {
unmapped = false;
boolean b = OreDictionary.itemMatches(filterStack, stack, true);
if (!b && doFuzzy(side.ordinal()))
b = filterStack.getItem().equals(stack.getItem());
if (!b && doOredict(side.ordinal()))
for (String name : OreDictionary.getOreNames()) if (Utils.compareToOreName(stack, name) && Utils.compareToOreName(filterStack, name)) {
b = true;
break;
}
if (doNBT(side.ordinal()))
b &= Utils.compareItemNBT(filterStack, stack);
if (b) {
allowed = true;
break filterIteration;
}
}
}
if (allowed) {
TileEntity inventory = this.worldObj.getTileEntity(getPos().offset(side));
if (Utils.canInsertStackIntoInventory(inventory, stack, side.getOpposite()))
validFilteredInvOuts.add(side.ordinal());
else if (allowThrowing)
validFilteredEntityOuts.add(side.ordinal());
} else if (allowUnmapped && unmapped) {
TileEntity inventory = this.worldObj.getTileEntity(getPos().offset(side));
if (Utils.canInsertStackIntoInventory(inventory, stack, side.getOpposite()))
validUnfilteredInvOuts.add(side.ordinal());
else if (allowThrowing)
validUnfilteredEntityOuts.add(side.ordinal());
}
}
this.isRouting = false;
return new Integer[][] { validFilteredInvOuts.toArray(new Integer[validFilteredInvOuts.size()]), validFilteredEntityOuts.toArray(new Integer[validFilteredEntityOuts.size()]), validUnfilteredInvOuts.toArray(new Integer[validUnfilteredInvOuts.size()]), validUnfilteredEntityOuts.toArray(new Integer[validUnfilteredEntityOuts.size()]) };
}
Aggregations