use of crazypants.enderio.base.conduit.IConduitBundle in project EnderIO by SleepyTrousers.
the class PowerConduit method getExternalPowerReceptor.
@Override
public IPowerInterface getExternalPowerReceptor(@Nonnull EnumFacing direction) {
TileEntity te = bundle.getEntity();
World world = te.getWorld();
TileEntity test = world.getTileEntity(te.getPos().offset(direction));
if (test == null) {
return null;
}
if (test instanceof IConduitBundle) {
return null;
}
return PowerHandlerUtil.getPowerInterface(test, direction.getOpposite());
}
use of crazypants.enderio.base.conduit.IConduitBundle in project EnderIO by SleepyTrousers.
the class ConduitBundleRenderer method render.
// TESR rendering
@Override
public void render(@Nonnull TileConduitBundle te, double x, double y, double z, float partialTick, int b, float alpha) {
IConduitBundle bundle = te;
EntityPlayerSP player = Minecraft.getMinecraft().player;
if (bundle.hasFacade() && bundle.getPaintSource().isOpaqueCube() && !YetaUtil.isFacadeHidden(bundle, player)) {
return;
}
float brightness = -1;
boolean hasDynamic = false;
for (IClientConduit c : bundle.getClientConduits()) {
// TODO Temporary work around
IClientConduit.WithDefaultRendering con = (IClientConduit.WithDefaultRendering) c;
if (YetaUtil.renderConduit(player, con)) {
IConduitRenderer renderer = getRendererForConduit(con);
if (renderer.isDynamic()) {
if (!hasDynamic) {
hasDynamic = true;
BlockPos loc = bundle.getLocation();
brightness = bundle.getEntity().getWorld().getLightFor(EnumSkyBlock.SKY, loc);
RenderUtil.setupLightmapCoords(te.getPos(), te.getWorld());
RenderUtil.bindBlockTexture();
GlStateManager.enableNormalize();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.shadeModel(GL11.GL_SMOOTH);
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder tes = tessellator.getBuffer();
tes.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
}
renderer.renderDynamicEntity(this, bundle, con, x, y, z, partialTick, brightness);
}
}
}
if (hasDynamic) {
Tessellator.getInstance().draw();
GlStateManager.disableNormalize();
GlStateManager.disableBlend();
GlStateManager.shadeModel(GL11.GL_FLAT);
GlStateManager.popMatrix();
}
}
use of crazypants.enderio.base.conduit.IConduitBundle in project EnderIO by SleepyTrousers.
the class ConduitBundleRenderer method getGeneralQuads.
// ------------ Block Model building
@Nonnull
public List<BakedQuad> getGeneralQuads(@Nonnull IBlockStateWrapper state, BlockRenderLayer layer) {
if (layer != null && layer != BlockRenderLayer.CUTOUT) {
return Collections.emptyList();
}
List<BakedQuad> result = new ArrayList<BakedQuad>();
IConduitBundle bundle = (IConduitBundle) state.getTileEntity();
if (bundle != null) {
if (layer == null) {
addBreakingQuads(bundle, result);
} else {
float brightness;
if (!ConduitConfig.updateLightingWhenHidingFacades.get() && bundle.hasFacade()) {
brightness = 15 << 20 | 15 << 4;
} else {
brightness = bundle.getEntity().getWorld().getLightFor(EnumSkyBlock.SKY, bundle.getLocation());
}
// TODO: check if this is the client thread, if not, make a copy of the bundle and its conduits in a thread-safe way
addConduitQuads(state, bundle, brightness, layer, result);
}
}
return result;
}
use of crazypants.enderio.base.conduit.IConduitBundle in project EnderIO by SleepyTrousers.
the class AbstractConduitPacket method getConduit.
@SuppressWarnings("unchecked")
@Nullable
public T getConduit(MessageContext ctx) {
if (ctx.side == Side.SERVER) {
if (ctx.getServerHandler().player.openContainer instanceof ExternalConnectionContainer) {
final TileConduitBundle tileEntity = ((ExternalConnectionContainer) ctx.getServerHandler().player.openContainer).getTileEntity();
if (tileEntity == null || !tileEntity.getPos().equals(getPos())) {
Log.warn("Player " + ctx.getServerHandler().player.getName() + " tried to manipulate conduit while having another conduit's GUI open!");
return null;
}
} else {
if (BlockCoord.get(ctx.getServerHandler().player).distanceSq(getPos()) > EnderIO.proxy.getReachDistanceForPlayer(ctx.getServerHandler().player)) {
Log.warn("Player " + ctx.getServerHandler().player.getName() + " tried to manipulate conduit without having its GUI open or being near it!");
return null;
}
}
}
World world = getWorld(ctx);
TileEntity tileEntity = getTileEntity(world);
if (tileEntity instanceof IConduitBundle) {
return (T) ((IConduitBundle) tileEntity).getConduit(getConType());
}
return null;
}
use of crazypants.enderio.base.conduit.IConduitBundle in project EnderIO by SleepyTrousers.
the class ItemConduitFacade method onItemUse.
@SuppressWarnings("deprecation")
@Override
@Nonnull
public EnumActionResult onItemUse(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumHand hand, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ) {
if (world.isRemote) {
return EnumActionResult.SUCCESS;
}
Block conduitBlock = Registry.getConduitBlock();
if (conduitBlock != null) {
ItemStack stack = player.getHeldItem(hand);
BlockPos placeAt = pos.offset(side);
if (player.canPlayerEdit(placeAt, side, stack) && PaintUtil.getSourceBlock(stack) != null) {
if (world.isAirBlock(placeAt)) {
world.setBlockState(placeAt, conduitBlock.getDefaultState());
IConduitBundle bundle = NullHelper.notnullM((IConduitBundle) world.getTileEntity(placeAt), "placing block yielded no tileentity");
IBlockState bs = PaintUtil.getSourceBlock(stack);
bundle.setFacadeType(EnumFacadeType.getTypeFromMeta(stack.getItemDamage()));
bundle.setPaintSource(bs);
ConduitUtil.playPlaceSound(bs.getBlock().getSoundType(), world, pos);
if (!player.capabilities.isCreativeMode) {
stack.shrink(1);
}
return EnumActionResult.SUCCESS;
} else {
TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof IConduitBundle) {
if (((IConduitBundle) tileEntity).handleFacadeClick(world, placeAt, player, side.getOpposite(), stack, hand, hitX, hitY, hitZ)) {
return EnumActionResult.SUCCESS;
}
}
}
}
}
return EnumActionResult.PASS;
}
Aggregations