-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from legoraft/dev
Quick and dirty update to 1.21
- Loading branch information
Showing
16 changed files
with
201 additions
and
143 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,6 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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,74 +1,93 @@ | ||
package com.survivaltweaks; | ||
|
||
import dev.lambdaurora.spruceui.Position; | ||
import dev.lambdaurora.spruceui.option.SpruceBooleanOption; | ||
import dev.lambdaurora.spruceui.option.SpruceOption; | ||
import dev.lambdaurora.spruceui.screen.SpruceScreen; | ||
import dev.lambdaurora.spruceui.widget.SpruceButtonWidget; | ||
import dev.lambdaurora.spruceui.widget.container.SpruceOptionListWidget; | ||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.screen.option.GameOptionsScreen; | ||
import net.minecraft.client.gui.screen.option.OptionsScreen; | ||
import net.minecraft.client.gui.widget.ButtonWidget; | ||
import net.minecraft.client.gui.widget.CyclingButtonWidget; | ||
import net.minecraft.client.gui.widget.OptionListWidget; | ||
import net.minecraft.text.Text; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Properties; | ||
|
||
public class configScreen extends SpruceScreen { | ||
public class configScreen extends GameOptionsScreen { | ||
|
||
private final Screen parent; | ||
public Screen parent; | ||
|
||
private final SpruceOption survivalDebugStickToggle; | ||
private final SpruceOption endermanGriefToggle; | ||
private final SpruceOption noExpensiveToggle; | ||
private final SpruceOption cheapRenameToggle; | ||
private final SpruceOption noXpPenaltyToggle; | ||
public configScreen(Screen parent) { | ||
super(parent, null, Text.translatable("config.title")); | ||
|
||
public configScreen(@Nullable Screen parent) { | ||
super(Text.translatable("title.config")); | ||
this.parent = parent; | ||
} | ||
|
||
this.survivalDebugStickToggle = new SpruceBooleanOption("config.survivaldebugstick", () -> config.SURVIVAL_DEBUG_STICK, newValue -> config.SURVIVAL_DEBUG_STICK = newValue, Text.translatable("config.description.survivaldebugstick")); | ||
this.endermanGriefToggle = new SpruceBooleanOption("config.noendermangrief", () -> config.NO_ENDERMAN_GRIEF, newValue -> config.NO_ENDERMAN_GRIEF = newValue, Text.translatable("config.description.noendermagrief")); | ||
this.noExpensiveToggle = new SpruceBooleanOption("config.notooexpensive", () -> config.NO_EXPENSIVE, newValue -> config.NO_EXPENSIVE = newValue, Text.translatable("config.description.notooexpensive")); | ||
this.cheapRenameToggle = new SpruceBooleanOption("config.cheaprename", () -> config.CHEAP_RENAME, newValue -> config.CHEAP_RENAME = newValue, Text.translatable("config.description.cheaprename")); | ||
this.noXpPenaltyToggle = new SpruceBooleanOption("config.noxppenalty", () -> config.NO_XP_PENALTY, newValue -> config.NO_XP_PENALTY = newValue, Text.translatable("config.description.noxppenalty")); | ||
public CyclingButtonWidget survivalDebugStickToggle; | ||
public CyclingButtonWidget endermanGriefToggle; | ||
public CyclingButtonWidget noExpensiveToggle; | ||
public CyclingButtonWidget cheapRenameToggle; | ||
public CyclingButtonWidget noXpPenaltyToggle; | ||
public CyclingButtonWidget phantomMobCap; | ||
|
||
} | ||
public ButtonWidget doneButton; | ||
|
||
@Override | ||
protected void init() { | ||
super.init(); | ||
survivalDebugStickToggle = CyclingButtonWidget.onOffBuilder(config.SURVIVAL_DEBUG_STICK) | ||
.build(Text.translatable("config.survivaldebugstick"), ((button, value) -> config.SURVIVAL_DEBUG_STICK = !config.SURVIVAL_DEBUG_STICK)); | ||
|
||
endermanGriefToggle = CyclingButtonWidget.onOffBuilder(config.NO_ENDERMAN_GRIEF) | ||
.build(Text.translatable("config.noendermangrief"), (button, value) -> config.NO_ENDERMAN_GRIEF = !config.NO_ENDERMAN_GRIEF); | ||
|
||
noExpensiveToggle = CyclingButtonWidget.onOffBuilder(config.NO_EXPENSIVE) | ||
.build(Text.translatable("config.notooexpensive"), (button, value) -> config.NO_EXPENSIVE = !config.NO_EXPENSIVE); | ||
|
||
cheapRenameToggle = CyclingButtonWidget.onOffBuilder(config.CHEAP_RENAME) | ||
.build(Text.translatable("config.cheaprename"), (button, value) -> config.CHEAP_RENAME = !config.CHEAP_RENAME); | ||
|
||
SpruceOptionListWidget list = new SpruceOptionListWidget(Position.of(0, 34), this.width, this.height - 69); | ||
list.addOptionEntry(this.survivalDebugStickToggle, this.endermanGriefToggle); | ||
list.addOptionEntry(this.noExpensiveToggle, this.cheapRenameToggle); | ||
list.addOptionEntry(this.noXpPenaltyToggle, null); | ||
noXpPenaltyToggle = CyclingButtonWidget.onOffBuilder(config.NO_XP_PENALTY) | ||
.build(Text.translatable("config.noxppenalty"), ((button, value) -> config.NO_XP_PENALTY = !config.NO_XP_PENALTY)); | ||
|
||
this.addDrawableChild(list); | ||
phantomMobCap = CyclingButtonWidget.onOffBuilder(config.PHANTOM_MOBCAP) | ||
.build(Text.translatable("config.noxppenalty"), ((button, value) -> config.PHANTOM_MOBCAP = !config.PHANTOM_MOBCAP)); | ||
|
||
this.addDrawableChild(new SpruceButtonWidget(Position.of(this.width / 2 - 100, this.height - 30), 200, 20, Text.translatable("config.done"), button -> this.applyChanges())); | ||
OptionListWidget optionListWidget = this.addDrawableChild(new OptionListWidget(this.client, this.width, this)); | ||
|
||
optionListWidget.addWidgetEntry(survivalDebugStickToggle, endermanGriefToggle); | ||
optionListWidget.addWidgetEntry(noExpensiveToggle, cheapRenameToggle); | ||
optionListWidget.addWidgetEntry(noXpPenaltyToggle, phantomMobCap); | ||
|
||
doneButton = ButtonWidget | ||
.builder(Text.translatable("config.done"), button -> close()) | ||
.dimensions(width / 2 - 100, height - 25, 200, 20) | ||
.build(); | ||
|
||
addDrawableChild(doneButton); | ||
} | ||
|
||
@Override | ||
public void renderTitle(DrawContext context, int MouseX, int MouseY, float delta) { | ||
context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 8, 16777215); | ||
public void render(DrawContext context, int mouseX, int mouseY, float delta) { | ||
super.render(context, mouseX, mouseY, delta); | ||
context.drawCenteredTextWithShadow(textRenderer, super.title, width / 2, 12, 0xffffff); | ||
} | ||
|
||
@Override | ||
public void renderBackground(DrawContext context, int mouseX, int mouseY, float delta) { | ||
this.renderBackgroundTexture(context); | ||
protected void addOptions() { | ||
super.init(); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
this.client.setScreen(parent); | ||
assert this.client != null; | ||
|
||
applyChanges(); | ||
this.client.setScreen(this.parent); | ||
} | ||
|
||
public void applyChanges() { | ||
config config = survivalTweaks.CONFIG; | ||
Properties properties = new Properties(); | ||
config.write(properties); | ||
config.save(); | ||
this.client.setScreen(parent); | ||
config.save(survivalTweaks.CONFIG_PATH); | ||
} | ||
|
||
} |
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
25 changes: 25 additions & 0 deletions
25
src/main/java/com/survivaltweaks/mixin/anvilScreenHandlerMixin.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,25 @@ | ||
package com.survivaltweaks.mixin; | ||
|
||
import com.survivaltweaks.config; | ||
import net.minecraft.screen.AnvilScreenHandler; | ||
import net.minecraft.screen.Property; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.*; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(AnvilScreenHandler.class) | ||
public class anvilScreenHandlerMixin { | ||
|
||
@Shadow @Final private Property levelCost; | ||
|
||
@Inject(method = "updateResult", at = @At("TAIL")) | ||
private void setLevelCost(CallbackInfo ci) { | ||
int cost = levelCost.get(); | ||
|
||
if (cost > 5 && config.NO_EXPENSIVE) { | ||
levelCost.set(5); | ||
} | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
src/main/java/com/survivaltweaks/mixin/anvilScreenMixin.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.