Java Code Examples for net.minecraft.item.Items#CLOCK
The following examples show how to use
net.minecraft.item.Items#CLOCK .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemFrameEntity_comparatorReadsClockMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 5 votes |
@Inject(method = "getComparatorPower", at = @At("HEAD"),cancellable = true) private void giveClockPower(CallbackInfoReturnable<Integer> cir) { if(CarpetExtraSettings.comparatorReadsClock && this.getHeldItemStack().getItem() == Items.CLOCK) { int power; //Every 1500 ticks, increase signal strength by one power = (int)(this.world.getTimeOfDay() % 24000) / 1500; //in case negative time of day every happens, make comparator output the according positive value if(power < 0) power = power + 16; cir.setReturnValue(power); cir.cancel(); } }
Example 2
Source File: ItemFrameEntity_comparatorReadsClockMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 5 votes |
public void tick() { if(CarpetExtraSettings.comparatorReadsClock && this.getHeldItemStack().getItem() == Items.CLOCK) { //This doesn't handle time set commands yet //Every 1500 ticks, increase signal strength by one, so update comparators exactly then if(this.world.getTimeOfDay() % 1500 == 0 || firstTick) { firstTick = false; if(this.attachmentPos != null) { this.world.updateHorizontalAdjacent(this.attachmentPos, Blocks.AIR); } } } super.tick(); }