generated from neoforged/MDK
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor and add different color variants
1 parent
5bfe4b5
commit 6a3ab2e
Showing
6 changed files
with
64 additions
and
60 deletions.
There are no files selected for viewing
9 changes: 3 additions & 6 deletions
9
.../leclowndu93150/invertedbed/IBEvents.java → ...wndu93150/invertedbed/IBClientEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 12 additions & 15 deletions
27
...owndu93150/invertedbed/SleepingLogic.java → ...wndu93150/invertedbed/IBServerEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,41 @@ | ||
package com.leclowndu93150.invertedbed; | ||
|
||
import net.minecraft.client.multiplayer.ClientLevel; | ||
import com.leclowndu93150.invertedbed.block.InvertedBedBlock; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.level.LevelAccessor; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.neoforged.bus.api.Event; | ||
import net.neoforged.bus.api.SubscribeEvent; | ||
import net.neoforged.fml.common.Mod; | ||
import net.neoforged.neoforge.event.entity.player.PlayerWakeUpEvent; | ||
import net.neoforged.neoforge.event.entity.player.SleepingLocationCheckEvent; | ||
import net.neoforged.neoforge.event.entity.player.SleepingTimeCheckEvent; | ||
import net.neoforged.neoforge.event.level.SleepFinishedTimeEvent; | ||
|
||
import static com.leclowndu93150.invertedbed.Main.INVERTED_BED; | ||
import static com.leclowndu93150.invertedbed.Main.MODID; | ||
|
||
@Mod.EventBusSubscriber(modid = MODID) | ||
public class SleepingLogic { | ||
public class IBServerEvents { | ||
@SubscribeEvent | ||
public static void onTrySleep(PlayerWakeUpEvent event) { | ||
if (!event.getEntity().level().isClientSide){ | ||
((ServerLevel) event.getEntity().level()).setDayTime(13000); | ||
if (!event.getEntity().level().isClientSide()) { | ||
ServerLevel level = ((ServerLevel) event.getEntity().level()); | ||
BlockState blockState = event.getEntity().level().getBlockState(event.getEntity().getSleepingPos().get()); | ||
if (blockState.getBlock() instanceof InvertedBedBlock) | ||
level.setDayTime(13000); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public static void onCheckTime(SleepingTimeCheckEvent event) { | ||
if (event.getEntity().level().getBlockState(event.getSleepingLocation().get()).is(INVERTED_BED)) { | ||
BlockState blockState = event.getEntity().level().getBlockState(event.getSleepingLocation().get()); | ||
if (blockState.getBlock() instanceof InvertedBedBlock) | ||
event.setResult(event.getEntity().level().isDay() ? Event.Result.ALLOW : Event.Result.DENY); | ||
} | ||
System.out.println("checking time: " + event.getSleepingLocation()); | ||
} | ||
|
||
@SubscribeEvent | ||
public static void onBedCheck(SleepingLocationCheckEvent event) { | ||
if (event.getEntity().level().getBlockState(event.getSleepingLocation()).getBlock().equals(INVERTED_BED)) { | ||
BlockState blockState = event.getEntity().level().getBlockState(event.getSleepingLocation()); | ||
if (blockState.getBlock() instanceof InvertedBedBlock) | ||
event.setResult(Event.Result.ALLOW); | ||
} | ||
System.out.println("checking location: " + event.getSleepingLocation()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 1 addition & 8 deletions
9
...du93150/invertedbed/InvertedBedBlock.java → ...0/invertedbed/block/InvertedBedBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 4 additions & 9 deletions
13
...0/invertedbed/InvertedBedBlockEntity.java → ...rtedbed/block/InvertedBedBlockEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters