Added environmental sensor to read local time and weather prediction

This commit is contained in:
Unknown 2020-04-25 16:10:54 +02:00 committed by unknown
parent 6c1d31942a
commit 807cb8ea9c
24 changed files with 655 additions and 1 deletions

View file

@ -41,6 +41,7 @@ import cr0s.warpdrive.block.decoration.BlockLamp_long;
import cr0s.warpdrive.block.detection.BlockCamera; import cr0s.warpdrive.block.detection.BlockCamera;
import cr0s.warpdrive.block.detection.BlockCloakingCoil; import cr0s.warpdrive.block.detection.BlockCloakingCoil;
import cr0s.warpdrive.block.detection.BlockCloakingCore; import cr0s.warpdrive.block.detection.BlockCloakingCore;
import cr0s.warpdrive.block.detection.BlockEnvironmentalSensor;
import cr0s.warpdrive.block.detection.BlockMonitor; import cr0s.warpdrive.block.detection.BlockMonitor;
import cr0s.warpdrive.block.detection.BlockRadar; import cr0s.warpdrive.block.detection.BlockRadar;
import cr0s.warpdrive.block.detection.BlockSiren; import cr0s.warpdrive.block.detection.BlockSiren;
@ -48,6 +49,7 @@ import cr0s.warpdrive.block.detection.BlockSpeaker;
import cr0s.warpdrive.block.detection.BlockWarpIsolation; import cr0s.warpdrive.block.detection.BlockWarpIsolation;
import cr0s.warpdrive.block.detection.TileEntityCamera; import cr0s.warpdrive.block.detection.TileEntityCamera;
import cr0s.warpdrive.block.detection.TileEntityCloakingCore; import cr0s.warpdrive.block.detection.TileEntityCloakingCore;
import cr0s.warpdrive.block.detection.TileEntityEnvironmentalSensor;
import cr0s.warpdrive.block.detection.TileEntityMonitor; import cr0s.warpdrive.block.detection.TileEntityMonitor;
import cr0s.warpdrive.block.detection.TileEntityRadar; import cr0s.warpdrive.block.detection.TileEntityRadar;
import cr0s.warpdrive.block.detection.TileEntitySiren; import cr0s.warpdrive.block.detection.TileEntitySiren;
@ -273,6 +275,7 @@ public class WarpDrive {
public static Block blockCamera; public static Block blockCamera;
public static Block blockCloakingCoil; public static Block blockCloakingCoil;
public static Block blockCloakingCore; public static Block blockCloakingCore;
public static Block blockEnvironmentalSensor;
public static Block blockMonitor; public static Block blockMonitor;
public static Block blockRadar; public static Block blockRadar;
public static Block[] blockSirenIndustrial; public static Block[] blockSirenIndustrial;
@ -470,6 +473,7 @@ public class WarpDrive {
blockCamera = new BlockCamera("camera", EnumTier.BASIC); blockCamera = new BlockCamera("camera", EnumTier.BASIC);
blockCloakingCoil = new BlockCloakingCoil("cloaking_coil", EnumTier.BASIC); blockCloakingCoil = new BlockCloakingCoil("cloaking_coil", EnumTier.BASIC);
blockCloakingCore = new BlockCloakingCore("cloaking_core", EnumTier.BASIC); blockCloakingCore = new BlockCloakingCore("cloaking_core", EnumTier.BASIC);
blockEnvironmentalSensor = new BlockEnvironmentalSensor("environmental_sensor", EnumTier.BASIC);
blockMonitor = new BlockMonitor("monitor", EnumTier.BASIC); blockMonitor = new BlockMonitor("monitor", EnumTier.BASIC);
blockRadar = new BlockRadar("radar", EnumTier.BASIC); blockRadar = new BlockRadar("radar", EnumTier.BASIC);
@ -1033,6 +1037,7 @@ public class WarpDrive {
GameRegistry.registerTileEntity(TileEntityCloakingCore.class, new ResourceLocation(WarpDrive.MODID, "cloaking_core")); GameRegistry.registerTileEntity(TileEntityCloakingCore.class, new ResourceLocation(WarpDrive.MODID, "cloaking_core"));
GameRegistry.registerTileEntity(TileEntityEnanReactorCore.class, new ResourceLocation(WarpDrive.MODID, "enan_reactor_core")); GameRegistry.registerTileEntity(TileEntityEnanReactorCore.class, new ResourceLocation(WarpDrive.MODID, "enan_reactor_core"));
GameRegistry.registerTileEntity(TileEntityEnanReactorLaser.class, new ResourceLocation(WarpDrive.MODID, "enan_reactor_laser")); GameRegistry.registerTileEntity(TileEntityEnanReactorLaser.class, new ResourceLocation(WarpDrive.MODID, "enan_reactor_laser"));
GameRegistry.registerTileEntity(TileEntityEnvironmentalSensor.class, new ResourceLocation(WarpDrive.MODID, "environmental_sensor"));
GameRegistry.registerTileEntity(TileEntityForceField.class, new ResourceLocation(WarpDrive.MODID, "force_field")); GameRegistry.registerTileEntity(TileEntityForceField.class, new ResourceLocation(WarpDrive.MODID, "force_field"));
GameRegistry.registerTileEntity(TileEntityForceFieldProjector.class, new ResourceLocation(WarpDrive.MODID, "force_field_projector")); GameRegistry.registerTileEntity(TileEntityForceFieldProjector.class, new ResourceLocation(WarpDrive.MODID, "force_field_projector"));
GameRegistry.registerTileEntity(TileEntityForceFieldRelay.class, new ResourceLocation(WarpDrive.MODID, "force_field_relay")); GameRegistry.registerTileEntity(TileEntityForceFieldRelay.class, new ResourceLocation(WarpDrive.MODID, "force_field_relay"));

View file

@ -140,9 +140,11 @@ public abstract class BlockAbstractBase extends Block implements IBlockBase {
final boolean hasVideoChannel = tileEntity instanceof IVideoChannel; final boolean hasVideoChannel = tileEntity instanceof IVideoChannel;
// video channel is reported client side, everything else is reported server side // video channel is reported client side, everything else is reported server side
// we still need to process the event server side for machines that are not full blocks, so in that case we return true
if ( world.isRemote if ( world.isRemote
&& !hasVideoChannel ) { && !hasVideoChannel ) {
return false; return tileEntityAbstractBase instanceof TileEntityAbstractMachine
&& itemStackHeld.getItem() == Item.getItemFromBlock(Blocks.REDSTONE_TORCH);
} }
UpgradeSlot upgradeSlot = tileEntityAbstractBase.getUpgradeSlot(itemStackHeld); UpgradeSlot upgradeSlot = tileEntityAbstractBase.getUpgradeSlot(itemStackHeld);

View file

@ -0,0 +1,153 @@
package cr0s.warpdrive.block.detection;
import cr0s.warpdrive.block.BlockAbstractRotatingContainer;
import cr0s.warpdrive.block.ItemBlockAbstractBase;
import cr0s.warpdrive.data.BlockProperties;
import cr0s.warpdrive.data.EnumTier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.BlockFaceShape;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockEnvironmentalSensor extends BlockAbstractRotatingContainer {
private static final AxisAlignedBB AABB_DOWN = new AxisAlignedBB(0.000D, 0.625D, 0.000D, 1.000D, 1.000D, 1.000D);
private static final AxisAlignedBB AABB_UP = new AxisAlignedBB(0.000D, 0.000D, 0.000D, 1.000D, 0.375D, 1.000D);
private static final AxisAlignedBB AABB_NORTH = new AxisAlignedBB(0.000D, 0.000D, 0.625D, 1.000D, 1.000D, 1.000D);
private static final AxisAlignedBB AABB_SOUTH = new AxisAlignedBB(0.000D, 0.000D, 0.000D, 1.000D, 1.000D, 0.375D);
private static final AxisAlignedBB AABB_WEST = new AxisAlignedBB(0.625D, 0.000D, 0.000D, 1.000D, 1.000D, 1.000D);
private static final AxisAlignedBB AABB_EAST = new AxisAlignedBB(0.000D, 0.000D, 0.000D, 0.375D, 1.000D, 1.000D);
private static final AxisAlignedBB AABB_FULL = FULL_BLOCK_AABB;
public BlockEnvironmentalSensor(final String registryName, final EnumTier enumTier) {
super(registryName, enumTier, Material.IRON);
setTranslationKey("warpdrive.detection.environmental_sensor");
}
@Nonnull
@Override
public TileEntity createNewTileEntity(@Nonnull final World world, final int metadata) {
return new TileEntityEnvironmentalSensor();
}
@SuppressWarnings("deprecation")
@Override
public int getLightOpacity(@Nonnull final IBlockState blockState) {
final EnumFacing enumFacing = blockState.getValue(BlockProperties.FACING);
if (enumFacing.getYOffset() != 0 ) {
return 255;
}
return 0;
}
@SuppressWarnings("deprecation")
@Nonnull
@Override
public AxisAlignedBB getBoundingBox(@Nonnull final IBlockState blockState, final IBlockAccess blockAccess, final BlockPos blockPos) {
return getBlockBoundsFromState(blockState);
}
@SuppressWarnings("deprecation")
@Nullable
@Override
public AxisAlignedBB getCollisionBoundingBox(final IBlockState blockState, @Nonnull final IBlockAccess blockAccess, @Nonnull final BlockPos blockPos) {
return getBlockBoundsFromState(blockState);
}
private AxisAlignedBB getBlockBoundsFromState(final IBlockState blockState) {
if (blockState == null) {
return AABB_FULL;
}
switch (blockState.getValue(BlockProperties.FACING)) {
case DOWN : return AABB_DOWN;
case UP : return AABB_UP;
case NORTH: return AABB_NORTH;
case SOUTH: return AABB_SOUTH;
case WEST : return AABB_WEST;
case EAST : return AABB_EAST;
default: return AABB_FULL;
}
}
@SuppressWarnings("deprecation")
@Override
public boolean isTopSolid(@Nonnull final IBlockState blockState) {
final EnumFacing enumFacing = blockState.getValue(BlockProperties.FACING);
return enumFacing == EnumFacing.DOWN;
}
@SuppressWarnings("deprecation")
@Nonnull
@Override
public BlockFaceShape getBlockFaceShape(@Nonnull final IBlockAccess blockAccess, @Nonnull final IBlockState blockState, @Nonnull final BlockPos blockPos, @Nonnull final EnumFacing facing) {
final EnumFacing enumFacing = blockState.getValue(BlockProperties.FACING);
return facing == enumFacing.getOpposite() ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED;
}
@SuppressWarnings("deprecation")
@Override
public boolean isFullBlock(@Nonnull final IBlockState blockState) {
return false;
}
@SuppressWarnings("deprecation")
@Override
public boolean isFullCube(@Nonnull final IBlockState blockState) {
return false;
}
@SuppressWarnings("deprecation")
@SideOnly(Side.CLIENT)
@Override
public boolean shouldSideBeRendered(@Nonnull final IBlockState blockState, @Nonnull final IBlockAccess blockAccess, @Nonnull final BlockPos blockPos, @Nonnull final EnumFacing facing) {
final BlockPos blockPosSide = blockPos.offset(facing);
final boolean doesSideBlockRendering = blockAccess.getBlockState(blockPosSide).doesSideBlockRendering(blockAccess, blockPosSide, facing);
return !doesSideBlockRendering;
}
@SuppressWarnings("deprecation")
@Override
public boolean isOpaqueCube(@Nonnull final IBlockState blockState) {
return false;
}
@Override
public boolean doesSideBlockRendering(@Nonnull final IBlockState blockState, final IBlockAccess blockAccess, final BlockPos blockPos, final EnumFacing side) {
final EnumFacing enumFacing = blockState.getValue(BlockProperties.FACING);
return enumFacing.getOpposite() == side;
}
@SuppressWarnings("deprecation")
@Override
public boolean isSideSolid(@Nonnull final IBlockState blockState, @Nonnull final IBlockAccess blockAccess, @Nonnull final BlockPos blockPos, final EnumFacing side) {
final EnumFacing enumFacing = blockState.getValue(BlockProperties.FACING);
return enumFacing.getOpposite() == side;
}
@Nullable
@Override
public ItemBlock createItemBlock() {
return new ItemBlockAbstractBase(this, false, true);
}
@Override
public boolean onBlockActivated(final World world, final BlockPos blockPos, final IBlockState blockState, final EntityPlayer entityPlayer, final EnumHand enumHand, final EnumFacing enumFacing, final float hitX, final float hitY, final float hitZ) {
return super.onBlockActivated(world, blockPos, blockState, entityPlayer, enumHand, enumFacing, hitX, hitY, hitZ);
}
}

View file

@ -0,0 +1,110 @@
package cr0s.warpdrive.block.detection;
import cr0s.warpdrive.block.TileEntityAbstractMachine;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.BlockProperties;
import li.cil.oc.api.machine.Arguments;
import li.cil.oc.api.machine.Callback;
import li.cil.oc.api.machine.Context;
import javax.annotation.Nonnull;
import java.util.Collections;
import net.minecraft.block.state.IBlockState;
import net.minecraftforge.fml.common.Optional;
public class TileEntityEnvironmentalSensor extends TileEntityAbstractMachine {
// persistent properties
// (none)
// computed properties
private int tickUpdate;
public TileEntityEnvironmentalSensor() {
super();
peripheralName = "warpdriveEnvironmentalSensor";
addMethods(new String[] {
"getWeather",
"getWorldTime"
});
CC_scripts = Collections.singletonList("clock");
}
@Override
public void update() {
super.update();
if (world.isRemote) {
return;
}
tickUpdate--;
if (tickUpdate >= 0) {
return;
}
tickUpdate = WarpDriveConfig.G_PARAMETERS_UPDATE_INTERVAL_TICKS;
final IBlockState blockState = world.getBlockState(pos);
updateBlockState(blockState, BlockProperties.ACTIVE, isEnabled);
}
// Common OC/CC methods
public Object[] getWeather() {
if (!isEnabled) {
return new Object[] { false, "Sensor is disabled." };
}
// note: we return estimated time in seconds as it's more natural. Also the smooth transition adds a bit of delay anyway.
if (world.isThundering()) {
return new Object[] { true, "THUNDER", world.getWorldInfo().getThunderTime() / 20 };
} else if (world.isRaining()) {
return new Object[] { true, "RAIN", world.getWorldInfo().getRainTime() / 20 };
}
return new Object[] { true, "CLEAR", world.getWorldInfo().getCleanWeatherTime() / 20 };
}
public Object[] getWorldTime() {
if (!isEnabled) {
return new Object[] { false, "Sensor is disabled." };
}
// returns the current day, hour of the day, minutes of the day, and number of seconds simulated in the world (or play time for single player).
// note: we return simulated seconds as it's more natural and discourages continuous pooling/abuse in LUA.
final int day = (int) ((6000L + world.getWorldTime()) / 24000L);
final int dayTime = 2400 * (int) ((6000L + world.getWorldTime()) % 24000L) / 24000;
return new Object[] { true, day, dayTime / 100, (dayTime % 100) * 60 / 100, world.getTotalWorldTime() / 20 };
}
// OpenComputers callback methods
@Callback(direct = true)
@Optional.Method(modid = "opencomputers")
public Object[] getWeather(final Context context, final Arguments arguments) {
OC_convertArgumentsAndLogCall(context, arguments);
return getWeather();
}
@Callback(direct = true)
@Optional.Method(modid = "opencomputers")
public Object[] getWorldTime(final Context context, final Arguments arguments) {
OC_convertArgumentsAndLogCall(context, arguments);
return getWorldTime();
}
// ComputerCraft IPeripheral methods
@Override
@Optional.Method(modid = "computercraft")
protected Object[] CC_callMethod(@Nonnull final String methodName, @Nonnull final Object[] arguments) {
switch (methodName) {
case "getWeather":
return getWeather();
case "getWorldTime":
return getWorldTime();
}
return super.CC_callMethod(methodName, arguments);
}
}

View file

@ -1283,6 +1283,14 @@ public class Recipes {
'c', oreGoldIngotOrCoil, 'c', oreGoldIngotOrCoil,
'm', itemStackMachineCasings[3] )); 'm', itemStackMachineCasings[3] ));
// Environmental sensor
WarpDrive.register(new ShapedOreRecipe(groupMachines,
WarpDrive.blockEnvironmentalSensor, " ", "dcd", "rCr",
'r', rubber,
'c', Items.CLOCK,
'd', Blocks.DAYLIGHT_DETECTOR,
'C', ItemComponent.getItemStack(EnumComponentType.COMPUTER_INTERFACE) ));
// Monitor is 3 Flat screen, 1 Computer interface, 1 Tuning diamond, 1 LV Machine casing // Monitor is 3 Flat screen, 1 Computer interface, 1 Tuning diamond, 1 LV Machine casing
WarpDrive.register(new ShapedOreRecipe(groupMachines, WarpDrive.register(new ShapedOreRecipe(groupMachines,
new ItemStack(WarpDrive.blockMonitor), false, "fd ", "fm ", "f ", new ItemStack(WarpDrive.blockMonitor), false, "fd ", "fm ", "f ",

View file

@ -0,0 +1,25 @@
{
"forge_marker": 1,
"defaults": {
"textures": {
"front_offline" : "warpdrive:blocks/detection/environmental_sensor-front_offline",
"front_online" : "warpdrive:blocks/detection/environmental_sensor-front_online",
"side" : "warpdrive:blocks/detection/environmental_sensor-side"
}
},
"variants": {
"active=false,facing=down" : { "model": "warpdrive:sensor_down" , "textures": { "front": "#front_offline" } },
"active=false,facing=up" : { "model": "warpdrive:sensor_up" , "textures": { "front": "#front_offline" } },
"active=false,facing=north" : { "model": "warpdrive:sensor_north", "textures": { "front": "#front_offline" } },
"active=false,facing=south" : { "model": "warpdrive:sensor_south", "textures": { "front": "#front_offline" } },
"active=false,facing=east" : { "model": "warpdrive:sensor_east" , "textures": { "front": "#front_offline" } },
"active=false,facing=west" : { "model": "warpdrive:sensor_west" , "textures": { "front": "#front_offline" } },
"active=true,facing=down" : { "model": "warpdrive:sensor_down" , "textures": { "front": "#front_online" } },
"active=true,facing=up" : { "model": "warpdrive:sensor_up" , "textures": { "front": "#front_online" } },
"active=true,facing=north" : { "model": "warpdrive:sensor_north", "textures": { "front": "#front_online" } },
"active=true,facing=south" : { "model": "warpdrive:sensor_south", "textures": { "front": "#front_online" } },
"active=true,facing=east" : { "model": "warpdrive:sensor_east" , "textures": { "front": "#front_online" } },
"active=true,facing=west" : { "model": "warpdrive:sensor_west" , "textures": { "front": "#front_online" } },
"inventory" : { "model": "warpdrive:sensor_up" , "textures": { "front": "#front_online" } }
}
}

View file

@ -302,6 +302,8 @@ tile.warpdrive.collection.mining_laser.name=Bergbau Laser
tile.warpdrive.detection.camera.name=Kamera tile.warpdrive.detection.camera.name=Kamera
tile.warpdrive.detection.cloaking_coil.name=Tarnfeld Spule tile.warpdrive.detection.cloaking_coil.name=Tarnfeld Spule
tile.warpdrive.detection.cloaking_core.name=Tarnfeld Kern tile.warpdrive.detection.cloaking_core.name=Tarnfeld Kern
tile.warpdrive.detection.environmental_sensor.name=Environmental Sensor
tile.warpdrive.detection.environmental_sensor.tooltip=Reports local time and weather
tile.warpdrive.detection.monitor.name=Monitor tile.warpdrive.detection.monitor.name=Monitor
tile.warpdrive.detection.radar.name=Radar tile.warpdrive.detection.radar.name=Radar
tile.warpdrive.detection.warp_isolation.name=Warp-Feld Isolations Block tile.warpdrive.detection.warp_isolation.name=Warp-Feld Isolations Block

View file

@ -302,6 +302,8 @@ tile.warpdrive.collection.mining_laser.name=Mining Laser
tile.warpdrive.detection.camera.name=Camera tile.warpdrive.detection.camera.name=Camera
tile.warpdrive.detection.cloaking_coil.name=Cloaking Coil tile.warpdrive.detection.cloaking_coil.name=Cloaking Coil
tile.warpdrive.detection.cloaking_core.name=Cloaking Core tile.warpdrive.detection.cloaking_core.name=Cloaking Core
tile.warpdrive.detection.environmental_sensor.name=Environmental Sensor
tile.warpdrive.detection.environmental_sensor.tooltip=Reports local time and weather
tile.warpdrive.detection.monitor.name=Monitor tile.warpdrive.detection.monitor.name=Monitor
tile.warpdrive.detection.radar.name=Radar tile.warpdrive.detection.radar.name=Radar
tile.warpdrive.detection.warp_isolation.name=Warp-field Isolation Block tile.warpdrive.detection.warp_isolation.name=Warp-field Isolation Block

View file

@ -302,6 +302,8 @@ tile.warpdrive.collection.mining_laser.name=Laser de minage
tile.warpdrive.detection.camera.name=Caméra tile.warpdrive.detection.camera.name=Caméra
tile.warpdrive.detection.cloaking_coil.name=Bobine d'invisibilité tile.warpdrive.detection.cloaking_coil.name=Bobine d'invisibilité
tile.warpdrive.detection.cloaking_core.name=Noyau d'invisibilité tile.warpdrive.detection.cloaking_core.name=Noyau d'invisibilité
tile.warpdrive.detection.environmental_sensor.name=Capteur environmental
tile.warpdrive.detection.environmental_sensor.tooltip=Rapporte l'heure et la météo locale
tile.warpdrive.detection.monitor.name=Moniteur tile.warpdrive.detection.monitor.name=Moniteur
tile.warpdrive.detection.radar.name=Radar tile.warpdrive.detection.radar.name=Radar
tile.warpdrive.detection.warp_isolation.name=Bloc d'isolation de champ de Warp tile.warpdrive.detection.warp_isolation.name=Bloc d'isolation de champ de Warp

View file

@ -302,6 +302,8 @@ tile.warpdrive.collection.mining_laser.name=Mijnlaser
tile.warpdrive.detection.camera.name=Camera tile.warpdrive.detection.camera.name=Camera
tile.warpdrive.detection.cloaking_coil.name=Dekmantelveld-spoel tile.warpdrive.detection.cloaking_coil.name=Dekmantelveld-spoel
tile.warpdrive.detection.cloaking_core.name=Dekmantelveld-kern tile.warpdrive.detection.cloaking_core.name=Dekmantelveld-kern
tile.warpdrive.detection.environmental_sensor.name=Environmental Sensor
tile.warpdrive.detection.environmental_sensor.tooltip=Reports local time and weather
tile.warpdrive.detection.monitor.name=Monitor tile.warpdrive.detection.monitor.name=Monitor
tile.warpdrive.detection.radar.name=Radar tile.warpdrive.detection.radar.name=Radar
tile.warpdrive.detection.warp_isolation.name=Warp-veld isolatieblok tile.warpdrive.detection.warp_isolation.name=Warp-veld isolatieblok

View file

@ -302,6 +302,8 @@ tile.warpdrive.collection.mining_laser.name=Лазерная буровая ус
tile.warpdrive.detection.camera.name=Камера видеонаблюдения tile.warpdrive.detection.camera.name=Камера видеонаблюдения
tile.warpdrive.detection.cloaking_coil.name=Маскировочная катушка tile.warpdrive.detection.cloaking_coil.name=Маскировочная катушка
tile.warpdrive.detection.cloaking_core.name=Маскировщик tile.warpdrive.detection.cloaking_core.name=Маскировщик
tile.warpdrive.detection.environmental_sensor.name=Environmental Sensor
tile.warpdrive.detection.environmental_sensor.tooltip=Reports local time and weather
tile.warpdrive.detection.monitor.name=Монитор tile.warpdrive.detection.monitor.name=Монитор
tile.warpdrive.detection.radar.name=Варп-радар tile.warpdrive.detection.radar.name=Варп-радар
tile.warpdrive.detection.warp_isolation.name=Блок изоляции варп-поля tile.warpdrive.detection.warp_isolation.name=Блок изоляции варп-поля

View file

@ -302,6 +302,8 @@ tile.warpdrive.collection.mining_laser.name=采矿激光
tile.warpdrive.detection.camera.name=摄像机 tile.warpdrive.detection.camera.name=摄像机
tile.warpdrive.detection.cloaking_coil.name=隐形线圈 tile.warpdrive.detection.cloaking_coil.name=隐形线圈
tile.warpdrive.detection.cloaking_core.name=隐形核心 tile.warpdrive.detection.cloaking_core.name=隐形核心
tile.warpdrive.detection.environmental_sensor.name=Environmental Sensor
tile.warpdrive.detection.environmental_sensor.tooltip=Reports local time and weather
tile.warpdrive.detection.monitor.name=监视器 tile.warpdrive.detection.monitor.name=监视器
tile.warpdrive.detection.radar.name=雷达 tile.warpdrive.detection.radar.name=雷达
tile.warpdrive.detection.warp_isolation.name=曲速场隔离方块 tile.warpdrive.detection.warp_isolation.name=曲速场隔离方块

View file

@ -302,6 +302,8 @@ tile.warpdrive.collection.mining_laser.name=采礦鐳射
tile.warpdrive.detection.camera.name=相機 tile.warpdrive.detection.camera.name=相機
tile.warpdrive.detection.cloaking_coil.name=偽裝線圈 tile.warpdrive.detection.cloaking_coil.name=偽裝線圈
tile.warpdrive.detection.cloaking_core.name=僞裝核心 tile.warpdrive.detection.cloaking_core.name=僞裝核心
tile.warpdrive.detection.environmental_sensor.name=Environmental Sensor
tile.warpdrive.detection.environmental_sensor.tooltip=Reports local time and weather
tile.warpdrive.detection.monitor.name=監控 tile.warpdrive.detection.monitor.name=監控
tile.warpdrive.detection.radar.name=雷達 tile.warpdrive.detection.radar.name=雷達
tile.warpdrive.detection.warp_isolation.name=躍遷力場隔絕方塊 tile.warpdrive.detection.warp_isolation.name=躍遷力場隔絕方塊

View file

@ -0,0 +1,100 @@
if not term.isColor() then
print("Advanced computer required")
error()
end
local sides = peripheral.getNames()
local environmentalSensors = {}
for _, side in pairs(sides) do
if peripheral.getType(side) == "warpdriveEnvironmentalSensor" then
print("Wrapping " .. side)
table.insert(environmentalSensors, peripheral.wrap(side))
end
end
local noExit = true
if #environmentalSensors == 0 then
term.setBackgroundColor(colors.red)
term.setTextColor(colors.white)
print("No environmental sensor detected")
noExit = false
end
local label = os.getComputerLabel()
if label then
else
label = "" .. os.getComputerID()
end
if noExit then
local isRunning = true
repeat
for key, environmentalSensor in pairs(environmentalSensors) do
local isSuccessWeather, currentWeather, nextWeatherSeconds = environmentalSensor.getWeather()
local isSuccessWorldTime, day, hours, minutes, totalSeconds = environmentalSensor.getWorldTime()
term.setBackgroundColor(colors.black)
term.setTextColor(colors.blue)
term.clear()
term.setBackgroundColor(colors.lime)
term.setCursorPos(1, 1)
term.write(label .. " - Environmental sensor " .. key .. " of " .. #environmentalSensors)
term.setBackgroundColor(colors.black)
term.setCursorPos(1, 3)
if isSuccessWeather then
if currentWeather == "CLEAR" then
term.setTextColor(colors.yellow)
elseif currentWeather == "RAIN" then
term.setTextColor(colors.blue)
else
term.setTextColor(colors.orange)
end
term.write("Local weather is " .. currentWeather .. ", changing in " .. nextWeatherSeconds .. " s.")
else
-- show failure message
term.setTextColor(colors.red)
term.write("Local weather is ? (" .. currentWeather .. ")")
end
term.setCursorPos(1, 5)
if isSuccessWorldTime then
if hours >= 6 and hours < 18 then
term.setTextColor(colors.white)
else
term.setTextColor(colors.lightGray)
end
term.write("Day " .. day)
else
-- show failure message
term.setTextColor(colors.red)
term.write("Day ? (" .. day .. ")")
end
term.setCursorPos(1, 7)
if isSuccessWorldTime then
if hours >= 6 and hours < 18 then
term.setTextColor(colors.white)
else
term.setTextColor(colors.lightGray)
end
term.write("Local time is " .. string.format("%02d", hours) .. ":" .. string.format("%02d", minutes))
else
-- show failure message
term.setTextColor(colors.red)
term.write("Local time is ? (" .. day .. ")")
end
os.sleep(1)
end
until not isRunning
end
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
print()
print("Program closed")

View file

@ -0,0 +1,117 @@
local component = require("component")
local computer = require("computer")
local term = require("term")
if not term.isAvailable() then
computer.beep()
os.exit()
end
if component.gpu.getDepth() < 4 then
print("A tier 2 or higher GPU is required")
os.exit()
end
local environmentalSensors = {}
for address, _ in component.list("warpdriveEnvironmentalSensor", true) do
print("Wrapping " .. address)
table.insert(environmentalSensors, component.proxy(address))
end
function textOut(x, y, text, fg, bg)
if term.isAvailable() then
local w, _ = component.gpu.getResolution()
if w then
component.gpu.setBackground(bg)
component.gpu.setForeground(fg)
component.gpu.set(x, y, text)
component.gpu.setBackground(0x000000)
end
end
end
local noExit = true
if #environmentalSensors == 0 then
computer.beep()
textOut(1, 2, "No environmental sensor detected", 0xFFFFFF, 0xFF0000)
noExit = false
end
local file = io.open("/etc/hostname")
local label
if file then
label = file:read("*l")
file:close()
else
label = "" .. computer.address()
end
if noExit then
local isRunning = true
repeat
for key, environmentalSensor in pairs(environmentalSensors) do
local isSuccessWeather, currentWeather, nextWeatherSeconds = environmentalSensor.getWeather()
local isSuccessWorldTime, day, hours, minutes, totalSeconds = environmentalSensor.getWorldTime()
term.clear()
textOut(1, 1, label .. " - Environmental sensor " .. key .. " of " .. #environmentalSensors, 0x0000FF, 0x00FF00)
if isSuccessWeather then
local colorText
if currentWeather == "CLEAR" then
colorText = 0xFFFF00
elseif currentWeather == "RAIN" then
colorText = 0x8080FF
else
colorText = 0xFF8080
end
textOut(1, 3, "Local weather is " .. currentWeather .. ", changing in " .. string.format("%d", math.floor(nextWeatherSeconds)) .. " s.", colorText, 0x000000)
else
-- show failure message
textOut(1, 3, "Local weather is ? (" .. currentWeather .. ")", 0xFF0000, 0x000000)
end
if isSuccessWorldTime then
local colorText
if hours >= 6 and hours < 18 then
colorText = 0xFFFFFF
else
colorText = 0x808080
end
textOut(1, 5, "Day " .. string.format("%d", math.floor(day)), colorText, 0x000000)
else
-- show failure message
textOut(1, 5, "Day ? (" .. day .. ")", 0xFF0000, 0x000000)
end
if isSuccessWorldTime then
if hours >= 6 and hours < 18 then
colorText = 0xFFFFFF
else
colorText = 0x808080
end
textOut(1, 7, "Local time is " .. string.format("%02d", hours) .. ":" .. string.format("%02d", minutes), colorText, 0x000000)
else
-- show failure message
textOut(1, 7, "Local time is ? (" .. day .. ")", 0xFF0000, 0x000000)
end
os.sleep(1)
end
until not isRunning
end
textOut(1, 1, "", 0xFFFFFF, 0x000000)
print()
print()
print()
print()
print()
print()
print()
print()
print()
print()
print("Program closed")

View file

@ -0,0 +1,20 @@
{
"parent": "block/block",
"textures": {
"particle": "#front"
},
"elements": [
{
"from": [ 0, 10, 0 ],
"to": [ 16, 16, 16 ],
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#front" },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cullface": "up" },
"north": { "uv": [ 0, 10, 16, 16 ], "texture": "#side", "cullface": "north" },
"south": { "uv": [ 0, 10, 16, 16 ], "texture": "#side", "cullface": "south" },
"west": { "uv": [ 0, 10, 16, 16 ], "texture": "#side", "cullface": "west" },
"east": { "uv": [ 0, 10, 16, 16 ], "texture": "#side", "cullface": "east" }
}
}
]
}

View file

@ -0,0 +1,20 @@
{
"parent": "block/block",
"textures": {
"particle": "#front"
},
"elements": [
{
"from": [ 0, 0, 0 ],
"to": [ 6, 16, 16 ],
"faces": {
"down": { "uv": [ 10, 0, 16, 16 ], "texture": "#side", "cullface": "down" },
"up": { "uv": [ 0, 0, 6, 16 ], "texture": "#side", "cullface": "up" },
"north": { "uv": [ 10, 0, 16, 16 ], "texture": "#side", "cullface": "north" },
"south": { "uv": [ 0, 0, 6, 16 ], "texture": "#side", "cullface": "south" },
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cullface": "west" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#front" }
}
}
]
}

View file

@ -0,0 +1,20 @@
{
"parent": "block/block",
"textures": {
"particle": "#front"
},
"elements": [
{
"from": [ 0, 0, 10 ],
"to": [ 16, 16, 16 ],
"faces": {
"down": { "uv": [ 0, 0, 16, 6 ], "texture": "#side", "cullface": "down" },
"up": { "uv": [ 0, 10, 16, 16 ], "texture": "#side", "cullface": "up" },
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#front" },
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cullface": "south" },
"west": { "uv": [ 10, 0, 16, 16 ], "texture": "#side", "cullface": "west" },
"east": { "uv": [ 0, 0, 6, 16 ], "texture": "#side", "cullface": "east" }
}
}
]
}

View file

@ -0,0 +1,20 @@
{
"parent": "block/block",
"textures": {
"particle": "#front"
},
"elements": [
{
"from": [ 0, 0, 0 ],
"to": [ 16, 16, 6 ],
"faces": {
"down": { "uv": [ 0, 10, 16, 16 ], "texture": "#side", "cullface": "down" },
"up": { "uv": [ 0, 0, 16, 6 ], "texture": "#side", "cullface": "up" },
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cullface": "north" },
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#front" },
"west": { "uv": [ 0, 0, 6, 16 ], "texture": "#side", "cullface": "west" },
"east": { "uv": [ 10, 0, 16, 16 ], "texture": "#side", "cullface": "east" }
}
}
]
}

View file

@ -0,0 +1,20 @@
{
"parent": "block/block",
"textures": {
"particle": "#front"
},
"elements": [
{
"from": [ 0, 0, 0 ],
"to": [ 16, 6, 16 ],
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cullface": "down" },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#front" },
"north": { "uv": [ 0, 0, 16, 6 ], "texture": "#side", "cullface": "north" },
"south": { "uv": [ 0, 0, 16, 6 ], "texture": "#side", "cullface": "south" },
"west": { "uv": [ 0, 0, 16, 6 ], "texture": "#side", "cullface": "west" },
"east": { "uv": [ 0, 0, 16, 6 ], "texture": "#side", "cullface": "east" }
}
}
]
}

View file

@ -0,0 +1,20 @@
{
"parent": "block/block",
"textures": {
"particle": "#front"
},
"elements": [
{
"from": [ 10, 0, 0 ],
"to": [ 16, 16, 16 ],
"faces": {
"down": { "uv": [ 0, 0, 6, 16 ], "texture": "#side", "cullface": "down" },
"up": { "uv": [ 10, 0, 16, 16 ], "texture": "#side", "cullface": "up" },
"north": { "uv": [ 0, 0, 6, 16 ], "texture": "#side", "cullface": "north" },
"south": { "uv": [ 10, 0, 16, 16 ], "texture": "#side", "cullface": "south" },
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#front" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#side", "cullface": "east" }
}
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB