Skip to content

Commit 0da34f5

Browse files
committed
feat: fixs
1 parent c26c6b9 commit 0da34f5

File tree

18 files changed

+183
-121
lines changed

18 files changed

+183
-121
lines changed

src/main/java/me/matl114/gui/basic/DrawableWidget.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public <T extends DrawableWidget> T updateRenderHandler(UnaryOperator<RenderHand
121121
@Override
122122
public final void render(DrawContext context, int mouseX, int mouseY, float delta) {
123123
VDrawContext vdraw = VDrawContext.of(context);
124-
render0(VDrawContext.of(context), mouseX, mouseY, delta, false);
124+
render0(vdraw, mouseX, mouseY, delta, false);
125125
vdraw.tryDraw();
126126
}
127127
protected void checkSelect(boolean disableSelect, int mouseX, int mouseY){

src/main/java/me/matl114/gui/basic/LabelElement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public LabelElement(TextProvider text, int color, int alignment){
3131
public void renderCentered0(DrawableWidget element, VDrawContext context, int mouseX, int mouseY, float delta, float alpha, boolean shouldHighlight) {
3232
Text text1 = text.getLabel(element);
3333
if(text1 != null){
34-
RenderHandler.drawScaledText0(context, mc.textRenderer, text1, 0,0,element.getTextureWidth(), element.getTextureHeight(), color, alignment);
3534
context.drawTexturedQuad(BACKGROUND_RESOURCE, 0,element.getTextureWidth(), 0, element.getTextureHeight(), 0,u0,u1,v0,v1 );
35+
RenderHandler.drawScaledText0(context, mc.textRenderer, text1, 0,0,element.getTextureWidth(), element.getTextureHeight(), color, alignment);
3636
}
3737
}
3838
}

src/main/java/me/matl114/gui/itemEdit/ItemEditScreen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ public DrawableWidget factory(int x, int y){
491491
ButtonAction.run(()-> sec.setHideFlag(sample, !sec.isHide(sample))),
492492
(bl)->sec.isHide(sample)
493493
)
494-
.withTooltips(TooltipHandler.of(List.of(Text.literal(sec.name().toLowerCase(Locale.ROOT)))))
494+
.withTooltips(TooltipHandler.of(List.of(Text.literal(sec.displayName()))))
495495
)
496496
);
497497
}

src/main/java/me/matl114/hacks/ModelTasks.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
import me.matl114.hacks.api.ModuleGroup;
55
import me.matl114.hacks.api.ModuleManager;
66
import me.matl114.hacks.modules.HackModules;
7-
import me.matl114.hacks.modules.models.ModelExtra;
8-
import me.matl114.hacks.modules.models.NewStyleModel;
9-
import me.matl114.hacks.modules.models.SlimefunModels;
10-
import me.matl114.hacks.modules.models.StorageDisplay;
7+
import me.matl114.hacks.modules.models.*;
118

129
public class ModelTasks {
1310
public static void init(){
@@ -17,6 +14,8 @@ public static void init(){
1714
@Getter
1815
public static ModelExtra modelExtra;
1916
@Getter
17+
public static CustomTextures customTextures;
18+
@Getter
2019
public static NewStyleModel newStyleModel;
2120
@Getter
2221
public static SlimefunModels slimefunModels;
@@ -28,6 +27,8 @@ public static void init(){
2827
private static void initModule(ModuleManager m){
2928
modelExtra = new ModelExtra()
3029
.register(m);
30+
customTextures = new CustomTextures()
31+
.register(m);
3132
newStyleModel = new NewStyleModel()
3233
.register(m);
3334
slimefunModels = new SlimefunModels()

src/main/java/me/matl114/hacks/RecipeTasks.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import me.matl114.hacks.utils.recipes.RecipeIngredient;
55
import net.minecraft.client.MinecraftClient;
66
import net.minecraft.item.ItemStack;
7+
import net.minecraft.item.Items;
78
import net.minecraft.network.packet.s2c.play.SynchronizeRecipesS2CPacket;
89
import net.minecraft.recipe.*;
910
import net.minecraft.registry.DynamicRegistryManager;
@@ -26,6 +27,20 @@ public static boolean isVanillaRecipeType(String rid){
2627
return Registries.RECIPE_TYPE.getOrEmpty(Identifier.tryParse(rid)).isPresent();
2728
}
2829

30+
private static final Map<String, ItemStack> SUPPORT_VANILLA_RTYPE = Map.of(
31+
"minecraft:crafting", new ItemStack(Items.CRAFTING_TABLE),
32+
"minecraft:smelting", new ItemStack(Items.FURNACE),
33+
"minecraft:blasting", new ItemStack(Items.BLAST_FURNACE),
34+
"minecraft:smoking", new ItemStack(Items.SMOKER),
35+
"minecraft:campfire_cooking", new ItemStack(Items.CAMPFIRE),
36+
"minecraft:stonecutting", new ItemStack(Items.STONECUTTER),
37+
"minecraft:smithing", new ItemStack(Items.SMITHING_TABLE)
38+
);
39+
40+
public static ItemStack getVanillaRecipeTypeIcon(String rid){
41+
return SUPPORT_VANILLA_RTYPE.getOrDefault(rid, null);
42+
}
43+
2944
public static Map<Identifier, RecipeRecord> getAllRecipe(){
3045
init();
3146
return CACHE;

src/main/java/me/matl114/hacks/SlimefunTasks.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,10 @@ public static ItemStack byId(String id){
6767
return InvTasks.getCustomItemDatabase().getFromCodecId(id);
6868
}
6969

70-
71-
private static final Map<String, ItemStack> SUPPORT_VANILLA_RTYPE = Map.of(
72-
"minecraft:crafting", new ItemStack(Items.CRAFTING_TABLE),
73-
"minecraft:smelting", new ItemStack(Items.FURNACE),
74-
"minecraft:blasting", new ItemStack(Items.BLAST_FURNACE),
75-
"minecraft:smoking", new ItemStack(Items.SMOKER),
76-
"minecraft:campfire_cooking", new ItemStack(Items.CAMPFIRE),
77-
"minecraft:stonecutting", new ItemStack(Items.STONECUTTER),
78-
"minecraft:smithing", new ItemStack(Items.SMITHING_TABLE)
79-
);
8070
private static ItemStack getSupportVanillaIcon(String rid){
81-
return SUPPORT_VANILLA_RTYPE.getOrDefault(rid,null);
71+
if(RecipeTasks.isVanillaRecipeType(rid)){
72+
return RecipeTasks.getVanillaRecipeTypeIcon(rid);
73+
}return null;
8274
}
8375
public static ItemStack getRecipeTypeIcon(String rid){
8476
ItemStack rt;
@@ -393,6 +385,8 @@ public void onView(ArgumentInputStream re){
393385
public static SlimefunGuide slimefunGuide;
394386
@Getter
395387
public static CopyId copyId;
388+
@Getter
389+
public static ShowIdTooltips showIdTooltips;
396390
private static void initModule(ModuleManager m){
397391
slimefunExtra = new SlimefunExtra()
398392
.register(m);
@@ -404,6 +398,8 @@ private static void initModule(ModuleManager m){
404398
.register(m);
405399
copyId = new CopyId()
406400
.register(m);
401+
showIdTooltips = new ShowIdTooltips()
402+
.register(m);
407403
}
408404

409405
static{

src/main/java/me/matl114/hacks/modules/inv/FastCraft.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void onRecipeClicked(Event<RecipeEntry<?>> event){
8585

8686
public void toggleRecipeLock(){
8787
lock = !lock;
88-
Debug.chat("Toggle RecipeLock ", lock);
88+
Debug.chat("Toggle RecipeLock", lock);
8989
}
9090

9191

@@ -192,8 +192,7 @@ private void addCraftingInventoryButton(CraftingScreen screen){
192192
)
193193
.addToSub(recipeSubScreen);
194194

195-
DrawableWidget lockItemDisplay = DisplayWidget.instance(150 + 10, access.getScreenY() + 56 + 10, 18, 18)
196-
.setTextureScale(0.4f)
195+
DrawableWidget lockItemDisplay = DisplayWidget.instance(150 + 10, access.getScreenY() + 56 + 10, 7, 7)
197196
.setRenderHandler(
198197
new SlotElement(this::getLockItem)
199198
.setInSlot(false)
@@ -249,8 +248,7 @@ private void addInventoryButton(InventoryScreen screen){
249248
)
250249
.addToSub(recipeSubScreen);
251250

252-
DrawableWidget lockItemDisplay = DisplayWidget.instance(132 + 10, access.getScreenY() + 55 + 10, 18, 18)
253-
.setTextureScale(0.4f)
251+
DrawableWidget lockItemDisplay = DisplayWidget.instance(132 + 10, access.getScreenY() + 55 + 10, 7, 7)
254252
.setRenderHandler(
255253
new SlotElement(this::getLockItem)
256254
.setInSlot(false)

src/main/java/me/matl114/hacks/modules/inv/SaveItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void ensureLoad(){
6969
Codec.list(Codec.STRING).xmap(
7070
lst -> (Map<String, ItemStackData>)lst.stream().collect(Collectors.toMap(Function.identity(), InvTasks.getCustomItemDatabase()::getDataFromCodecId, (k, v)-> v, LinkedHashMap::new)),
7171
mp -> mp.keySet().stream().toList()
72-
).fieldOf("saved-ids").codec();
72+
).optionalFieldOf("saved-ids", Map.of()).codec();
7373
Gson gson = new GsonBuilder()
7474
.disableHtmlEscaping()
7575
.create();

src/main/java/me/matl114/hacks/modules/mine/MineExtra.java

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -162,67 +162,68 @@ public void registerAll() {
162162
}
163163

164164
public void onRender(Event<MatrixStack> renderEvent){
165-
RenderUtils.startDrawVirtual(renderEvent.context);
166-
try{
167-
if(mineRender.get() && mc.interactionManager != null && mc.player != null && mc.world != null){
168-
BlockPos blockPos = PlayerInteractionAccess.of(mc.interactionManager).getCurrentMiningPos();
169-
Vec3d pos =Vec3d.of(blockPos);
170-
//超过200格的不渲染
171-
if(mc.player.getPos().squaredDistanceTo(pos) < 40000){
172-
RenderUtils.setAsCurrentShaderColor(Color.BLUE, 1.0F);
173-
RenderUtils.drawOutlinedBox(renderEvent.context, pos, pos.add(1.0, 1.0, 1.0));
174-
float progress = PlayerInteractionAccess.of(mc.interactionManager).getCurrentMiningProgress(true);
175-
if(progress > 0.0F){
176-
BlockState state = mc.world.getBlockState(blockPos);
177-
Box box;
178-
if(state.isAir()){
179-
box = new Box(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
180-
}else{
181-
VoxelShape shape = state.getOutlineShape(mc.world, blockPos);
182-
box = shape.isEmpty()? new Box(0.0, 0.0, 0.0, 1.0, 1.0, 1.0): shape.getBoundingBox();
183-
}
184-
Vec3d vec3 = box.getMaxPos().subtract(box.getMinPos()).multiply(0.5);
185-
186-
RenderUtils.setAsCurrentShaderColor(Color.YELLOW, 0.25F);
187-
Vec3d vec3d = pos.add(box.getCenter());
188-
float clamped = MathHelper.clamp(progress, 0.0F, 1.0F) ;
189-
RenderUtils.drawSolidBox(renderEvent.context.peek().getPositionMatrix(), vec3d.add(vec3.multiply(-clamped)), vec3d.add(vec3.multiply(clamped)));
190-
}
191-
}
192-
193-
194-
BlockPos doubleMinePos = PlayerInteractionAccess.of(mc.interactionManager).getCurrentFailBreakPos();
195-
if(doubleMinePos != null){
196-
Vec3d doubleMineVec = Vec3d.of(doubleMinePos);
197-
if(mc.player.getPos().squaredDistanceTo(doubleMineVec) < 40000 && !Objects.equals(doubleMineVec, pos)){
198-
float progressFail = PlayerInteractionAccess.of(mc.interactionManager).getFailBreakMiningProgress();
199-
RenderUtils.setAsCurrentShaderColor(Color.MAGENTA, 1.0F);
200-
RenderUtils.drawOutlinedBox(renderEvent.context, doubleMineVec, doubleMineVec.add(1.0, 1.0, 1.0));
201-
if(progressFail > 0.0F){
202-
BlockState state = mc.world.getBlockState(doubleMinePos);
165+
if(mineRender.get()){
166+
RenderUtils.startDrawVirtual(renderEvent.context);
167+
try{
168+
if(mc.interactionManager != null && mc.player != null && mc.world != null){
169+
BlockPos blockPos = PlayerInteractionAccess.of(mc.interactionManager).getCurrentMiningPos();
170+
Vec3d pos =Vec3d.of(blockPos);
171+
//超过200格的不渲染
172+
if(mc.player.getPos().squaredDistanceTo(pos) < 40000){
173+
RenderUtils.setAsCurrentShaderColor(Color.BLUE, 1.0F);
174+
RenderUtils.drawOutlinedBox(renderEvent.context, pos, pos.add(1.0, 1.0, 1.0));
175+
float progress = PlayerInteractionAccess.of(mc.interactionManager).getCurrentMiningProgress(true);
176+
if(progress > 0.0F){
177+
BlockState state = mc.world.getBlockState(blockPos);
203178
Box box;
204179
if(state.isAir()){
205180
box = new Box(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
206181
}else{
207-
VoxelShape shape = state.getOutlineShape(mc.world, doubleMinePos);
182+
VoxelShape shape = state.getOutlineShape(mc.world, blockPos);
208183
box = shape.isEmpty()? new Box(0.0, 0.0, 0.0, 1.0, 1.0, 1.0): shape.getBoundingBox();
209184
}
210185
Vec3d vec3 = box.getMaxPos().subtract(box.getMinPos()).multiply(0.5);
211186

212-
RenderUtils.setAsCurrentShaderColor(Color.ORANGE, 0.25F);
213-
Vec3d vec3d = doubleMineVec.add(box.getCenter());
214-
float clamped = MathHelper.clamp(progressFail, 0.0F, 1.0F) ;
187+
RenderUtils.setAsCurrentShaderColor(Color.YELLOW, 0.25F);
188+
Vec3d vec3d = pos.add(box.getCenter());
189+
float clamped = MathHelper.clamp(progress, 0.0F, 1.0F) ;
215190
RenderUtils.drawSolidBox(renderEvent.context.peek().getPositionMatrix(), vec3d.add(vec3.multiply(-clamped)), vec3d.add(vec3.multiply(clamped)));
216191
}
217192
}
218193

219-
}
220194

195+
BlockPos doubleMinePos = PlayerInteractionAccess.of(mc.interactionManager).getCurrentFailBreakPos();
196+
if(doubleMinePos != null){
197+
Vec3d doubleMineVec = Vec3d.of(doubleMinePos);
198+
if(mc.player.getPos().squaredDistanceTo(doubleMineVec) < 40000 && !Objects.equals(doubleMineVec, pos)){
199+
float progressFail = PlayerInteractionAccess.of(mc.interactionManager).getFailBreakMiningProgress();
200+
RenderUtils.setAsCurrentShaderColor(Color.MAGENTA, 1.0F);
201+
RenderUtils.drawOutlinedBox(renderEvent.context, doubleMineVec, doubleMineVec.add(1.0, 1.0, 1.0));
202+
if(progressFail > 0.0F){
203+
BlockState state = mc.world.getBlockState(doubleMinePos);
204+
Box box;
205+
if(state.isAir()){
206+
box = new Box(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
207+
}else{
208+
VoxelShape shape = state.getOutlineShape(mc.world, doubleMinePos);
209+
box = shape.isEmpty()? new Box(0.0, 0.0, 0.0, 1.0, 1.0, 1.0): shape.getBoundingBox();
210+
}
211+
Vec3d vec3 = box.getMaxPos().subtract(box.getMinPos()).multiply(0.5);
212+
213+
RenderUtils.setAsCurrentShaderColor(Color.ORANGE, 0.25F);
214+
Vec3d vec3d = doubleMineVec.add(box.getCenter());
215+
float clamped = MathHelper.clamp(progressFail, 0.0F, 1.0F) ;
216+
RenderUtils.drawSolidBox(renderEvent.context.peek().getPositionMatrix(), vec3d.add(vec3.multiply(-clamped)), vec3d.add(vec3.multiply(clamped)));
217+
}
218+
}
219+
220+
}
221+
222+
}
223+
}finally {
224+
RenderUtils.stopDrawVirtual(renderEvent.context);
221225
}
222-
}finally {
223-
RenderUtils.stopDrawVirtual(renderEvent.context);
224226
}
225-
226227
}
227228

228229

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package me.matl114.hacks.modules.models;
2+
3+
import me.matl114.events.Event;
4+
import me.matl114.events.RenderListener;
5+
import me.matl114.hacks.api.BaseModule;
6+
import me.matl114.managers.Configs;
7+
import me.matl114.managers.config.ListRef;
8+
import me.matl114.utils.Debug;
9+
import net.minecraft.resource.ResourceManager;
10+
import net.minecraft.resource.ResourcePack;
11+
import net.minecraft.resource.ResourceType;
12+
import net.minecraft.util.Identifier;
13+
14+
import java.util.*;
15+
16+
public class CustomTextures extends BaseModule {
17+
public static final String[] CUSTOM_TEXTURE_PATTERN = {"texture-config", "namespace-for-custom-textures"};
18+
public CustomTextures() {
19+
20+
}
21+
22+
@Override
23+
public void registerAll() {
24+
super.registerAll();
25+
registerListener(RenderListener.getAtlasSourceSupply(), this::onAtlasSupply);
26+
}
27+
28+
public final ListRef customTexturePath = builder(Configs.MODEL_CONFIG, CUSTOM_TEXTURE_PATTERN, ListRef.TYPE)
29+
.defaultValue(List.of("ae2", "slimefunhelper", "infinityexpansion", "avaritia"))
30+
31+
.build();
32+
33+
public void onAtlasSupply(Event<Set<Identifier>> event){
34+
if(targetIdentifier.equals(event.getArgs(1))){
35+
Debug.info("Loading blocks atlases");
36+
Debug.info("Appending our textures automatically");
37+
event.context().addAll(loadOurselvesCustomModelTexture(event.getArgs(0)));
38+
}
39+
}
40+
41+
private static final String OUR_NAMESPACE = "slimefunhelper";
42+
public Collection<Identifier> loadOurselvesCustomModelTexture(ResourceManager manager){
43+
List<Identifier> textureIds = new ArrayList<>();
44+
Set<String> namespaces = new HashSet<>(customTexturePath.get());
45+
for(ResourcePack pack : manager.streamResourcePacks().toList()){
46+
//Debug.info("in resourcepack ",pack.getName());
47+
Set<String> namespacess= pack.getNamespaces(ResourceType.CLIENT_RESOURCES);
48+
for(String namespace : namespacess){
49+
if(OUR_NAMESPACE.equals(namespace) || namespaces.contains(namespace)){
50+
Debug.info("Force load TEXTURE in pack",pack.getId(),"and namespace",namespace);
51+
pack.findResources(ResourceType.CLIENT_RESOURCES,namespace,"textures",(i,j)->{
52+
String realNamespace=i.getNamespace();
53+
if(i.getPath().endsWith(".png")){
54+
String realPath=i.getPath().replaceFirst("^textures/","").replaceAll(".png$","");
55+
56+
Identifier shouldId=new Identifier(realNamespace,realPath);
57+
textureIds.add(shouldId);
58+
59+
}
60+
}
61+
);
62+
}
63+
}
64+
65+
66+
}
67+
return textureIds;
68+
}
69+
private static Identifier targetIdentifier = new Identifier("minecraft","blocks");
70+
}

0 commit comments

Comments
 (0)