use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt in project ImmersiveEngineering by BluSunrize.
the class BlockConveyor method onIEBlockPlacedBy.
@Override
public void onIEBlockPlacedBy(World world, BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase placer, ItemStack stack) {
super.onIEBlockPlacedBy(world, pos, state, side, hitX, hitY, hitZ, placer, stack);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileEntityConveyorBelt && !(tile instanceof TileEntityConveyorVertical)) {
TileEntityConveyorBelt conveyor = (TileEntityConveyorBelt) tile;
EnumFacing f = conveyor.facing;
ResourceLocation rl = new ResourceLocation(ItemNBTHelper.getString(stack, "conveyorType"));
IConveyorBelt subType = ConveyorHandler.getConveyor(rl, conveyor);
conveyor.setConveyorSubtype(subType);
tile = world.getTileEntity(pos.offset(f));
TileEntity tileUp = world.getTileEntity(pos.offset(f).add(0, 1, 0));
if (subType != null && (!(tile instanceof IConveyorTile) || ((IConveyorTile) tile).getFacing() == f.getOpposite()) && tileUp instanceof IConveyorTile && ((IConveyorTile) tileUp).getFacing() != f.getOpposite() && world.isAirBlock(pos.add(0, 1, 0)))
subType.setConveyorDirection(ConveyorDirection.UP);
tile = world.getTileEntity(pos.offset(f.getOpposite()).add(0, 1, 0));
// if(tile instanceof TileEntityConveyorBelt&&!(tile instanceof TileEntityConveyorVertical) && ((TileEntityConveyorBelt)tile).facing==f)
// conveyor.transportDown = true;
// if(conveyor.transportUp && conveyor.transportDown)
// conveyor.transportDown = false;
}
}
use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt 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;
IConveyorBelt conveyor = defaultBelt;
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 ImmutableList.copyOf(cachedQuads);
else {
if (conveyor == null)
conveyor = ConveyorHandler.getConveyor(new ResourceLocation(key), tile);
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, ImmutableList.copyOf(cachedQuads));
return ImmutableList.copyOf(cachedQuads);
}
}
use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt in project ImmersiveEngineering by BluSunrize.
the class TileEntityConveyorBelt method readOnPlacement.
@Override
public void readOnPlacement(EntityLivingBase placer, ItemStack stack) {
String key = ItemNBTHelper.getString(stack, "conveyorType");
IConveyorBelt subType = ConveyorHandler.getConveyor(new ResourceLocation(key), this);
setConveyorSubtype(subType);
}
use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt in project ImmersiveEngineering by BluSunrize.
the class ConveyorVertical method isInwardConveyor.
protected boolean isInwardConveyor(TileEntity tile, EnumFacing f) {
TileEntity te = tile.getWorld().getTileEntity(tile.getPos().offset(f));
if (te instanceof IConveyorTile) {
IConveyorBelt sub = ((IConveyorTile) te).getConveyorSubtype();
if (sub != null)
for (EnumFacing f2 : sub.sigTransportDirections(te, ((IConveyorTile) te).getFacing())) if (f2 == EnumFacing.UP)
break;
else if (f == f2.getOpposite())
return true;
}
te = tile.getWorld().getTileEntity(tile.getPos().add(0, -1, 0).offset(f));
if (te instanceof IConveyorTile) {
IConveyorBelt sub = ((IConveyorTile) te).getConveyorSubtype();
if (sub != null) {
int b = 0;
for (EnumFacing f2 : sub.sigTransportDirections(te, ((IConveyorTile) te).getFacing())) {
if (f == f2.getOpposite())
b++;
else if (EnumFacing.UP == f2)
b++;
if (b == 2)
return true;
}
}
}
return false;
}
use of blusunrize.immersiveengineering.api.tool.ConveyorHandler.IConveyorBelt in project ImmersiveEngineering by BluSunrize.
the class ClientProxy method drawConveyorInGui.
@Override
public boolean drawConveyorInGui(String conveyor, EnumFacing facing) {
IConveyorBelt con = ConveyorHandler.getConveyor(new ResourceLocation(conveyor), null);
if (con != null) {
GlStateManager.pushMatrix();
List<BakedQuad> quads = ModelConveyor.getBaseConveyor(facing, 1, new Matrix4(facing), ConveyorDirection.HORIZONTAL, ClientUtils.getSprite(con.getActiveTexture()), new boolean[] { true, true }, new boolean[] { true, true }, null, 0);
// GlStateManager.translate(0, 0, 1);
ClientUtils.renderQuads(quads, 1, 1, 1, 1);
GlStateManager.popMatrix();
return true;
}
return false;
}
Aggregations