This commit is contained in:
gnembon committed 2020-04-22 17:00:31 -03:00
1 parent d749bbe3ff
commit f2e9a9de91
16 files changed
+75 -58

No files matched your search

+2 -2
View File
@@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
# or better: https://modmuss50.me/fabric.html
minecraft_version=20w16a
yarn_mappings=20w16a+build.9
minecraft_version=20w17a
yarn_mappings=20w17a+build.1
loader_version=0.8.2+build.194
# Mod Properties
@@ -1,8 +1,11 @@
package carpet.fakes;
import net.minecraft.world.level.storage.LevelStorage;
import java.util.function.BooleanSupplier;
public interface MinecraftServerInterface
{
void forceTick(BooleanSupplier sup);
LevelStorage.Session getCMSession();
}
@@ -21,7 +21,6 @@ import net.minecraft.world.gen.chunk.OverworldChunkGeneratorConfig;
import net.minecraft.world.gen.decorator.BeehiveTreeDecorator;
import net.minecraft.world.gen.feature.BastionRemnantFeatureConfig;
import net.minecraft.world.gen.feature.BoulderFeatureConfig;
import net.minecraft.world.gen.feature.BranchedTreeFeatureConfig;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
import net.minecraft.world.gen.feature.Feature;
@@ -38,9 +37,7 @@ import net.minecraft.world.gen.feature.ShipwreckFeatureConfig;
import net.minecraft.world.gen.feature.SingleStateFeatureConfig;
import net.minecraft.world.gen.feature.StructureFeature;
import net.minecraft.world.gen.feature.StructurePoolFeatureConfig;
import net.minecraft.world.gen.foliage.BlobFoliagePlacer;
import net.minecraft.world.gen.stateprovider.SimpleBlockStateProvider;
import net.minecraft.world.gen.trunk.StraightTrunkPlacer;
import net.minecraft.world.gen.feature.TreeFeatureConfig;
import java.util.Arrays;
import java.util.Collections;
@@ -50,6 +47,9 @@ import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import static net.minecraft.world.biome.DefaultBiomeFeatures.FANCY_TREE_CONFIG;
import static net.minecraft.world.biome.DefaultBiomeFeatures.OAK_TREE_CONFIG;
public class FeatureGenerator
{
@FunctionalInterface
@@ -76,9 +76,9 @@ public class FeatureGenerator
return simplePlop(feature.configure(FeatureConfig.DEFAULT));
}
private static Thing simpleTree(BranchedTreeFeatureConfig config)
private static Thing simpleTree(TreeFeatureConfig config)
{
return simplePlop(Feature.NORMAL_TREE.configure(config));
return simplePlop(Feature.TREE.configure(config));
}
private static Thing simplePatch(RandomPatchFeatureConfig config)
@@ -224,35 +224,24 @@ public class FeatureGenerator
private static final Map<String, Thing> featureMap = new HashMap<String, Thing>() {{
put("oak", simpleTree(DefaultBiomeFeatures.OAK_TREE_CONFIG));
put("oak", simpleTree(OAK_TREE_CONFIG));
put("oak_beehive", simpleTree(
(new BranchedTreeFeatureConfig.Builder(
new SimpleBlockStateProvider(Blocks.OAK_LOG.getDefaultState()),
new SimpleBlockStateProvider(Blocks.OAK_LEAVES.getDefaultState()),
new BlobFoliagePlacer(2, 0, 0, 0, 3),
new StraightTrunkPlacer(4, 2, 0))
).noVines().treeDecorators(ImmutableList.of(new BeehiveTreeDecorator(1.0F))).build()
));
put("oak_large", simplePlop(Feature.FANCY_TREE.configure(DefaultBiomeFeatures.FANCY_TREE_CONFIG)));
put("oak_large_beehive", simplePlop(Feature.FANCY_TREE.configure(
(new BranchedTreeFeatureConfig.Builder(
new SimpleBlockStateProvider(Blocks.OAK_LOG.getDefaultState()),
new SimpleBlockStateProvider(Blocks.OAK_LEAVES.getDefaultState()),
new BlobFoliagePlacer(0, 0, 0, 0, 0),
new StraightTrunkPlacer(0, 0, 0))
).treeDecorators(ImmutableList.of(new BeehiveTreeDecorator(1.0F))).build()
(OAK_TREE_CONFIG.method_27373((ImmutableList.of(new BeehiveTreeDecorator(1.0F))))
)));
put("oak_large", simplePlop(Feature.TREE.configure(DefaultBiomeFeatures.FANCY_TREE_CONFIG)));
put("oak_large_beehive", simplePlop(
Feature.TREE.configure(FANCY_TREE_CONFIG.method_27373(ImmutableList.of(new BeehiveTreeDecorator(1.0F))))));
put("birch", simpleTree(DefaultBiomeFeatures.BIRCH_TREE_CONFIG));
put("birch_large", simpleTree(DefaultBiomeFeatures.LARGE_BIRCH_TREE_CONFIG));
put("shrub", simplePlop(Feature.JUNGLE_GROUND_BUSH.configure(DefaultBiomeFeatures.JUNGLE_GROUND_BUSH_CONFIG)));
put("shrub", simplePlop(Feature.TREE.configure(DefaultBiomeFeatures.JUNGLE_GROUND_BUSH_CONFIG)));
put("jungle", simpleTree(DefaultBiomeFeatures.JUNGLE_TREE_CONFIG));
put("jungle_large", simplePlop(Feature.MEGA_JUNGLE_TREE.configure(DefaultBiomeFeatures.MEGA_JUNGLE_TREE_CONFIG)));
put("jungle_large", simplePlop(Feature.TREE.configure(DefaultBiomeFeatures.MEGA_JUNGLE_TREE_CONFIG)));
put("spruce", simpleTree(DefaultBiomeFeatures.SPRUCE_TREE_CONFIG));
put("spruce_large", simplePlop(Feature.MEGA_SPRUCE_TREE.configure(DefaultBiomeFeatures.MEGA_SPRUCE_TREE_CONFIG)));
put("spruce_large", simplePlop(Feature.TREE.configure(DefaultBiomeFeatures.MEGA_SPRUCE_TREE_CONFIG)));
put("pine", simpleTree(DefaultBiomeFeatures.PINE_TREE_CONFIG));
put("pine_large", simplePlop(Feature.MEGA_SPRUCE_TREE.configure(DefaultBiomeFeatures.MEGA_PINE_TREE_CONFIG)));
put("dark_oak", simplePlop(Feature.DARK_OAK_TREE.configure(DefaultBiomeFeatures.DARK_OAK_TREE_CONFIG)));
put("acacia", simplePlop(Feature.NORMAL_TREE.configure(DefaultBiomeFeatures.ACACIA_TREE_CONFIG)));
put("pine_large", simplePlop(Feature.TREE.configure(DefaultBiomeFeatures.MEGA_PINE_TREE_CONFIG)));
put("dark_oak", simplePlop(Feature.TREE.configure(DefaultBiomeFeatures.DARK_OAK_TREE_CONFIG)));
put("acacia", simplePlop(Feature.TREE.configure(DefaultBiomeFeatures.ACACIA_TREE_CONFIG)));
put("oak_swamp", simpleTree(DefaultBiomeFeatures.SWAMP_TREE_CONFIG));
put("well", simplePlop(Feature.DESERT_WELL));
put("grass", simplePatch(DefaultBiomeFeatures.GRASS_CONFIG));
@@ -7,12 +7,17 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(IntegratedServer.class)
public class IntegratedServerMixin
{
@Inject(method = "loadWorld", at = @At("HEAD"))
private void onSetupServerIntegrated(String string, long l, LevelGeneratorOptions levelGeneratorOptions, CallbackInfo ci) {
@Inject(method = "setupServer", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/integrated/IntegratedServer;loadWorld()V",
shift = At.Shift.BEFORE
))
private void onSetupServerIntegrated(CallbackInfoReturnable<Boolean> cir) {
CarpetServer.onServerLoaded((IntegratedServer) (Object) this);
}
}
@@ -14,7 +14,7 @@ public class MinecraftDedicatedServerMixin
// this.tickWorlds(booleanSupplier_1);
@Inject(method = "setupServer", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/dedicated/MinecraftDedicatedServer;loadWorld(Ljava/lang/String;JLnet/minecraft/world/level/LevelGeneratorOptions;)V",
target = "Lnet/minecraft/server/dedicated/MinecraftDedicatedServer;loadWorld()V",
shift = At.Shift.BEFORE
))
private void onSetupServer(CallbackInfoReturnable<Boolean> cir) {
@@ -33,7 +33,7 @@ public abstract class MinecraftServer_coreMixin
// Dedicated server only
@Inject(method = "loadWorld", at = @At("HEAD"))
private void serverLoaded(String string, long l, LevelGeneratorOptions levelGeneratorOptions, CallbackInfo ci)
private void serverLoaded(CallbackInfo ci)
{
CarpetServer.onServerLoaded((MinecraftServer) (Object) this);
}
@@ -6,6 +6,8 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerTask;
import net.minecraft.util.Util;
import net.minecraft.util.thread.ReentrantThreadExecutor;
import net.minecraft.world.level.storage.LevelStorage;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -34,6 +36,8 @@ public abstract class MinecraftServer_scarpetMixin extends ReentrantThreadExecut
@Shadow public abstract boolean runTask();
@Shadow @Final protected LevelStorage.Session session;
@Override
public void forceTick(BooleanSupplier isAhead)
{
@@ -42,6 +46,12 @@ public abstract class MinecraftServer_scarpetMixin extends ReentrantThreadExecut
runTask();
}
@Override
public LevelStorage.Session getCMSession()
{
return session;
}
@Inject(method = "tick", at = @At(
value = "CONSTANT",
args = "stringValue=tallying"
@@ -52,4 +62,6 @@ public abstract class MinecraftServer_scarpetMixin extends ReentrantThreadExecut
NETHER_TICK.onTick();
ENDER_TICK.onTick();
}
}
@@ -3,6 +3,7 @@ package carpet.mixins;
import carpet.fakes.ServerChunkManagerInterface;
import carpet.utils.SpawnReporter;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.class_5217;
import net.minecraft.entity.EntityCategory;
import net.minecraft.server.world.ChunkTicketManager;
import net.minecraft.server.world.ServerChunkManager;
@@ -54,7 +55,7 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
private void grabMobcaps(CallbackInfo ci,
long long_1,
long long_2,
LevelProperties levelProperties_1,
class_5217 levelProperties_1,
boolean boolean_1,
boolean boolean_2,
int int_1,
@@ -146,7 +147,7 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
@Inject(method = "tickChunks", at = @At("RETURN"))
private void onFinishSpawnWorldCycle(CallbackInfo ci)
{
LevelProperties levelProperties_1 = this.world.getLevelProperties();
class_5217 levelProperties_1 = this.world.getLevelProperties(); // levelProperies class
boolean boolean_3 = levelProperties_1.getTime() % 400L == 0L;
if (SpawnReporter.track_spawns > 0L && SpawnReporter.local_spawns != null)
{
@@ -2,6 +2,7 @@ package carpet.mixins;
import carpet.helpers.TickSpeed;
import carpet.utils.CarpetProfiler;
import net.minecraft.class_5217;
import net.minecraft.server.world.ServerChunkManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.level.LevelGeneratorType;
@@ -93,9 +94,10 @@ public abstract class ServerChunkManager_tickMixin
//// Tick freeze
@Redirect(method = "tickChunks", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/LevelProperties;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
//target = "Lnet/minecraft/world/level/LevelProperties;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
target = "Lnet/minecraft/class_5217;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
))
private LevelGeneratorType skipChunkTicking(LevelProperties levelProperties)
private LevelGeneratorType skipChunkTicking(class_5217 levelProperties)
{
if (!TickSpeed.process_entities) return LevelGeneratorType.DEBUG_ALL_BLOCK_STATES;
return levelProperties.getGeneratorType();
@@ -2,6 +2,7 @@ package carpet.mixins;
import carpet.helpers.TickSpeed;
import carpet.utils.CarpetProfiler;
import net.minecraft.class_5217;
import net.minecraft.entity.raid.RaidManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.profiler.Profiler;
@@ -152,9 +153,10 @@ public abstract class ServerWorld_tickMixin extends World
@Redirect(method = "tick", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/LevelProperties;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
target = "Lnet/minecraft/class_5217;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
//target = "Lnet/minecraft/world/level/LevelProperties;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
))
private LevelGeneratorType tickPendingBlocks(LevelProperties levelProperties)
private LevelGeneratorType tickPendingBlocks(class_5217 levelProperties)
{
if (TickSpeed.process_entities) return levelProperties.getGeneratorType();
return LevelGeneratorType.DEBUG_ALL_BLOCK_STATES;
@@ -6,6 +6,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.class_5217;
import net.minecraft.server.world.ChunkHolder;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.profiler.Profiler;
@@ -28,7 +29,7 @@ public abstract class World_movableTEMixin implements WorldInterface
public boolean isClient;
@Shadow
@Final
protected LevelProperties properties;
protected class_5217 properties; //LevelProperties
@Shadow
public abstract WorldChunk getWorldChunk(BlockPos blockPos_1);
@@ -15,6 +15,7 @@ import carpet.utils.Messenger;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.tree.CommandNode;
import net.minecraft.class_5218;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.util.math.BlockPos;
@@ -75,7 +76,7 @@ public class CarpetScriptServer
public Module getModule(String name, boolean allowLibraries)
{
File folder = CarpetServer.minecraft_server.method_27050().resolve("scripts").toFile();
File folder = CarpetServer.minecraft_server.method_27050(class_5218.field_24188).resolve("scripts").toFile();
File[] listOfFiles = folder.listFiles();
if (listOfFiles != null)
for (File script : listOfFiles)
@@ -109,7 +110,7 @@ public class CarpetScriptServer
if (!mi.isLibrary()) moduleNames.add(mi.getName());
}
}
File folder = CarpetServer.minecraft_server.method_27050().resolve("scripts").toFile();
File folder = CarpetServer.minecraft_server.method_27050(class_5218.field_24188).resolve("scripts").toFile();
File[] listOfFiles = folder.listFiles();
if (listOfFiles == null)
return moduleNames;
@@ -1,6 +1,7 @@
package carpet.script.bundled;
import carpet.CarpetServer;
import net.minecraft.class_5218;
import net.minecraft.nbt.Tag;
import java.io.File;
@@ -34,7 +35,7 @@ public abstract class Module
public static Tag getData(Module module, String file, boolean isShared)
{
if (!isShared && (module == null || module.getName() == null)) return null;
File dataFile = CarpetServer.minecraft_server.method_27050().resolve("scripts/"+getDescriptor(module, file, isShared)+".nbt").toFile();
File dataFile = CarpetServer.minecraft_server.method_27050(class_5218.field_24188).resolve("scripts/"+getDescriptor(module, file, isShared)+".nbt").toFile();
if (!Files.exists(dataFile.toPath()) || !(dataFile.isFile())) return null;
return read(dataFile);
}
@@ -42,7 +43,7 @@ public abstract class Module
public static boolean saveData(Module module, String file, Tag globalState, boolean isShared)
{
if (!isShared && (module == null || module.getName() == null)) return false;
File dataFile =CarpetServer.minecraft_server.method_27050().resolve("scripts/"+getDescriptor(module, file, isShared)+".nbt").toFile();
File dataFile =CarpetServer.minecraft_server.method_27050(class_5218.field_24188).resolve("scripts/"+getDescriptor(module, file, isShared)+".nbt").toFile();
if (!Files.exists(dataFile.toPath().getParent()) && !dataFile.getParentFile().mkdirs()) return false;
return write(globalState, dataFile);
}
@@ -1,5 +1,6 @@
package carpet.script.utils;
import carpet.fakes.MinecraftServerInterface;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.chunk.ChunkStatus;
@@ -24,9 +25,7 @@ public class WorldTools
if (region == null) return false;
return region.hasChunk(chpos);
}
Path regionPath = world.getDimension().getType().getSaveDirectory(
world.getSaveHandler().getWorldDir()
).toPath().resolve("region");
Path regionPath = new File(((MinecraftServerInterface )world.getServer()).getCMSession().method_27424(world.getDimension().getType()), "region").toPath();
Path regionFilePath = regionPath.resolve(currentRegionName);
File regionFile = regionFilePath.toFile();
if (!regionFile.exists())
@@ -11,6 +11,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraft.class_5218;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.ServerTask;
@@ -136,7 +137,7 @@ public class SettingsManager
private File getFile()
{
return server.method_27050().resolve(identifier+".conf").toFile();
return server.method_27050(class_5218.field_24188).resolve(identifier+".conf").toFile();
}
public void disableBooleanCommands()
+9 -9
View File
@@ -3,14 +3,14 @@ package carpet.utils;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Formatting;
import net.minecraft.text.BaseText;
import net.minecraft.server.MinecraftServer;
import net.minecraft.text.ClickEvent;
import net.minecraft.text.HoverEvent;
import net.minecraft.text.LiteralText;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.Formatting;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.dimension.DimensionType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -56,10 +56,10 @@ public class Messenger
{
//could be rewritten to be more efficient
comp.getStyle().setItalic(style.indexOf('i')>=0);
comp.getStyle().setStrikethrough(style.indexOf('s')>=0);
comp.getStyle().setUnderline(style.indexOf('u')>=0);
if (style.indexOf('s')>=0) comp.setStyle(comp.getStyle().method_27705(Formatting.STRIKETHROUGH));
if (style.indexOf('u')>=0) comp.setStyle(comp.getStyle().method_27705(Formatting.UNDERLINE));
comp.getStyle().setBold(style.indexOf('b')>=0);
comp.getStyle().setObfuscated(style.indexOf('o')>=0);
if (style.indexOf('o')>=0) comp.setStyle(comp.getStyle().method_27705(Formatting.OBFUSCATED));
comp.getStyle().setColor(Formatting.WHITE);
if (style.indexOf('w')>=0) comp.getStyle().setColor(Formatting.WHITE); // not needed
if (style.indexOf('y')>=0) comp.getStyle().setColor(Formatting.YELLOW);
@@ -139,7 +139,7 @@ public class Messenger
if (desc.charAt(0) == '^')
{
if (previous_message != null)
previous_message.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, c(message.substring(1))));
previous_message.getStyle().setHoverEvent(new HoverEvent(HoverEvent.class_5247.field_24342, c(message.substring(1))));
return previous_message;
}
BaseText txt = new LiteralText(str);