-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c60a8d
commit 052b567
Showing
103 changed files
with
1,850 additions
and
133 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
minVersionIncluded=1.3 | ||
maxVersionIncluded=1.12.2 | ||
artifactSuffix= |
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
32 changes: 32 additions & 0 deletions
32
...nd-api-v1/common/src/testmod/java/net/legacyfabric/fabric/test/command/CommandV1Test.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2020 - 2024 Legacy Fabric | ||
* Copyright (c) 2016 - 2022 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.legacyfabric.fabric.test.command; | ||
|
||
import net.fabricmc.api.ModInitializer; | ||
|
||
import net.legacyfabric.fabric.api.logger.v1.Logger; | ||
import net.legacyfabric.fabric.api.registry.CommandRegistry; | ||
|
||
public class CommandV1Test implements ModInitializer { | ||
public static final Logger LOGGER = Logger.get("LegacyFabricAPI", "Test", "CommandV1Test"); | ||
|
||
@Override | ||
public void onInitialize() { | ||
CommandRegistry.INSTANCE.register(new ModMetadataCommandV1()); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
...v1/common/src/testmod/java/net/legacyfabric/fabric/test/command/ModMetadataCommandV1.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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright (c) 2020 - 2024 Legacy Fabric | ||
* Copyright (c) 2016 - 2022 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.legacyfabric.fabric.test.command; | ||
|
||
import java.util.Optional; | ||
|
||
import net.minecraft.command.AbstractCommand; | ||
import net.minecraft.command.CommandException; | ||
import net.minecraft.command.CommandSource; | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
import net.fabricmc.loader.api.ModContainer; | ||
import net.fabricmc.loader.api.metadata.ContactInformation; | ||
|
||
public class ModMetadataCommandV1 extends AbstractCommand { | ||
@Override | ||
public String getCommandName() { | ||
return "modmetadatav1"; | ||
} | ||
|
||
@Override | ||
public String getUsageTranslationKey(CommandSource source) { | ||
return "modmetadatav1"; | ||
} | ||
|
||
@Override | ||
public void execute(CommandSource source, String[] args) throws CommandException { | ||
if (args.length > 0) { | ||
Optional<ModContainer> optionalModContainer = FabricLoader.getInstance().getModContainer(args[0]); | ||
|
||
if (optionalModContainer.isPresent()) { | ||
ModContainer container = optionalModContainer.get(); | ||
|
||
StringBuilder builder = new StringBuilder(); | ||
builder.append("Mod Name: ".concat(container.getMetadata().getName()).concat("\n")); | ||
builder.append("Description: ".concat(container.getMetadata().getDescription()).concat("\n")); | ||
ContactInformation contact = container.getMetadata().getContact(); | ||
|
||
if (contact.get("issues").isPresent()) { | ||
StringBuilder issueText = new StringBuilder(""); | ||
issueText.append("Issues: "); | ||
StringBuilder issueUrl = new StringBuilder(contact.get("issues").get()); | ||
issueText.append(issueUrl); | ||
issueText.append("\n"); | ||
builder.append(issueText); | ||
} | ||
|
||
if (contact.get("sources").isPresent()) { | ||
StringBuilder sourcesText = new StringBuilder(""); | ||
sourcesText.append("Sources: "); | ||
StringBuilder sourcesUrl = new StringBuilder(contact.get("sources").get()); | ||
sourcesText.append(sourcesUrl); | ||
sourcesText.append("\n"); | ||
builder.append(sourcesText); | ||
} | ||
|
||
builder.append("Metadata Type: ".concat(container.getMetadata().getType()).concat("\n")); | ||
CommandV1Test.LOGGER.info(builder.toString()); | ||
} else { | ||
CommandV1Test.LOGGER.error("Couldn't find Mod container for mod id '" + args[0] + "'"); | ||
} | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
legacy-fabric-command-api-v1/common/src/testmod/resources/fabric.mod.json
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"id": "legacy-fabric-command-api-v1-testmod", | ||
"description": "Tests for api features", | ||
"version": "1.0.0", | ||
"entrypoints": { | ||
"main": [ | ||
"net.legacyfabric.fabric.test.command.CommandV1Test" | ||
] | ||
}, | ||
"depends": { | ||
"minecraft": "${minecraft_version}" | ||
} | ||
} |
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,2 +1,2 @@ | ||
minVersionIncluded=1.3 | ||
minVersionIncluded=1.7.10 | ||
maxVersionIncluded=1.7.10 |
36 changes: 36 additions & 0 deletions
36
...-v1/1.12.2/src/main/java/net/legacyfabric/fabric/mixin/item/group/client/MixinScreen.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2020 - 2024 Legacy Fabric | ||
* Copyright (c) 2016 - 2022 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.legacyfabric.fabric.mixin.item.group.client; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
import net.minecraft.client.gui.screen.Screen; | ||
|
||
import net.legacyfabric.fabric.impl.item.group.ScreenAccessor; | ||
|
||
@Mixin(Screen.class) | ||
public abstract class MixinScreen implements ScreenAccessor { | ||
@Shadow | ||
public abstract void renderTooltip(String text, int x, int y); | ||
|
||
@Override | ||
public void callRenderTooltip(String text, int x, int y) { | ||
this.renderTooltip(text, x, y); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
"ItemGroupMixin" | ||
], | ||
"client": [ | ||
"client.MixinScreen" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
|
Empty file.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minVersionIncluded=1.3 | ||
maxVersionIncluded=1.6.4 |
57 changes: 57 additions & 0 deletions
57
...roups-v1/1.6.4/src/main/java/net/legacyfabric/fabric/impl/item/group/FabricItemGroup.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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2020 - 2024 Legacy Fabric | ||
* Copyright (c) 2016 - 2022 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.legacyfabric.fabric.impl.item.group; | ||
|
||
import java.util.List; | ||
import java.util.function.BiConsumer; | ||
import java.util.function.Supplier; | ||
|
||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.itemgroup.ItemGroup; | ||
|
||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
|
||
public class FabricItemGroup extends ItemGroup { | ||
private final Supplier<ItemStack> itemSupplier; | ||
private final BiConsumer<List<ItemStack>, ItemGroup> stacksForDisplay; | ||
|
||
public FabricItemGroup(int index, String id, Supplier<ItemStack> itemSupplier, BiConsumer<List<ItemStack>, ItemGroup> stacksForDisplay) { | ||
super(index, id); | ||
this.itemSupplier = itemSupplier; | ||
this.stacksForDisplay = stacksForDisplay; | ||
} | ||
|
||
@Override | ||
@Environment(EnvType.CLIENT) | ||
public Item method_3320() { | ||
return this.itemSupplier.get().getItem(); | ||
} | ||
|
||
@Override | ||
@Environment(EnvType.CLIENT) | ||
public void showItems(List stacks) { | ||
if (stacksForDisplay != null) { | ||
stacksForDisplay.accept(stacks, this); | ||
return; | ||
} | ||
|
||
super.showItems(stacks); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...roups-v1/1.6.4/src/main/java/net/legacyfabric/fabric/mixin/item/group/ItemGroupMixin.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2020 - 2024 Legacy Fabric | ||
* Copyright (c) 2016 - 2022 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.legacyfabric.fabric.mixin.item.group; | ||
|
||
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 net.minecraft.item.itemgroup.ItemGroup; | ||
|
||
import net.legacyfabric.fabric.impl.item.group.FabricCreativeGuiComponents; | ||
import net.legacyfabric.fabric.impl.item.group.FabricItemGroup; | ||
|
||
@Mixin(ItemGroup.class) | ||
public class ItemGroupMixin { | ||
@Inject(method = "<clinit>", at = @At("RETURN")) | ||
private static void classInit(CallbackInfo ci) { | ||
FabricCreativeGuiComponents.ITEM_GROUP_CREATOR = FabricItemGroup::new; | ||
} | ||
} |
Oops, something went wrong.