Compare commits

...

4 Commits

10 changed files with 129 additions and 57 deletions

View File

@ -71,6 +71,18 @@ Real life days are calculated differently from the world time but are stored in
</details> </details>
<details><summary>Items can now be repaired at crafting tables</summary>
<video controls src="https://i.imgur.com/UrLHQDh.mp4" />
</details>
<details><summary>Dyed wool can be turned back into white wool using bone meal</summary>
<video controls src="https://i.imgur.com/Uwk3K2t.mp4" />
</details>
### Fixes ### Fixes
<details><summary>Fixes selected blocks being rendered under text in containers</summary> <details><summary>Fixes selected blocks being rendered under text in containers</summary>

View File

@ -9,6 +9,6 @@ plasma_build=22
api_version=1.1.0.1 api_version=1.1.0.1
# Mod Properties # Mod Properties
mod_version = 1.0.0 mod_version = 1.1.0
maven_group = xyz.pixelatedw.finalbeta maven_group = xyz.pixelatedw.finalbeta
archives_base_name = finalbeta archives_base_name = finalbeta

View File

@ -32,6 +32,10 @@ public class ModConfig {
"Allows the player to drop the entire stack they're holding using Shift + Q (or whatever drop key they have set)"); "Allows the player to drop the entire stack they're holding using Shift + Q (or whatever drop key they have set)");
public static final Option<Boolean> ENABLE_TIME_TRACKING = make("Enable Time Tracking", true, public static final Option<Boolean> ENABLE_TIME_TRACKING = make("Enable Time Tracking", true,
"Adds a Days Played entry in the F3 overlay displaying number of ingame days and real life days played in that world"); "Adds a Days Played entry in the F3 overlay displaying number of ingame days and real life days played in that world");
public static final Option<Boolean> ENABLE_REPAIR = make("Enable Item Repair", true,
"Allows 2 or more items of the same type to be repaired using a crafting table using the same formula as modern day vanilla uses");
public static final Option<Boolean> ENABLE_WHITE_WOOL_RECIPE = make("Enable White Wool Recipe", true,
"Allows dyed wool to be dyed back white using bone meal");
public static final Option<Boolean> FIX_BOW_MODEL = make("Fix bow model", true, public static final Option<Boolean> FIX_BOW_MODEL = make("Fix bow model", true,
"Makes the box model held by players and skeletons bigger and facing forward"); "Makes the box model held by players and skeletons bigger and facing forward");

View File

