-
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
9170d75
commit f96b8da
Showing
21 changed files
with
295 additions
and
20 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
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.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
|
||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.itemgroup.ItemGroup; | ||
|
||
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; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...6.4/src/main/java/net/legacyfabric/fabric/mixin/item/group/client/HandledScreenMixin.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,19 @@ | ||
package net.legacyfabric.fabric.mixin.item.group.client; | ||
|
||
import net.legacyfabric.fabric.impl.item.group.ScreenAccessor; | ||
|
||
import net.minecraft.client.gui.screen.ingame.HandledScreen; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
|
||
@Mixin(HandledScreen.class) | ||
public abstract class HandledScreenMixin implements ScreenAccessor { | ||
@Shadow | ||
protected abstract void method_1128(String par1, int par2, int par3); | ||
|
||
@Override | ||
public void callRenderTooltip(String text, int x, int y) { | ||
this.method_1128(text, x, y); | ||
} | ||
} |
Binary file added
BIN
+1.54 KB
...cy-fabric-item-groups-v1/1.6.4/src/main/resources/assets/legacy-fabric/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
legacy-fabric-item-groups-v1/1.6.4/src/main/resources/assets/legacy-fabric/lang/en_US.lang
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 @@ | ||
fabric.gui.creativeTabPage=Page %d/%d |
1 change: 1 addition & 0 deletions
1
legacy-fabric-item-groups-v1/1.6.4/src/main/resources/assets/legacy-fabric/lang/ru_RU.lang
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 @@ | ||
fabric.gui.creativeTabPage=Страница %d/%d |
Binary file added
BIN
+552 Bytes
...1.6.4/src/main/resources/assets/legacy-fabric/textures/gui/creative_buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions
37
legacy-fabric-item-groups-v1/1.6.4/src/main/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,37 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"id": "legacy-fabric-item-groups-v1", | ||
"name": "Legacy Fabric Item Groups (V1)", | ||
"version": "${version}", | ||
"environment": "*", | ||
"license": "Apache-2.0", | ||
"icon": "assets/legacy-fabric/icon.png", | ||
"contact": { | ||
"homepage": "https://legacyfabric.net/", | ||
"issues": "https://github.com/Legacy-Fabric/fabric/issues", | ||
"sources": "https://github.com/Legacy-Fabric/fabric" | ||
}, | ||
"authors": [ | ||
"FabricMC", | ||
"Legacy Fabric" | ||
], | ||
"mixins": [ | ||
"legacy-fabric-item-groups-v1.mixins.json" | ||
], | ||
"description": "Advanced item groups.", | ||
"depends": { | ||
"minecraft": "${minecraft_version}" | ||
}, | ||
"custom": { | ||
"modmenu": { | ||
"badges": [ "library" ], | ||
"parent": { | ||
"id": "legacy-fabric-api", | ||
"name": "Legacy Fabric API", | ||
"badges": [ "library" ], | ||
"description": "Core API module providing key hooks and inter-compatibility features for Minecraft 1.7.10-1.12.2.", | ||
"icon": "assets/legacy-fabric/icon.png" | ||
} | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...y-fabric-item-groups-v1/1.6.4/src/main/resources/legacy-fabric-item-groups-v1.mixins.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 @@ | ||
{ | ||
"required": true, | ||
"package": "net.legacyfabric.fabric.mixin.item.group", | ||
"compatibilityLevel": "JAVA_8", | ||
"mixins": [ | ||
"ItemGroupMixin" | ||
], | ||
"client": [ | ||
"client.HandledScreenMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...oups-v1/1.6.4/src/testmod/java/net/legacyfabric/fabric/test/item/group/ItemGroupTest.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,56 @@ | ||
/* | ||
* 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.item.group; | ||
|
||
import java.util.Arrays; | ||
import java.util.Objects; | ||
import java.util.stream.StreamSupport; | ||
|
||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.itemgroup.ItemGroup; | ||
|
||
import net.fabricmc.api.ModInitializer; | ||
|
||
import net.legacyfabric.fabric.api.client.itemgroup.FabricItemGroupBuilder; | ||
import net.legacyfabric.fabric.api.util.Identifier; | ||
|
||
public class ItemGroupTest implements ModInitializer { | ||
//Adds an item group with all items in it | ||
private static final ItemGroup ITEM_GROUP = FabricItemGroupBuilder.create(new Identifier("legacy-fabric-item-groups-v1-testmod", "test_group")) | ||
.iconWithItemStack(() -> new ItemStack(Item.DIAMOND)) | ||
.appendItems(stacks -> | ||
StreamSupport.stream(Arrays.stream(Item.ITEMS).spliterator(), false) | ||
.filter(Objects::nonNull) | ||
.map(ItemStack::new) | ||
.forEach(stacks::add) | ||
).build(); | ||
|
||
private static final ItemGroup ITEM_GROUP_2 = FabricItemGroupBuilder.create(new Identifier("legacy-fabric-item-groups-v1-testmod", "test_group_two")) | ||
.iconWithItemStack(() -> new ItemStack(Item.REDSTONE)) | ||
.appendItems((stacks, itemGroup) -> { | ||
for (Item item : Item.ITEMS) { | ||
if (item != null && (item.getItemGroup() == ItemGroup.FOOD || item.getItemGroup() == itemGroup)) { | ||
stacks.add(new ItemStack(item)); | ||
} | ||
} | ||
}).build(); | ||
|
||
@Override | ||
public void onInitialize() { } | ||
} |
1 change: 1 addition & 0 deletions
1
...abric-item-groups-v1/1.6.4/src/testmod/resources/assets/legacy-fabric-api/lang/en_US.lang
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 @@ | ||
itemGroup.dmn.testgroup=Test Group by DomamaN202 |
14 changes: 14 additions & 0 deletions
14
legacy-fabric-item-groups-v1/1.6.4/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-item-groups-v0-testmod", | ||
"description": "Tests for Item Groups", | ||
"version": "1.0.0", | ||
"entrypoints": { | ||
"main": [ | ||
"net.legacyfabric.fabric.test.item.group.ItemGroupTest" | ||
] | ||
}, | ||
"depends": { | ||
"minecraft": "${minecraft_version}" | ||
} | ||
} |
File renamed without changes.
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 | ||
|
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.7.10 | ||
minVersionIncluded=1.3 | ||
maxVersionIncluded=1.12.2 |
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