Jetfan16ladd Posted May 4, 2014 Share Posted May 4, 2014 Is there any way to make a block the only emits light at night and does not emit light during the day? please post ideas on how this can be done Quote Link to comment Share on other sites More sharing options...
brandon3055 Posted May 4, 2014 Share Posted May 4, 2014 I still have a lot to learn so i am sure there is an easier way but with what i know now this is how i would do it. create two identical blocks one that emits light and one that dosn't. in the randomDisplayTick() use world.getWorldTime(); in the block that dosnt emmit light if it is night use world.setBlock("light emitting version") in the block that dose emit light if it is day use world.setBlock("non light emitting version") This should work but im sure there is a better way out there Note to get the "actual time" use double days = world.getWorldTime() / 24000; int time = (int)(world.getWorldTime() - days * 24000); Quote I am the author of Draconic Evolution Link to comment Share on other sites More sharing options...
brandon3055 Posted May 4, 2014 Share Posted May 4, 2014 @diesieben07 i would have tryed that after my first attempt failed Quote I am the author of Draconic Evolution Link to comment Share on other sites More sharing options...
Jetfan16ladd Posted May 4, 2014 Author Share Posted May 4, 2014 randomDisplayTick is client-side only. You will need a TileEntity for proper ticking or constantly schedule Block updates. im a noob so how can I do the TileEntity thingy or block updates Quote Link to comment Share on other sites More sharing options...
kc9zda Posted May 5, 2014 Share Posted May 5, 2014 This example may work on 1.7.2, but I know it works on 1.6.2. If you do not know how to use tile entities, please see the tutorial on the wiki. Now, on your updateEntity method, you should have something similar to: public void updateEntity() { boolean isDay = this.worldObj.isDaytime(); if (isDay && this.worldObj.getBlockId(this.posX, this.posY, this.posZ) == ModBlocks.litBlock.blockId) { this.worldObj.setBlock(this.posX, this.posY, this.posZ, ModBlocks.darkBlock.blockId); } else { if (!isDay && this.worldObj.getBlockId(this.posX, this.posY, this.posZ) == ModBlocks.darkBlock.blockId) { this.worldObj.setBlock(this.posX, this.posY, this.posZ, ModBlocks.litBlock.blockId); } } } This is a start, but there may be some unwanted happenings once the block changes, because Minecraft probably won't like the block changing, but not the tile entity. I also didn't include the server-client syncing code (to sync with the server). Quote Link to comment Share on other sites More sharing options...
supercat765 Posted November 15, 2014 Share Posted November 15, 2014 I have tried EVERYTHING and I cant get my block to emit during the day and be off at night Quote Link to comment Share on other sites More sharing options...
shieldbug1 Posted November 15, 2014 Share Posted November 15, 2014 Override Block#getLightValue and safely cast the block access to World. Then you can try using World#isDaytime to return a different light value. If that doesn't work, try World#getWorldTime - it has a value between 0 and 23,999 in ticks. Quote BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials. Link to comment Share on other sites More sharing options...
TheGreyGhost Posted November 15, 2014 Share Posted November 15, 2014 Hi You might gain some useful ideas (in addition to the ones above) by looking how BlockRedstoneLight works. There are two instances of it; Blocks.lit_redstone_lamp and Blocks.redstone_lamp It switches between them based on whether it is getting redstone power or not. If you look at BlockDaylightDetector, it shows you how you might tell whether it's daylight or not. -TGG Quote Link to comment Share on other sites More sharing options...
Draco18s Posted November 15, 2014 Share Posted November 15, 2014 There's actually no reason to switch block IDs, you can do it with metadata. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.