@ -2,11 +2,17 @@ package xyz.pixelatedw.finalbeta;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.time.Duration; import java.time.Duration;
import java.util.HashMap; import java.util.HashMap;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.Player; import net.minecraft.entity.player.Player;
import net.minecraft.item.ItemInstance;
import net.minecraft.item.ItemType;
import net.minecraft.recipe.RecipeRegistry;
import net.minecraft.tile.Tile;
import net.minecraft.tile.WoolTile;
public class WyHelper { public class WyHelper {
@ -31,10 +37,10 @@ public class WyHelper {
return INSTANCE; return INSTANCE;
} else { } else {
try { try {
Field f = Minecraft.class.getDeclaredField("instance"); Field f = Minecraft.class.getDeclaredFields()[1];
f.setAccessible(true); f.setAccessible(true);
return (Minecraft) f.get(null); return (Minecraft) f.get(null);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
@ -63,54 +69,25 @@ public class WyHelper {
return val < min ? min : Math.min(val, max); return val < min ? min : Math.min(val, max);
} }
public static void registerWhiteWoolRecipe() {
Method method = RecipeRegistry.class.getDeclaredMethods()[2];
method.setAccessible(true);
try {
// Makes new recipes for all colored wools so they can be dyed back white using bone meal
for (int colorId = 0; colorId < 16; ++colorId) {
method.invoke(RecipeRegistry.getInstance(), new ItemInstance(Tile.WOOL, 1, 0), new Object[]{
new ItemInstance(Tile.WOOL, 1, WoolTile.method_2(colorId)), new ItemInstance(ItemType.dyePowder, 1, 15)});
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void cheatCommand(Player player) { public static void cheatCommand(Player player) {
// player.level.setLevelTime(0);
// player.dropItem(new ItemInstance(Tile.LEVER, 1)); // player.level.getProperties().setRaining(false);
// player.level.getProperties().setRainTime(0);
// int x = MathsHelper.floor(player.x); // player.level.getProperties().setThundering(false);
// int y = MathsHelper.floor(player.boundingBox.minY); // player.level.getProperties().setThunderTime(0);
// int z = MathsHelper.floor(player.z);
// int lightLevel = player.level.getLightLevel(x, y, z);
// System.out.println(lightLevel);
// player.dropItem(new ItemInstance(ItemType.swordDiamond, 1));
// player.dropItem(new ItemInstance(Tile.TORCH, 64));
// player.dropItem(new ItemInstance(Tile.BED, 64));
// player.dropItem(new ItemInstance(Tile.FENCE, 64));
// player.dropItem(new ItemInstance(Tile.BUTTON, 64));
// player.dropItem(new ItemInstance(Tile.BOOKSHELF, 64));
// player.dropItem(new ItemInstance(Tile.SNOW));
// Random rand = new Random();
// player.level.playSound(player, "random.break", 1, (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F);
// player.dropItem(new ItemInstance(ItemType.hatchetDiamond, 1), false);
// player.dropItem(new ItemInstance(ItemType.shovelDiamond, 1), false);
// player.dropItem(new ItemInstance(Tile.CLAY, 128), false);
// player.dropItem(new ItemInstance(Tile.GOLD_ORE, 64), false);
// player.dropItem(new ItemInstance(ItemType.bow, 1), false);
// player.dropItem(new ItemInstance(ItemType.arrow, 64), false);
// player.dropItem(new ItemInstance(Tile.STONE, 64), false);
// player.level.playLevelEvent((Player)null, 1005, (int)player.x, (int)player.y, (int)player.z, 0);
// player.dropItem(new ItemInstance(Tile.REDSTONE_TORCH_LIT, 64), false);
// player.dropItem(new ItemInstance(Tile.RAIL, 64), false);
// player.dropItem(new ItemInstance(Tile.GOLDEN_RAIL, 64), false);
// player.dropItem(new ItemInstance(ItemType.saddle, 1));
//
// Pig animal = new Pig(player.level);
// animal.setPositionAndAngles(player.x + 2, player.y, player.z, 0.0f, 0.0f);
// player.level.spawnEntity(animal);
player.level.setLevelTime(0);
player.level.getProperties().setRaining(false);
player.level.getProperties().setRainTime(0);
player.level.getProperties().setThundering(false);
player.level.getProperties().setThunderTime(0);
} }
} }

View File

@ -0,0 +1,51 @@
package xyz.pixelatedw.finalbeta.mixin;
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.container.CraftingContainer;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemInstance;
import xyz.pixelatedw.finalbeta.ModConfig;
@Mixin(CraftingContainer.class)
public class CraftingContainerMixin {
@Inject(method = "onContentsChanged", at = @At("HEAD"), cancellable = true)
public void onContentsChanged(Inventory inventory, CallbackInfo ci) {
if (!ModConfig.ENABLE_REPAIR.get()) {
return;
}
CraftingContainer container = ((CraftingContainer)(Object)this);
ItemInstance resultItem = null;
int defaultDamage = 0;
int damage = 0;
for (int i = 0; i < inventory.getInvSize(); i++) {
ItemInstance item = inventory.getInvItem(i);
if (item != null && item.method_723() > 0) {
if (resultItem == null) {
resultItem = new ItemInstance(item.itemId, 1, item.getDamage());
defaultDamage = item.method_723() - item.getDamage();
} else if (item.itemId == resultItem.itemId) {
damage += item.method_723() - item.getDamage();
}
}
}
if (resultItem != null && damage > 0) {
int newDurability = (int) (defaultDamage + damage + Math.floor(resultItem.method_723() / 20));
newDurability = Math.min(newDurability, resultItem.method_723());
if (newDurability != defaultDamage) {
resultItem.setDamage(resultItem.method_723() - newDurability);
container.result.setInvItem(0, resultItem);
ci.cancel();
}
}
}
}

View File

@ -0,0 +1,25 @@
package xyz.pixelatedw.finalbeta.mixin;
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.container.Container;
import net.minecraft.inventory.CraftingInventory;
import xyz.pixelatedw.finalbeta.ModConfig;
import xyz.pixelatedw.finalbeta.WyHelper;
@Mixin(CraftingInventory.class)
public class CraftingInventoryMixin {
private static boolean hasCustomRecipesRegistered = false;
@Inject(method = "<init>", at = @At("TAIL"))
public void init(Container container, int x, int y, CallbackInfo ci) {
if (ModConfig.ENABLE_WHITE_WOOL_RECIPE.get() && !hasCustomRecipesRegistered) {
WyHelper.registerWhiteWoolRecipe();
hasCustomRecipesRegistered = true;
}
}
}

View File

@ -11,7 +11,7 @@ import xyz.pixelatedw.finalbeta.WyHelper;
@Mixin(Level.class) @Mixin(Level.class)
public class LevelMixin { public class LevelMixin {
@Inject(method = "method_242", at = @At(value = "INVOKE", target = "Lnet/minecraft/level/LevelMonsterSpawner;method_1870")) @Inject(method = "method_242", at = @At(value = "INVOKE", target = "Lnet/minecraft/level/LevelMonsterSpawner;method_1870(Lnet/minecraft/level/Level;ZZ)V"))
public void tick(CallbackInfo ci) { public void tick(CallbackInfo ci) {
WyHelper.playTime++; WyHelper.playTime++;
} }

View File

@ -17,7 +17,7 @@ import xyz.pixelatedw.finalbeta.ModConfig;
@Mixin(Minecraft.class) @Mixin(Minecraft.class)
public class MinecraftMixin { public class MinecraftMixin {
@Redirect(method = "init()V", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;create()V")) @Redirect(method = "init()V", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/Display;create()V"), remap = false)
public void createDisplay() throws LWJGLException { public void createDisplay() throws LWJGLException {
// Why the fuck is this even a thing ? What was its intended purpose ? I NEED TO KNOW // Why the fuck is this even a thing ? What was its intended purpose ? I NEED TO KNOW
Minecraft.field_2800 = null; Minecraft.field_2800 = null;

View File

@ -25,16 +25,17 @@ public class OverlayMixin extends DrawableHelper {
method = "render(FZII)V", method = "render(FZII)V",
at = @At( at = @At(
value = "INVOKE", value = "INVOKE",
target = "Lorg/lwjgl/opengl/GL11;glPopMatrix()V" target = "Lorg/lwjgl/opengl/GL11;glPopMatrix()V",
remap = false
), ),
slice = @Slice( slice = @Slice(
from = @At( from = @At(
value = "INVOKE", value = "INVOKE",
target = "drawTextWithShadow(Lnet/minecraft/client/render/TextRenderer;Ljava/lang/String;III)V" target = "Lnet/minecraft/client/gui/Overlay;drawTextWithShadow(Lnet/minecraft/client/render/TextRenderer;Ljava/lang/String;III)V"
), ),
to = @At( to = @At(
value = "FIELD", value = "FIELD",
target = "jukeboxMessageTime:I", target = "Lnet/minecraft/client/gui/Overlay;jukeboxMessageTime:I",
opcode = Opcodes.GETFIELD opcode = Opcodes.GETFIELD
) )
) )

View File

@ -36,7 +36,9 @@
"BoatMixin", "BoatMixin",
"LevelPropertiesMixin", "LevelPropertiesMixin",
"LevelMixin", "LevelMixin",
"DoorTileMixin" "DoorTileMixin",
"CraftingContainerMixin",
"CraftingInventoryMixin"
], ],
"injectors": { "injectors": {
"defaultRequire": -1 "defaultRequire": -1