Skip to content

Commit

Permalink
merged 1.19.x branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Jul 9, 2022
1 parent 6fe2ddd commit a90f0cf
Show file tree
Hide file tree
Showing 73 changed files with 995 additions and 102 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ preprocess {
def mc116 = createNode('1.16.5' , 1_16_05, 'yarn')
def mc117 = createNode('1.17.1' , 1_17_01, 'yarn')
def mc118 = createNode('1.18.x' , 1_18_02, 'yarn')
// def mc119 = createNode('1.19.x', 1_19_00, 'yarn')
// def mcSnapshot = createNode('future', 1_19_01, 'yarn')
def mc119 = createNode('1.19.x' , 1_19_00, 'yarn')
// def mcFuture = createNode('future', 1_19_01, 'yarn')

mc115.link(mc114, file('versions/mapping-1.15-1.14.txt'))
mc115.link(mc116, file('versions/mapping-1.15-1.16.txt'))
mc116.link(mc117, file('versions/mapping-1.16-1.17.txt'))
mc117.link(mc118, file('versions/mapping-1.17-1.18.txt'))
// mc118.link(mcSnapshot, null)
mc118.link(mc119, file('versions/mapping-1.18-1.19.txt'))
// mc119.link(mcFuture, null)
}

task buildAndGather {
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def versions = Arrays.asList(
"1.16.5",
"1.17.1",
"1.18.x",
// "1.19.x",
"1.19.x",
// "future",
)
for (String version : versions) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/carpettisaddition/CarpetTISAdditionMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class CarpetTISAdditionMod implements ModInitializer
public void onInitialize()
{
version = FabricLoader.getInstance().getModContainer(MOD_ID).orElseThrow(RuntimeException::new).getMetadata().getVersion().getFriendlyString();

CarpetTISAdditionServer.registerExtension();
}

public static String getModId()
Expand Down
38 changes: 30 additions & 8 deletions src/main/java/carpettisaddition/CarpetTISAdditionServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import carpettisaddition.translations.TISAdditionTranslations;
import carpettisaddition.utils.deobfuscator.StackTraceDeobfuscator;
import carpettisaddition.utils.settings.CarpetRuleRegistrar;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.server.MinecraftServer;
Expand All @@ -29,6 +30,10 @@

import java.util.Map;

//#if MC >= 11900
//$$ import net.minecraft.command.CommandRegistryAccess;
//#endif

//#if MC >= 11600
//$$ import carpet.script.annotation.AnnotationParser;
//$$ import carpettisaddition.script.Functions;
Expand All @@ -37,7 +42,7 @@

public class CarpetTISAdditionServer implements CarpetExtension
{
public static final CarpetTISAdditionServer INSTANCE = new CarpetTISAdditionServer();
private static final CarpetTISAdditionServer INSTANCE = new CarpetTISAdditionServer();
public static final String name = CarpetTISAdditionMod.getModId();
public static final String fancyName = "Carpet TIS Addition";
public static final String compactName = name.replace("-",""); // carpettisaddition
Expand All @@ -50,6 +55,11 @@ public String version()
return name;
}

public static CarpetTISAdditionServer getInstance()
{
return INSTANCE;
}

public static void registerExtension()
{
CarpetServer.manageExtension(INSTANCE);
Expand Down Expand Up @@ -117,14 +127,26 @@ public void onCarpetClientHello(ServerPlayerEntity player)
}

@Override
public void registerCommands(CommandDispatcher<ServerCommandSource> dispatcher)
public void registerCommands(
CommandDispatcher<ServerCommandSource> dispatcher
//#if MC >= 11900
//$$ , CommandRegistryAccess commandBuildContext
//#endif
)
{
LifeTimeCommand.getInstance().registerCommand(dispatcher);
ManipulateCommand.getInstance().registerCommand(dispatcher);
RefreshCommand.getInstance().registerCommand(dispatcher);
RaidCommand.getInstance().registerCommand(dispatcher);
RemoveEntityCommand.getInstance().registerCommand(dispatcher);
SupplierCounterCommand.getInstance().registerCommand(dispatcher);
Lists.newArrayList(
LifeTimeCommand.getInstance(),
ManipulateCommand.getInstance(),
RefreshCommand.getInstance(),
RaidCommand.getInstance(),
RemoveEntityCommand.getInstance(),
SupplierCounterCommand.getInstance()
).forEach(command -> command.registerCommand(
dispatcher
//#if MC >= 11900
//$$ , commandBuildContext
//#endif
));
}

//#if MC >= 11500
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/carpettisaddition/commands/CommandExtender.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.server.command.ServerCommandSource;

//#if MC >= 11900
//$$ import net.minecraft.command.CommandRegistryAccess;
//#endif

public interface CommandExtender
{
void extendCommand(LiteralArgumentBuilder<ServerCommandSource> builder);
void extendCommand(
LiteralArgumentBuilder<ServerCommandSource> builder
//#if MC >= 11900
//$$ , CommandRegistryAccess commandBuildContext
//#endif
);
}
11 changes: 10 additions & 1 deletion src/main/java/carpettisaddition/commands/CommandRegister.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.server.command.ServerCommandSource;

//#if MC >= 11900
//$$ import net.minecraft.command.CommandRegistryAccess;
//#endif

public interface CommandRegister
{
void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher);
void registerCommand(
CommandDispatcher<ServerCommandSource> dispatcher
//#if MC >= 11900
//$$ , CommandRegistryAccess commandBuildContext
//#endif
);
}
18 changes: 16 additions & 2 deletions src/main/java/carpettisaddition/commands/info/InfoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
import java.util.function.Function;
import java.util.stream.Collectors;

