Skip to content

Commit

Permalink
Set IS_RUNNING_IN_IDE to true in userdev (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt authored Jan 21, 2024
1 parent 932773f commit 0c97f37
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 5 deletions.
10 changes: 10 additions & 0 deletions patches/net/minecraft/SharedConstants.java.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
--- a/net/minecraft/SharedConstants.java
+++ b/net/minecraft/SharedConstants.java
@@ -122,7 +_,8 @@
public static final long MAXIMUM_TICK_TIME_NANOS = Duration.ofMillis(300L).toNanos();
public static final boolean USE_WORKFLOWS_HOOKS = false;
public static boolean CHECK_DATA_FIXER_SCHEMA = true;
- public static boolean IS_RUNNING_IN_IDE;
+ public static boolean IS_RUNNING_IN_IDE = !net.neoforged.fml.loading.FMLLoader.isProduction();
+ public static final boolean IS_RUNNING_WITH_JDWP = java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments().stream().anyMatch(str -> str.startsWith("-agentlib:jdwp"));
public static Set<TypeReference> DATA_FIX_TYPES_TO_OPTIMIZE = Set.of();
public static final int WORLD_RESOLUTION = 16;
public static final int MAX_CHAT_LENGTH = 256;
@@ -204,6 +_,7 @@
}

Expand Down
30 changes: 28 additions & 2 deletions patches/net/minecraft/Util.java.patch
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
--- a/net/minecraft/Util.java
+++ b/net/minecraft/Util.java
@@ -261,7 +_,7 @@
@@ -261,8 +_,8 @@
.getSchema(DataFixUtils.makeKey(SharedConstants.getCurrentVersion().getDataVersion().getVersion()))
.getChoiceType(p_137552_, p_137553_);
} catch (IllegalArgumentException illegalargumentexception) {
- LOGGER.error("No data fixer registered for {}", p_137553_);
- if (SharedConstants.IS_RUNNING_IN_IDE) {
+ LOGGER.debug("No data fixer registered for {}", p_137553_);
if (SharedConstants.IS_RUNNING_IN_IDE) {
+ if (SharedConstants.IS_RUNNING_IN_IDE && false) {
throw illegalargumentexception;
}
}
@@ -438,20 +_,20 @@

public static void logAndPauseIfInIde(String p_143786_) {
LOGGER.error(p_143786_);
- if (SharedConstants.IS_RUNNING_IN_IDE) {
+ if (SharedConstants.IS_RUNNING_WITH_JDWP) {
doPause(p_143786_);
}
}

public static void logAndPauseIfInIde(String p_200891_, Throwable p_200892_) {
LOGGER.error(p_200891_, p_200892_);
- if (SharedConstants.IS_RUNNING_IN_IDE) {
+ if (SharedConstants.IS_RUNNING_WITH_JDWP) {
doPause(p_200891_);
}
}

public static <T extends Throwable> T pauseInIde(T p_137571_) {
- if (SharedConstants.IS_RUNNING_IN_IDE) {
+ if (SharedConstants.IS_RUNNING_WITH_JDWP) {
LOGGER.error("Trying to throw a fatal exception, pausing in IDE", p_137571_);
doPause(p_137571_.getMessage());
}
11 changes: 11 additions & 0 deletions patches/net/minecraft/client/GameNarrator.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/net/minecraft/client/GameNarrator.java
+++ b/net/minecraft/client/GameNarrator.java
@@ -59,7 +_,7 @@
}

private void logNarratedMessage(String p_168788_) {
- if (SharedConstants.IS_RUNNING_IN_IDE) {
+ if (SharedConstants.IS_RUNNING_IN_IDE && false) {
LOGGER.debug("Narrating: {}", p_168788_.replaceAll("\n", "\\\\n"));
}
}
3 changes: 2 additions & 1 deletion patches/net/minecraft/client/Minecraft.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@
this.setOverlay(
- new LoadingOverlay(
- this, reloadinstance, p_299779_ -> Util.ifElse(p_299779_, p_299772_ -> this.rollbackResourcePacks(p_299772_, minecraft$gameloadcookie), () -> {
- if (SharedConstants.IS_RUNNING_IN_IDE) {
+ net.neoforged.fml.loading.ImmediateWindowHandler.<LoadingOverlay>loadingOverlay(
+ () -> this, () -> reloadinstance, p_299779_ -> Util.ifElse(p_299779_, p_299772_ -> this.rollbackResourcePacks(p_299772_, minecraft$gameloadcookie), () -> {
if (SharedConstants.IS_RUNNING_IN_IDE) {
+ if (SharedConstants.IS_RUNNING_IN_IDE && false) {
this.selfTest();
}

Expand Down
9 changes: 8 additions & 1 deletion patches/net/minecraft/world/item/Item.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@
protected static final UUID BASE_ATTACK_DAMAGE_UUID = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF");
protected static final UUID BASE_ATTACK_SPEED_UUID = UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3");
public static final int MAX_STACK_SIZE = 64;
@@ -98,6 +_,8 @@
@@ -92,12 +_,14 @@
this.foodProperties = p_41383_.foodProperties;
this.isFireResistant = p_41383_.isFireResistant;
this.requiredFeatures = p_41383_.requiredFeatures;
- if (SharedConstants.IS_RUNNING_IN_IDE) {
+ if (SharedConstants.IS_RUNNING_IN_IDE && false) {
String s = this.getClass().getSimpleName();
if (!s.endsWith("Item")) {
LOGGER.error("Item classes should end with Item and {} doesn't.", s);
}
}
Expand Down
9 changes: 8 additions & 1 deletion patches/net/minecraft/world/level/block/Block.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
private static final LoadingCache<VoxelShape, Boolean> SHAPE_FULL_BLOCK_CACHE = CacheBuilder.newBuilder()
.maximumSize(512L)
.weakKeys()
@@ -193,6 +_,7 @@
@@ -187,12 +_,13 @@
this.createBlockStateDefinition(builder);
this.stateDefinition = builder.create(Block::defaultBlockState, BlockState::new);
this.registerDefaultState(this.stateDefinition.any());
- if (SharedConstants.IS_RUNNING_IN_IDE) {
+ if (SharedConstants.IS_RUNNING_IN_IDE && false) {
String s = this.getClass().getSimpleName();
if (!s.endsWith("Block")) {
LOGGER.error("Block classes should end with Block and {} doesn't.", s);
}
}
Expand Down

0 comments on commit 0c97f37

Please sign in to comment.