use of micdoodle8.mods.galacticraft.core.blocks.BlockUnlitTorch in project Galacticraft by micdoodle8.
the class GCBlocks method initBlocks.
public static void initBlocks() {
GCBlocks.breatheableAir = new BlockBreathableAir("breatheable_air");
GCBlocks.brightAir = new BlockBrightAir("bright_air");
GCBlocks.brightBreatheableAir = new BlockBrightBreathableAir("bright_breathable_air");
GCBlocks.brightLamp = new BlockBrightLamp("arclamp");
GCBlocks.treasureChestTier1 = new BlockTier1TreasureChest("treasure_chest");
GCBlocks.landingPad = new BlockLandingPad("landing_pad");
GCBlocks.landingPadFull = new BlockLandingPadFull("landing_pad_full");
GCBlocks.unlitTorch = new BlockUnlitTorch(false, "unlit_torch");
GCBlocks.unlitTorchLit = new BlockUnlitTorch(true, "unlit_torch_lit");
GCBlocks.oxygenDistributor = new BlockOxygenDistributor("distributor");
GCBlocks.oxygenPipe = new BlockFluidPipe("fluid_pipe", BlockFluidPipe.EnumPipeMode.NORMAL);
GCBlocks.oxygenPipePull = new BlockFluidPipe("fluid_pipe_pull", BlockFluidPipe.EnumPipeMode.PULL);
GCBlocks.oxygenCollector = new BlockOxygenCollector("collector");
GCBlocks.nasaWorkbench = new BlockNasaWorkbench("rocket_workbench");
GCBlocks.fallenMeteor = new BlockFallenMeteor("fallen_meteor");
GCBlocks.basicBlock = new BlockBasic("basic_block_core");
GCBlocks.airLockFrame = new BlockAirLockFrame("air_lock_frame");
GCBlocks.airLockSeal = new BlockAirLockWall("air_lock_seal");
// These glass types have to be registered as 6 separate blocks, (a) to allow different coloring of each one and (b) because the Forge MultiLayer custom model does not allow for different textures to be set for different variants
GCBlocks.spaceGlassVanilla = (BlockSpaceGlass) new BlockSpaceGlass("space_glass_vanilla", GlassType.VANILLA, GlassFrame.PLAIN, null).setHardness(0.3F).setResistance(3F);
GCBlocks.spaceGlassClear = (BlockSpaceGlass) new BlockSpaceGlass("space_glass_clear", GlassType.CLEAR, GlassFrame.PLAIN, null).setHardness(0.3F).setResistance(3F);
GCBlocks.spaceGlassStrong = (BlockSpaceGlass) new BlockSpaceGlass("space_glass_strong", GlassType.STRONG, GlassFrame.PLAIN, null).setHardness(4F).setResistance(35F);
GCBlocks.spaceGlassTinVanilla = (BlockSpaceGlass) new BlockSpaceGlass("space_glass_vanilla_tin", GlassType.VANILLA, GlassFrame.TIN_DECO, GCBlocks.spaceGlassVanilla).setHardness(0.3F).setResistance(4F);
GCBlocks.spaceGlassTinClear = (BlockSpaceGlass) new BlockSpaceGlass("space_glass_clear_tin", GlassType.CLEAR, GlassFrame.TIN_DECO, GCBlocks.spaceGlassClear).setHardness(0.3F).setResistance(4F);
GCBlocks.spaceGlassTinStrong = (BlockSpaceGlass) new BlockSpaceGlass("space_glass_strong_tin", GlassType.STRONG, GlassFrame.TIN_DECO, GCBlocks.spaceGlassStrong).setHardness(4F).setResistance(35F);
GCBlocks.crafting = new BlockCrafting("magnetic_table");
GCBlocks.refinery = new BlockRefinery("refinery");
GCBlocks.oxygenCompressor = new BlockOxygenCompressor(false, "oxygen_compressor");
GCBlocks.fuelLoader = new BlockFuelLoader("fuel_loader");
GCBlocks.spaceStationBase = new BlockSpaceStationBase("space_station_base");
GCBlocks.fakeBlock = new BlockMulti("block_multi");
GCBlocks.oxygenSealer = new BlockOxygenSealer("sealer");
GCBlocks.sealableBlock = new BlockEnclosed("enclosed");
GCBlocks.oxygenDetector = new BlockOxygenDetector("oxygen_detector");
GCBlocks.cargoLoader = new BlockCargoLoader("cargo");
GCBlocks.parachest = new BlockParaChest("parachest");
GCBlocks.solarPanel = new BlockSolar("solar");
GCBlocks.radioTelescope = new BlockDish("dishbase");
GCBlocks.machineBase = new BlockMachine("machine");
GCBlocks.machineBase2 = new BlockMachine2("machine2");
GCBlocks.machineBase3 = new BlockMachine3("machine3");
GCBlocks.machineTiered = new BlockMachineTiered("machine_tiered");
GCBlocks.aluminumWire = new BlockAluminumWire("aluminum_wire");
GCBlocks.panelLighting = new BlockPanelLighting("panel_lighting");
GCBlocks.glowstoneTorch = new BlockGlowstoneTorch("glowstone_torch");
GCBlocks.blockMoon = new BlockBasicMoon("basic_block_moon");
GCBlocks.cheeseBlock = new BlockCheese("cheese");
GCBlocks.spinThruster = new BlockSpinThruster("spin_thruster");
GCBlocks.screen = new BlockScreen("view_screen");
GCBlocks.telemetry = new BlockTelemetry("telemetry");
GCBlocks.fluidTank = new BlockFluidTank("fluid_tank");
GCBlocks.bossSpawner = new BlockBossSpawner("boss_spawner");
GCBlocks.slabGCHalf = new BlockSlabGC("slab_gc_half", Material.rock);
GCBlocks.slabGCDouble = new BlockDoubleSlabGC("slab_gc_double", Material.rock);
GCBlocks.tinStairs1 = new BlockStairsGC("tin_stairs_1", basicBlock.getDefaultState().withProperty(BlockBasic.BASIC_TYPE, BlockBasic.EnumBlockBasic.ALUMINUM_DECORATION_BLOCK_0)).setHardness(2.0F);
GCBlocks.tinStairs2 = new BlockStairsGC("tin_stairs_2", basicBlock.getDefaultState().withProperty(BlockBasic.BASIC_TYPE, BlockBasic.EnumBlockBasic.ALUMINUM_DECORATION_BLOCK_1)).setHardness(2.0F);
GCBlocks.moonStoneStairs = new BlockStairsGC("moon_stairs_stone", blockMoon.getDefaultState().withProperty(BlockBasicMoon.BASIC_TYPE_MOON, BlockBasicMoon.EnumBlockBasicMoon.MOON_STONE)).setHardness(1.5F);
GCBlocks.moonBricksStairs = new BlockStairsGC("moon_stairs_brick", blockMoon.getDefaultState().withProperty(BlockBasicMoon.BASIC_TYPE_MOON, BlockBasicMoon.EnumBlockBasicMoon.MOON_DUNGEON_BRICK)).setHardness(4.0F);
GCBlocks.wallGC = new BlockWallGC("wall_gc");
GCBlocks.concealedRedstone = new BlockConcealedRedstone("concealed_redstone");
GCBlocks.concealedRepeater_Powered = new BlockConcealedRepeater("concealed_repeater_pow", true);
GCBlocks.concealedRepeater_Unpowered = new BlockConcealedRepeater("concealed_repeater", false);
GCBlocks.concealedDetector = new BlockConcealedDetector("concealed_detector");
GCBlocks.platform = new BlockPlatform("platform");
GCBlocks.emergencyBox = new BlockEmergencyBox("emergency_box");
GCBlocks.grating = new BlockGrating("grating");
// Hide certain items from NEI
GCBlocks.hiddenBlocks.add(GCBlocks.airLockSeal);
GCBlocks.hiddenBlocks.add(GCBlocks.oxygenPipePull);
GCBlocks.hiddenBlocks.add(GCBlocks.unlitTorch);
GCBlocks.hiddenBlocks.add(GCBlocks.unlitTorchLit);
GCBlocks.hiddenBlocks.add(GCBlocks.landingPadFull);
GCBlocks.hiddenBlocks.add(GCBlocks.spaceStationBase);
GCBlocks.hiddenBlocks.add(GCBlocks.bossSpawner);
GCBlocks.hiddenBlocks.add(GCBlocks.slabGCDouble);
GCBlocks.hiddenBlocks.add(GCBlocks.concealedRepeater_Powered);
// Register blocks before register ores, so that the ItemStack picks up the correct item
GCBlocks.registerBlocks();
GCBlocks.setHarvestLevels();
// Complete registration of various types of torches
BlockUnlitTorch.register((BlockUnlitTorch) GCBlocks.unlitTorch, (BlockUnlitTorch) GCBlocks.unlitTorchLit, Blocks.torch);
OreDictionary.registerOre("oreCopper", new ItemStack(GCBlocks.basicBlock, 1, 5));
OreDictionary.registerOre("oreCopper", new ItemStack(GCBlocks.blockMoon, 1, 0));
OreDictionary.registerOre("oreTin", new ItemStack(GCBlocks.basicBlock, 1, 6));
OreDictionary.registerOre("oreTin", new ItemStack(GCBlocks.blockMoon, 1, 1));
OreDictionary.registerOre("oreAluminum", new ItemStack(GCBlocks.basicBlock, 1, 7));
OreDictionary.registerOre("oreAluminium", new ItemStack(GCBlocks.basicBlock, 1, 7));
OreDictionary.registerOre("oreNaturalAluminum", new ItemStack(GCBlocks.basicBlock, 1, 7));
OreDictionary.registerOre("oreSilicon", new ItemStack(GCBlocks.basicBlock, 1, 8));
OreDictionary.registerOre("oreCheese", new ItemStack(GCBlocks.blockMoon, 1, 2));
OreDictionary.registerOre("blockCopper", new ItemStack(GCBlocks.basicBlock, 1, 9));
OreDictionary.registerOre("blockTin", new ItemStack(GCBlocks.basicBlock, 1, 10));
OreDictionary.registerOre("blockAluminum", new ItemStack(GCBlocks.basicBlock, 1, 11));
OreDictionary.registerOre("blockAluminium", new ItemStack(GCBlocks.basicBlock, 1, 11));
OreDictionary.registerOre("blockSilicon", new ItemStack(GCBlocks.basicBlock, 1, 13));
OreDictionary.registerOre("turfMoon", new ItemStack(GCBlocks.blockMoon, 1, EnumBlockBasicMoon.MOON_TURF.getMeta()));
}
use of micdoodle8.mods.galacticraft.core.blocks.BlockUnlitTorch in project Galacticraft by micdoodle8.
the class ThreadFindSeal method canBlockPassAirCheck.
private boolean canBlockPassAirCheck(Block block, BlockVec3 vec, int side) {
if (block instanceof IPartialSealableBlock) {
EnumFacing testSide = EnumFacing.getFront(side);
IPartialSealableBlock blockPartial = (IPartialSealableBlock) block;
BlockPos vecPos = new BlockPos(vec.x, vec.y, vec.z);
if (blockPartial.isSealed(this.world, vecPos, testSide)) {
// If a partial block checks as solid, allow it to be tested
// again from other directions
// This won't cause an endless loop, because the block won't
// be included in nextLayer if it checks as solid
this.checkCount--;
return false;
}
// Find the solid sides so they don't get iterated into, when doing the next layer
for (EnumFacing face : EnumFacing.VALUES) {
if (face == testSide) {
continue;
}
if (blockPartial.isSealed(this.world, vecPos, face)) {
vec.setSideDone(face.getIndex() ^ 1);
}
}
checkedAdd(vec);
return true;
}
// (See net.minecraft.block.BlockLeaves.isOpaqueCube()!)
if (block instanceof BlockLeavesBase) {
checkedAdd(vec);
return true;
}
if (block.isOpaqueCube()) {
checkedAdd(vec);
// Gravel, wool and sponge are porous
return block instanceof BlockGravel || block.getMaterial() == Material.cloth || block instanceof BlockSponge;
}
if (block instanceof BlockGlass || block instanceof BlockStainedGlass) {
checkedAdd(vec);
return false;
}
// Solid but non-opaque blocks, for example special glass
if (OxygenPressureProtocol.nonPermeableBlocks.containsKey(block)) {
ArrayList<Integer> metaList = OxygenPressureProtocol.nonPermeableBlocks.get(block);
if (metaList.contains(Integer.valueOf(-1)) || metaList.contains(vec.getBlockMetadata(this.world))) {
checkedAdd(vec);
return false;
}
}
if (block instanceof BlockUnlitTorch) {
this.torchesToUpdate.add(vec);
checkedAdd(vec);
return true;
}
// Half slab seals on the top side or the bottom side according to its metadata
if (block instanceof BlockSlab) {
boolean isTopSlab = (vec.getBlockMetadata(this.world) & 8) == 8;
// Looking down onto a top slab or looking up onto a bottom slab
if (side == 0 && isTopSlab || side == 1 && !isTopSlab) {
// Sealed from that solid side but allow other sides still to be checked
this.checkCount--;
return false;
}
// Not sealed
vec.setSideDone(isTopSlab ? 1 : 0);
checkedAdd(vec);
return true;
}
// Farmland etc only seals on the solid underside
if (block instanceof BlockFarmland || block instanceof BlockEnchantmentTable || block instanceof BlockLiquid) {
if (side == 1) {
// Sealed from the underside but allow other sides still to be checked
this.checkCount--;
return false;
}
// Not sealed
vec.setSideDone(0);
checkedAdd(vec);
return true;
}
if (block instanceof BlockPistonBase) {
BlockPistonBase piston = (BlockPistonBase) block;
IBlockState state = this.world.getBlockState(new BlockPos(vec.x, vec.y, vec.z));
if (((Boolean) state.getValue(BlockPistonBase.EXTENDED)).booleanValue()) {
int facing = ((EnumFacing) state.getValue(BlockPistonBase.FACING)).getIndex();
if (side == facing) {
this.checkCount--;
return false;
}
vec.setSideDone(facing ^ 1);
checkedAdd(vec);
return true;
}
checkedAdd(vec);
return false;
}
// ### Any exceptions in mods should implement the IPartialSealableBlock interface ###
if (block.isSideSolid(this.world, new BlockPos(vec.x, vec.y, vec.z), EnumFacing.getFront(side ^ 1))) {
// Solid on all sides
if (block.getMaterial().blocksMovement() && block.isFullCube()) {
checkedAdd(vec);
return false;
}
// Sealed from this side but allow other sides still to be checked
this.checkCount--;
return false;
}
// Easy case: airblock, return without checking other sides
if (block.getMaterial() == Material.air) {
checkedAdd(vec);
return true;
}
// Look to see if there is any other side which is solid in which case a check will not be needed next time
for (int i = 0; i < 6; i++) {
if (i == (side ^ 1)) {
continue;
}
if (block.isSideSolid(this.world, new BlockPos(vec.x, vec.y, vec.z), EnumFacing.getFront(i))) {
vec.setSideDone(i);
}
}
// Not solid from this side, so this is not sealed
checkedAdd(vec);
return true;
}
use of micdoodle8.mods.galacticraft.core.blocks.BlockUnlitTorch in project Galacticraft by micdoodle8.
the class OxygenUtil method checkTorchHasOxygen.
/*
* A simplified version of the breathable air check which checks
* all 6 sides of the given block (because a torch can pass air on all sides)
* Used in BlockUnlitTorch.
*/
public static boolean checkTorchHasOxygen(World world, BlockPos pos) {
if (OxygenUtil.inOxygenBubble(world, pos.getX() + 0.5D, pos.getY() + 0.6D, pos.getZ() + 0.5D)) {
return true;
}
OxygenUtil.checked = new HashSet<>();
BlockVec3 vec = new BlockVec3(pos);
for (int side = 0; side < 6; side++) {
BlockVec3 sidevec = vec.newVecSide(side);
Block newblock = sidevec.getBlockID_noChunkLoad(world);
if (OxygenUtil.testContactWithBreathableAir(world, newblock, sidevec.toBlockPos(), 1) >= 0) {
return true;
}
}
return false;
}
use of micdoodle8.mods.galacticraft.core.blocks.BlockUnlitTorch in project Galacticraft by micdoodle8.
the class TickHandlerServer method onWorldTick.
@SubscribeEvent
public void onWorldTick(WorldTickEvent event) {
if (event.phase == Phase.START) {
final WorldServer world = (WorldServer) event.world;
CopyOnWriteArrayList<ScheduledBlockChange> changeList = TickHandlerServer.scheduledBlockChanges.get(GCCoreUtil.getDimensionID(world));
if (changeList != null && !changeList.isEmpty()) {
int blockCount = 0;
int blockCountMax = Math.max(this.MAX_BLOCKS_PER_TICK, changeList.size() / 4);
List<ScheduledBlockChange> newList = new ArrayList<ScheduledBlockChange>(Math.max(0, changeList.size() - blockCountMax));
for (ScheduledBlockChange change : changeList) {
if (++blockCount > blockCountMax) {
newList.add(change);
} else {
if (change != null) {
BlockPos changePosition = change.getChangePosition();
Block block = world.getBlockState(changePosition).getBlock();
// Only replace blocks of type BlockAir or fire - this is to prevent accidents where other mods have moved blocks
if (changePosition != null && (block instanceof BlockAir || block == Blocks.fire)) {
world.setBlockState(changePosition, change.getChangeID().getStateFromMeta(change.getChangeMeta()), change.getChangeUpdateFlag());
}
}
}
}
changeList.clear();
TickHandlerServer.scheduledBlockChanges.remove(GCCoreUtil.getDimensionID(world));
if (newList.size() > 0) {
TickHandlerServer.scheduledBlockChanges.put(GCCoreUtil.getDimensionID(world), new CopyOnWriteArrayList<ScheduledBlockChange>(newList));
}
}
CopyOnWriteArrayList<BlockVec3> torchList = TickHandlerServer.scheduledTorchUpdates.get(GCCoreUtil.getDimensionID(world));
if (torchList != null && !torchList.isEmpty()) {
for (BlockVec3 torch : torchList) {
if (torch != null) {
BlockPos pos = new BlockPos(torch.x, torch.y, torch.z);
Block b = world.getBlockState(pos).getBlock();
if (b instanceof BlockUnlitTorch) {
world.scheduleUpdate(pos, b, 2 + world.rand.nextInt(30));
}
}
}
torchList.clear();
TickHandlerServer.scheduledTorchUpdates.remove(GCCoreUtil.getDimensionID(world));
}
if (world.provider instanceof IOrbitDimension) {
try {
int dim = GCCoreUtil.getDimensionID(WorldUtil.getProviderForNameServer(((IOrbitDimension) world.provider).getPlanetToOrbit()));
int minY = ((IOrbitDimension) world.provider).getYCoordToTeleportToPlanet();
final Entity[] entityList = world.loadedEntityList.toArray(new Entity[world.loadedEntityList.size()]);
for (final Entity e : entityList) {
if (e.posY <= minY && e.worldObj == world) {
WorldUtil.transferEntityToDimension(e, dim, world, false, null);
}
}
} catch (Exception ex) {
}
}
int dimensionID = GCCoreUtil.getDimensionID(world);
if (worldsNeedingUpdate.contains(dimensionID)) {
worldsNeedingUpdate.remove(dimensionID);
for (Object obj : event.world.loadedTileEntityList) {
TileEntity tile = (TileEntity) obj;
if (tile instanceof TileEntityFluidTank) {
((TileEntityFluidTank) tile).updateClient = true;
}
}
}
} else if (event.phase == Phase.END) {
final WorldServer world = (WorldServer) event.world;
for (GalacticraftPacketHandler handler : packetHandlers) {
handler.tick(world);
}
int dimID = GCCoreUtil.getDimensionID(world);
Set<BlockPos> edgesList = TickHandlerServer.edgeChecks.get(dimID);
final HashSet<BlockPos> checkedThisTick = new HashSet<>();
if (edgesList != null && !edgesList.isEmpty()) {
List<BlockPos> edgesListCopy = new ArrayList<>();
edgesListCopy.addAll(edgesList);
for (BlockPos edgeBlock : edgesListCopy) {
if (edgeBlock != null && !checkedThisTick.contains(edgeBlock)) {
if (TickHandlerServer.scheduledForChange(dimID, edgeBlock)) {
continue;
}
ThreadFindSeal done = new ThreadFindSeal(world, edgeBlock, 0, new ArrayList<TileEntityOxygenSealer>());
checkedThisTick.addAll(done.checkedAll());
}
}
TickHandlerServer.edgeChecks.remove(GCCoreUtil.getDimensionID(world));
}
}
}
use of micdoodle8.mods.galacticraft.core.blocks.BlockUnlitTorch in project Galacticraft by micdoodle8.
the class GCBlocks method doOtherModsTorches.
public static void doOtherModsTorches() {
BlockUnlitTorch torch;
BlockUnlitTorch torchLit;
if (CompatibilityManager.isTConstructLoaded) {
Block modTorch = null;
try {
// tconstruct.world.TinkerWorld.stoneTorch
Class clazz = Class.forName("slimeknights.tconstruct.gadgets.TinkerGadgets");
modTorch = (Block) clazz.getDeclaredField("stoneTorch").get(null);
} catch (Exception e) {
e.printStackTrace();
}
if (modTorch != null) {
torch = new BlockUnlitTorch(false, "unlit_torch_stone");
torchLit = new BlockUnlitTorch(true, "unlit_torch_stone_lit");
GCBlocks.hiddenBlocks.add(torch);
GCBlocks.hiddenBlocks.add(torchLit);
GCBlocks.otherModTorchesUnlit.add(torch);
GCBlocks.otherModTorchesLit.add(torchLit);
registerBlock(torch, ItemBlockGC.class);
registerBlock(torchLit, ItemBlockGC.class);
BlockUnlitTorch.register(torch, torchLit, modTorch);
GCLog.info("Galacticraft: activating Tinker's Construct compatibility.");
}
}
}
Aggregations