//#if MC >= 11900
//$$ import net.minecraft.command.CommandRegistryAccess;
//#endif

//#if MC >= 11800
//$$ import carpettisaddition.mixins.command.info.ChunkTickSchedulerAccessor;
//$$ import carpettisaddition.mixins.command.info.WorldTickSchedulerAccessor;
Expand Down Expand Up @@ -55,11 +59,21 @@ public InfoCommand()
}

@Override
public void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher)
public void registerCommand(
CommandDispatcher<ServerCommandSource> dispatcher
//#if MC >= 11900
//$$ , CommandRegistryAccess commandBuildContext
//#endif
)
{
}

public void extendCommand(LiteralArgumentBuilder<ServerCommandSource> builder)
public void extendCommand(
LiteralArgumentBuilder<ServerCommandSource> builder
//#if MC >= 11900
//$$ , CommandRegistryAccess commandBuildContext
//#endif
)
{
builder.then(
literal("world").
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;

//#if MC >= 11900
//$$ import net.minecraft.command.CommandRegistryAccess;
//#endif

/**
* Logic ports from fabric-carpet 1.4.54
* Newer carpet remove entity info framework, so we need to keep a copy of that
Expand All @@ -34,7 +38,12 @@ public static EntityInfoCommand getInstance()
}

@Override
public void extendCommand(LiteralArgumentBuilder<ServerCommandSource> builder)
public void extendCommand(
LiteralArgumentBuilder<ServerCommandSource> builder
//#if MC >= 11900
//$$ , CommandRegistryAccess commandBuildContext
//#endif
)
{
builder.then(literal("entity").
then(argument("entity selector", EntityArgumentType.entities()).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ public static List<BaseText> entityInfo(Entity e, World source_world)
if (e instanceof PaintingEntity)
{
PaintingEntity ep = (PaintingEntity)e;
lst.add(Messenger.c("w - Art: ", "wb "+ep.motive.toString()));
String motive =
//#if MC >= 11900
//$$ ep.getVariant().toString();
//#else
ep.motive.toString();
//#endif
lst.add(Messenger.c("w - Art: ", "wb "+motive));
}

if (e instanceof LivingEntity) // EntityLivingBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
import static net.minecraft.server.command.CommandManager.literal;
import static net.minecraft.server.command.CommandSource.suggestMatching;

//#if MC >= 11900
//$$ import net.minecraft.command.CommandRegistryAccess;
//#endif

public class LifeTimeCommand extends AbstractCommand
{
private static final String NAME = "lifetime";
Expand Down Expand Up @@ -116,7 +120,12 @@ private int printEntityFilter(ServerCommandSource source, @Nullable String entit
*/

@Override
public void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher)
public void registerCommand(
CommandDispatcher<ServerCommandSource> dispatcher
//#if MC >= 11900
//$$ , CommandRegistryAccess commandBuildContext
//#endif
)
{
final String entityTypeArg = "entity_type";
final String detailModeArg = "detail";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

import static net.minecraft.server.command.CommandManager.literal;

//#if MC >= 11900
//$$ import net.minecraft.command.CommandRegistryAccess;
//#endif

public class ManipulateCommand extends AbstractCommand
{
private static final String NAME = "manipulate";
Expand All @@ -35,10 +39,21 @@ public static ManipulateCommand getInstance()
}

@Override
public void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher)
public void registerCommand(
CommandDispatcher<ServerCommandSource> dispatcher
//#if MC >= 11900
//$$ , CommandRegistryAccess commandBuildContext
//#endif
)
{
LiteralArgumentBuilder<ServerCommandSource> containerNode = literal("container");
COLLECTION_CONTROLLERS.forEach(controller -> containerNode.then(controller.getCommandNode()));
COLLECTION_CONTROLLERS.forEach(
controller -> containerNode.then(controller.getCommandNode(
//#if MC >= 11900
//$$ commandBuildContext
//#endif
))
);

LiteralArgumentBuilder<ServerCommandSource> builder = literal(NAME).
requires(player -> CarpetModUtil.canUseCommand(player, CarpetTISAdditionSettings.commandManipulate)).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

import static net.minecraft.server.command.CommandManager.literal;

//#if MC >= 11900
//$$ import net.minecraft.command.CommandRegistryAccess;
//#endif

public abstract class AbstractContainerController extends TranslationContext
{
protected static final Translator basicTranslator = ManipulateCommand.getInstance().getTranslator().getDerivedTranslator("container");
Expand All @@ -26,7 +30,11 @@ protected BaseText getName()
return tr("name");
}

public ArgumentBuilder<ServerCommandSource, ?> getCommandNode()
public ArgumentBuilder<ServerCommandSource, ?> getCommandNode(
//#if MC >= 11900
//$$ CommandRegistryAccess commandBuildContext
//#endif
)
{
return literal(this.commandPrefix).executes(c -> this.showHelp(c.getSource()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

import static net.minecraft.server.command.CommandManager.literal;

//#if MC >= 11900
//$$ import net.minecraft.command.CommandRegistryAccess;
//#endif

public abstract class AbstractEntityListController extends AbstractContainerController
{
public AbstractEntityListController(String translationName)
Expand Down Expand Up @@ -53,9 +57,17 @@ protected int manipulate(ServerCommandSource source, Runnable task)
}

@Override
public ArgumentBuilder<ServerCommandSource, ?> getCommandNode()
public ArgumentBuilder<ServerCommandSource, ?> getCommandNode(
//#if MC >= 11900
//$$ CommandRegistryAccess commandBuildContext
//#endif
)
{
return super.getCommandNode().
return super.getCommandNode(
//#if MC >= 11900
//$$ commandBuildContext
//#endif
).
then(literal("shuffle").executes(c -> this.shuffle(c.getSource()))).
then(literal("revert").executes(c -> this.revert(c.getSource())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;

//#if MC >= 11900
//$$ import net.minecraft.command.CommandRegistryAccess;
//#endif

public class BlockEventQueueController extends AbstractContainerController
{
public BlockEventQueueController()
Expand Down Expand Up @@ -66,17 +70,29 @@ public int addEvent(CommandContext<ServerCommandSource> context) throws CommandS
}

@Override
public ArgumentBuilder<ServerCommandSource, ?> getCommandNode()
public ArgumentBuilder<ServerCommandSource, ?> getCommandNode(
//#if MC >= 11900
//$$ CommandRegistryAccess commandBuildContext
//#endif
)
{
return super.getCommandNode().
return super.getCommandNode(
//#if MC >= 11900
//$$ commandBuildContext
//#endif
).
then(literal("remove").
then(argument("pos", blockPos()).
executes(c -> this.removeAt(c.getSource(), getLoadedBlockPos(c, "pos")))
)
).
then(literal("add").
then(argument("pos", blockPos()).
then(argument("block", blockState()).
then(argument("block", blockState(
//#if MC >= 11900
//$$ commandBuildContext
//#endif
)).
then(argument("type", integer()).
then(argument("data", integer()).
executes(this::addEvent)
Expand Down
Loading

0 comments on commit a90f0cf

Please sign in to comment.