Skip to content

Commit

Permalink
ported to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
Thepigcat76 committed Jun 13, 2024
1 parent 8e279ac commit 80efeca
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
10 changes: 9 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.0.105'
id 'net.neoforged.gradle.userdev' version '7.0.142'
}

version = mod_version
group = mod_group_id

repositories {
mavenLocal()
maven {
name 'Maven for PR #1076' // https://github.com/neoforged/NeoForge/pull/1076
url 'https://prmaven.neoforged.net/NeoForge/pr1076'
content {
includeModule('net.neoforged', 'testframework')
includeModule('net.neoforged', 'neoforge')
}
}
}

base {
Expand Down
13 changes: 7 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.debug=false

neogradle.subsystems.parchment.minecraftVersion=1.20.4
neogradle.subsystems.parchment.mappingsVersion=2024.04.14
neogradle.subsystems.parchment.minecraftVersion=1.20.6
neogradle.subsystems.parchment.mappingsVersion=2024.06.02

# Environment Properties
minecraft_version=1.20.6
minecraft_version_range=[1.20.6,1.21)
neo_version=20.6.18-beta
neo_version_range=[20.4,)
minecraft_version=1.21-rc1
minecraft_version_range=[1.21-rc1,1.22)
neo_version=21.0.0-alpha.1.21-rc1.20240612.183440
neo_version_range=[21.0.0-alpha.1.21-rc1.20240612.183440,)
loader_version_range=[2,)

## Mod Properties
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-rc-1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
28 changes: 17 additions & 11 deletions src/main/java/com/portingdeadmods/invertedbed/IBServerEvents.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.portingdeadmods.invertedbed;

import com.portingdeadmods.invertedbed.block.InvertedBedBlock;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
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.EventBusSubscriber;
import net.neoforged.neoforge.event.entity.player.CanContinueSleepingEvent;
import net.neoforged.neoforge.event.entity.player.CanPlayerSleepEvent;
import net.neoforged.neoforge.event.entity.player.PlayerWakeUpEvent;
import net.neoforged.neoforge.event.entity.player.SleepingLocationCheckEvent;
import net.neoforged.neoforge.event.entity.player.SleepingTimeCheckEvent;

@EventBusSubscriber(modid = Main.MODID)
public class IBServerEvents {
Expand All @@ -24,17 +24,23 @@ public static void onTrySleep(PlayerWakeUpEvent event) {
}

@SubscribeEvent
public static void onCheckTime(SleepingTimeCheckEvent event) {
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);
public static void canStartSleep(CanPlayerSleepEvent event) {
BlockState blockState = event.getEntity().level().getBlockState(event.getPos());
if (blockState.getBlock() instanceof InvertedBedBlock) {
event.setProblem(event.getEntity().level().isDay()
&& (event.getVanillaProblem() == null
|| event.getVanillaProblem() == Player.BedSleepingProblem.NOT_POSSIBLE_NOW)
? null
: Player.BedSleepingProblem.NOT_POSSIBLE_NOW);
}
}

@SubscribeEvent
public static void onBedCheck(SleepingLocationCheckEvent event) {
BlockState blockState = event.getEntity().level().getBlockState(event.getSleepingLocation());
public static void canContinueSleep(CanContinueSleepingEvent event) {
Level level = event.getEntity().level();
BlockState blockState = level.getBlockState(event.getEntity().getSleepingPos().get());
if (blockState.getBlock() instanceof InvertedBedBlock)
event.setResult(Event.Result.ALLOW);
event.setContinueSleeping(level.isDay());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
public class InvertedBedRenderer implements BlockEntityRenderer<InvertedBedBlockEntity> {
private final ModelPart headRoot;
private final ModelPart footRoot;
public static final ModelLayerLocation BED_HEAD = new ModelLayerLocation(new ResourceLocation(Main.MODID, "bed_head"), "main");
public static final ModelLayerLocation BED_FOOT = new ModelLayerLocation(new ResourceLocation(Main.MODID, "bed_foot"), "main");
public static final ModelLayerLocation BED_HEAD = new ModelLayerLocation(ResourceLocation.fromNamespaceAndPath(Main.MODID, "bed_head"), "main");
public static final ModelLayerLocation BED_FOOT = new ModelLayerLocation(ResourceLocation.fromNamespaceAndPath(Main.MODID, "bed_foot"), "main");

public InvertedBedRenderer(BlockEntityRendererProvider.Context pContext) {
this.headRoot = pContext.bakeLayer(BED_HEAD);
Expand Down

0 comments on commit 80efeca

Please sign in to comment.