-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.20.2] Initial port work; port resource loader #336
Changes from all commits
eeb5e95
0b2532d
2dedeae
d8c5ad1
e4f5971
9b5cb6a
5ed9deb
af8e289
64562df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
import com.google.common.util.concurrent.ThreadFactoryBuilder; | ||
import com.google.gson.JsonObject; | ||
import com.mojang.logging.LogUtils; | ||
import net.minecraft.SharedConstants; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't forget about checkstyle |
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.jetbrains.annotations.Unmodifiable; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
package org.quiltmc.qsl.resource.loader.api; | ||
|
||
import net.minecraft.resource.pack.ResourcePack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import net.minecraft.resource.pack.ResourcePackProfile; | ||
|
@@ -39,4 +40,18 @@ public interface QuiltResourcePackProfile { | |
default @NotNull ResourcePackActivationType getActivationType() { | ||
return ResourcePackActivationType.NORMAL; | ||
} | ||
|
||
static ResourcePackProfile.ResourcePackFactory identityFactory(ResourcePack pack) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this in API? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved it to API after noticing that the testmods need it. Vanilla does exactly the same thing, but their implementation |
||
return new ResourcePackProfile.ResourcePackFactory() { | ||
@Override | ||
public ResourcePack method_52424(String string) { | ||
return pack; | ||
} | ||
|
||
@Override | ||
public ResourcePack method_52425(String string, ResourcePackProfile.Info info) { | ||
return pack; | ||
} | ||
}; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2023 The Quilt Project | ||
* | ||
* 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 org.quiltmc.qsl.resource.loader.impl; | ||
|
||
import net.minecraft.resource.pack.ResourcePackSource; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Formatting; | ||
|
||
/** | ||
* Represents a built-in resource pack source. | ||
* Similar to {@link ResourcePackSource#PACK_SOURCE_BUILTIN} but specifies the mod name too. | ||
*/ | ||
public class BuiltinResourcePackSource implements ResourcePackSource { | ||
private static final Text SOURCE_BUILTIN_TEXT = Text.translatable("pack.source.builtin"); | ||
private final ModNioResourcePack pack; | ||
private final Text text; | ||
private final Text tooltip; | ||
|
||
BuiltinResourcePackSource(ModNioResourcePack pack) { | ||
String modName = pack.modInfo.name(); | ||
|
||
if (modName == null) { | ||
modName = pack.modInfo.id(); | ||
} | ||
|
||
this.pack = pack; | ||
this.text = SOURCE_BUILTIN_TEXT; | ||
this.tooltip = Text.translatable("options.generic_value", SOURCE_BUILTIN_TEXT, modName); | ||
} | ||
|
||
@Override | ||
public Text decorate(Text description) { | ||
return Text.translatable("pack.nameAndSource", description, this.text).formatted(Formatting.GRAY); | ||
} | ||
|
||
@Override | ||
public boolean shouldAddAutomatically() { | ||
return this.pack.getActivationType().isEnabledByDefault(); | ||
} | ||
|
||
public Text getTooltip() { | ||
return this.tooltip; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.