Search in sources :

Example 1 with BlockRedstoneWire

use of net.minecraft.block.BlockRedstoneWire in project BetterWithAddons by DaedalusGame.

the class AssortedHandler method makeRedstonePCB.

private void makeRedstonePCB(World world, BlockPos pos) {
    IBlockState blockstate = world.getBlockState(pos);
    Block block = blockstate.getBlock();
    Block bottomblock = world.getBlockState(pos.down()).getBlock();
    if (!world.isRemote && block instanceof BlockRedstoneWire && bottomblock instanceof BlockPCB) {
        world.setBlockState(pos, ModBlocks.pcbwire.getDefaultState());
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockRedstoneWire(net.minecraft.block.BlockRedstoneWire) BlockPCB(betterwithaddons.block.BetterRedstone.BlockPCB)

Example 2 with BlockRedstoneWire

use of net.minecraft.block.BlockRedstoneWire in project Random-Things by lumien231.

the class RTEventHandler method renderRedstoneTool.

private void renderRedstoneTool(RenderGameOverlayEvent event) {
    ItemStack equippedItem;
    Minecraft minecraft = Minecraft.getMinecraft();
    if (!(equippedItem = minecraft.player.getHeldItemMainhand()).isEmpty()) {
        if (equippedItem.getItem() == ModItems.redstoneTool) {
            RayTraceResult objectMouseOver = minecraft.objectMouseOver;
            if (objectMouseOver != null && objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK) {
                IBlockState hitState = minecraft.world.getBlockState(objectMouseOver.getBlockPos());
                Block hitBlock = hitState.getBlock();
                if (hitBlock instanceof BlockRedstoneWire) {
                    int width = event.getResolution().getScaledWidth();
                    int height = event.getResolution().getScaledHeight();
                    int power = hitState.getValue(BlockRedstoneWire.POWER);
                    GlStateManager.disableBlend();
                    Minecraft.getMinecraft().fontRenderer.drawString(power + "", width / 2 + 5, height / 2 + 5, Colors.RED_INT);
                    GlStateManager.color(1, 1, 1, 1);
                    GlStateManager.enableBlend();
                }
            }
        } else if (equippedItem.getItem() == ModItems.ingredients && equippedItem.getItemDamage() == ItemIngredient.INGREDIENT.BIOME_SENSOR.id) {
            Biome b = minecraft.world.getBiome(minecraft.player.getPosition());
            int width = event.getResolution().getScaledWidth();
            int height = event.getResolution().getScaledHeight();
            GlStateManager.disableBlend();
            Minecraft.getMinecraft().fontRenderer.drawString(b.getBiomeName(), width / 2 + 5, height / 2 + 5, Colors.WHITE_INT);
            GlStateManager.color(1, 1, 1, 1);
            GlStateManager.enableBlend();
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Biome(net.minecraft.world.biome.Biome) RayTraceResult(net.minecraft.util.math.RayTraceResult) Block(net.minecraft.block.Block) RightClickBlock(net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock) BlockCompressedSlimeBlock(lumien.randomthings.block.BlockCompressedSlimeBlock) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) BlockRedstoneWire(net.minecraft.block.BlockRedstoneWire)

Example 3 with BlockRedstoneWire

use of net.minecraft.block.BlockRedstoneWire in project Charset by CharsetMC.

the class PartGate method updateInputs.

public boolean updateInputs(byte[] values) {
    byte[] oldValues = new byte[4];
    boolean changed = false;
    System.arraycopy(values, 0, oldValues, 0, 4);
    for (int i = 0; i <= 3; i++) {
        EnumFacing facing = EnumFacing.getFront(i + 2);
        GateLogic.Connection conn = logic.getType(facing);
        values[i] = 0;
        if (conn.isInput() && conn.isRedstone()) {
            if (logic.isSideOpen(facing)) {
                EnumFacing real = gateToReal(facing);
                World w = getWorld();
                BlockPos p = getPos().offset(real);
                int mpValue = SimpleLogicGates.proxyMultipart.getWeakPower(w, p, real);
                if (mpValue >= 0) {
                    values[i] = (byte) mpValue;
                } else {
                    TileEntity tile = w.getTileEntity(p);
                    if (tile != null && tile.hasCapability(Capabilities.REDSTONE_EMITTER, real.getOpposite())) {
                        values[i] = (byte) tile.getCapability(Capabilities.REDSTONE_EMITTER, real.getOpposite()).getRedstoneSignal();
                    } else {
                        IBlockState s = w.getBlockState(p);
                        if (RedstoneUtils.canConnectFace(w, p, s, real, getSide())) {
                            if (s.getBlock() instanceof BlockRedstoneWire) {
                                values[i] = s.getValue(BlockRedstoneWire.POWER).byteValue();
                            } else {
                                values[i] = (byte) s.getWeakPower(w, p, real);
                            }
                        }
                    }
                }
                if (conn.isDigital()) {
                    values[i] = values[i] != 0 ? (byte) 15 : 0;
                }
                if (logic.isSideInverted(facing)) {
                    values[i] = values[i] != 0 ? 0 : (byte) 15;
                }
            }
            if (values[i] != oldValues[i]) {
                changed = true;
            }
        }
    }
    return changed;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) GateLogic(pl.asie.simplelogic.gates.logic.GateLogic) BlockRedstoneWire(net.minecraft.block.BlockRedstoneWire)

Example 4 with BlockRedstoneWire

use of net.minecraft.block.BlockRedstoneWire in project TUMAT by canitzp.

the class Vanilla method renderBlock.

@Override
public TooltipComponent renderBlock(WorldClient world, EntityPlayerSP player, BlockPos pos, EnumFacing side, TooltipComponent component, boolean shouldCalculate) {
    IBlockState state = world.getBlockState(pos);
    // Plants:
    if (state.getBlock() instanceof IPlantable) {
        IBlockState plant = ((IPlantable) state.getBlock()).getPlant(world, pos);
        if (plant != null) {
            if (ConfigBoolean.SHOW_PLANT_GROWTH_STATUS.value && plant.getBlock() instanceof BlockCrops) {
                try {
                    PropertyInteger prop = (PropertyInteger) getAgeProperty.invoke(plant.getBlock());
                    int plantStatus = state.getValue(prop);
                    float growStatus = Math.round((plantStatus / (prop.getAllowedValues().size() - 1 * 1.0F) * 100F) * 100.00F) / 100.00F;
                    ColoredText.createOneLine(component, L10n.getVanillaGrowRate(String.valueOf(growStatus)), ColoredText.Colors.BROWN_PLANT);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (plant.getBlock() instanceof BlockDoublePlant && InfoUtil.hasProperty(plant, BlockDoublePlant.HALF)) {
                BlockDoublePlant.EnumBlockHalf half = plant.getValue(BlockDoublePlant.HALF);
                if (half == BlockDoublePlant.EnumBlockHalf.UPPER) {
                    IBlockState down = world.getBlockState(pos.down());
                    component.setName(new TextComponent(InfoUtil.getBlockName(down)));
                }
            }
        }
    }
    if (ConfigBoolean.SHOW_REDSTONE_STRENGTH.value) {
        int power = state.getWeakPower(world, pos, side);
        if (power > 0 || state.getBlock() instanceof BlockRedstoneWire) {
            ColoredText.createOneLine(component, L10n.getVanillaRedstoneStrength(power), ColoredText.Colors.RED_REDSTONE);
        }
        if (state.getBlock() instanceof BlockRedstoneRepeater) {
            ColoredText.createOneLine(component, L10n.getVanillaRedstoneDelay(state.getValue(BlockRedstoneRepeater.DELAY)), ColoredText.Colors.RED_REDSTONE);
            if (state.getValue(BlockRedstoneRepeater.LOCKED)) {
                TextComponent.createOneLine(component, L10n.REDSTONE_LOCKED, TextFormatting.GRAY);
            }
        }
    }
    if (ConfigBoolean.SHOW_LIGHT_LEVEL.value) {
        boolean isBlockLightSource = state.getLightValue(world, pos) != 0;
        if (!isBlockLightSource && !world.getBlockState(pos.up()).isFullCube() && !world.getBlockState(pos.up()).isFullBlock()) {
            int lightLevel = world.getLightFor(EnumSkyBlock.BLOCK, pos.up());
            TextFormatting canMobsSpawn = world.getWorldTime() % 24000 >= 13000 && lightLevel <= 7 && state.getBlock().canCreatureSpawn(state, world, pos, EntityLiving.SpawnPlacementType.ON_GROUND) ? TextFormatting.RED : TextFormatting.YELLOW;
            TextComponent.createOneLine(component, L10n.getVanillaLight(lightLevel), canMobsSpawn);
        }
        if (isBlockLightSource) {
            int lightValue = state.getLightValue(world, pos);
            TextComponent.createOneLine(component, L10n.getVanillaLightSource(lightValue), TextFormatting.YELLOW);
        }
    }
    return component;
}
Also used : TextComponent(de.canitzp.tumat.api.components.TextComponent) IBlockState(net.minecraft.block.state.IBlockState) BlockCrops(net.minecraft.block.BlockCrops) PropertyInteger(net.minecraft.block.properties.PropertyInteger) IPlantable(net.minecraftforge.common.IPlantable) BlockDoublePlant(net.minecraft.block.BlockDoublePlant) BlockRedstoneRepeater(net.minecraft.block.BlockRedstoneRepeater) TextFormatting(net.minecraft.util.text.TextFormatting) BlockRedstoneWire(net.minecraft.block.BlockRedstoneWire)

Aggregations

BlockRedstoneWire (net.minecraft.block.BlockRedstoneWire)4 IBlockState (net.minecraft.block.state.IBlockState)4 Block (net.minecraft.block.Block)2 BlockPCB (betterwithaddons.block.BetterRedstone.BlockPCB)1 TextComponent (de.canitzp.tumat.api.components.TextComponent)1 BlockCompressedSlimeBlock (lumien.randomthings.block.BlockCompressedSlimeBlock)1 BlockCrops (net.minecraft.block.BlockCrops)1 BlockDoublePlant (net.minecraft.block.BlockDoublePlant)1 BlockRedstoneRepeater (net.minecraft.block.BlockRedstoneRepeater)1 PropertyInteger (net.minecraft.block.properties.PropertyInteger)1 Minecraft (net.minecraft.client.Minecraft)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 TextFormatting (net.minecraft.util.text.TextFormatting)1 World (net.minecraft.world.World)1 Biome (net.minecraft.world.biome.Biome)1 IPlantable (net.minecraftforge.common.IPlantable)1 RightClickBlock (net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock)1