Shift for unmounting vehicles, drop entire stacks and multiple ways to handle boat breaking

master
Wynd 2024-01-07 02:30:52 +02:00
parent 456c2f9006
commit 801429d27f
7 changed files with 114 additions and 25 deletions

View File

@ -20,14 +20,16 @@ public class ModConfig {
public static final Option<Boolean> ENABLE_CLOUDS = make("Enable Clouds", true, "Enables the rendering of clouds");
public static final Option<Boolean> DISABLE_ID_TAGS = make("Disable ID Tags", true,
"Disables id tags showing above entities in F3 mode");
public static final Option<Boolean> BOOKSHELVES_DROP = make("Bookshelves Drops", true,
"Drops 3 books when breaking a bookshelf");
public static final Option<Boolean> FENCE_SLIM_HITBOX = make("Slim Hitbox for Fences", true,
"Uses slim hitbox for fences on the X and Z axies (the height of the fence is not changed)");
public static final Option<Boolean> REMOVE_NIGHTMARES = make("Remove Nightmares", false,
"Removes nightmares completely");
public static final Option<Boolean> DISABLE_BEDS = make("Disable Beds", false,
"Disables bed mechanics such as setting spawn points and skipping the night, does NOT delete already placed blocks nor does it disable the crafting or placing of beds as decorative blocks");
public static final Option<Integer> BOAT_BREAKING_LOGIC = make("Boat Breaking Logic", 2,
"0 - Vanilla behavior\n1 - Boats will never break regardless of their speed\n2 - Boats will only break when crashing with almost max speed");
public static final Option<Boolean> STACK_DROP = make("Drop Held Stack", true,
"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> FIX_BOW_MODEL = make("Fix bow model", true,
"Makes the box model held by players and skeletons bigger and facing forward");
@ -47,6 +49,8 @@ public class ModConfig {
"Fixes saddles not dropping when killing saddled pigs");
public static final Option<Boolean> FIX_FURNACE_LAVA_BUCKET = make("Fix furnace lava bucket", true,
"Fixes furnaces consuming the bucket when using lava buckets as fuel");
public static final Option<Boolean> FIX_BOOKSHELVES_DROP = make("Fix Bookshelves Drops", true,
"Drops 3 books when breaking a bookshelf");
private static ModConfig instance = new ModConfig();
public static final ModConfig instance() {

View File

@ -6,6 +6,8 @@ import java.time.Duration;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.Player;
import net.minecraft.item.ItemInstance;
import net.minecraft.item.ItemType;
import net.minecraft.stat.Stats;
public class WyHelper {
@ -54,6 +56,8 @@ public class WyHelper {
public static void cheatCommand(Player player) {
player.dropItem(new ItemInstance(ItemType.boat, 1));
// int x = MathsHelper.floor(player.x);
// int y = MathsHelper.floor(player.boundingBox.minY);
// int z = MathsHelper.floor(player.z);
@ -88,14 +92,16 @@ public class WyHelper {
// player.dropItem(new ItemInstance(Tile.RAIL, 64), false);
// player.dropItem(new ItemInstance(Tile.GOLDEN_RAIL, 64), false);
// Zombie enemy = new Zombie(player.level);
// enemy.setPositionAndAngles(player.x + 2, player.y, player.z, 0.0f, 0.0f);
// player.level.spawnEntity(enemy);
// 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);
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,49 @@
package xyz.pixelatedw.finalbeta.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.entity.Boat;
import xyz.pixelatedw.finalbeta.ModConfig;
@Mixin(Boat.class)
public class BoatMixin {
@Inject(method = "tick", at = @At(value = "INVOKE", target = "Ljava/lang/Math;sqrt(D)D", shift = Shift.AFTER))
public void boatVelocityCheck(CallbackInfo ci) {
Boat boat = ((Boat) (Object) this);
/*
* This randomly named field_1624 is actually the horizontal collision
* check, which we're setting to false before the vanilla check happens
* if the boat is set to survive the impact from our checks.
*
* Do note that they way the boat collision check happens is that the
* boat gets slowed down first, and then the velocity check is
* performed, by default a velocity check is 0.15, we're raising that
* limit to 0.22.
*/
if (this.isCollidingHorizontally(boat) && this.canSurvive(boat)) {
((Boat) (Object) this).field_1624 = false;
}
}
private boolean canSurvive(Boat boat) {
double velocity = Math.sqrt(boat.velocityX * boat.velocityX + boat.velocityZ * boat.velocityZ);
boolean survives = false;
if (ModConfig.BOAT_BREAKING_LOGIC.get() == 1) {
survives = true;
} else if (ModConfig.BOAT_BREAKING_LOGIC.get() == 2 && velocity < 0.22) {
survives = true;
}
return survives;
}
private boolean isCollidingHorizontally(Boat boat) {
return ((Boat) (Object) this).field_1624;
}
}

View File

@ -22,14 +22,14 @@ public class BookshelfTileMixin extends Tile {
@Inject(method = "getDropCount", at = @At("HEAD"), cancellable = true)
public void getDropCount(Random random, CallbackInfoReturnable<Integer> cir) {
if (ModConfig.BOOKSHELVES_DROP.get()) {
if (ModConfig.FIX_BOOKSHELVES_DROP.get()) {
cir.setReturnValue(3);
}
}
@Override
public int getDropId(int i, Random random) {
if (ModConfig.BOOKSHELVES_DROP.get()) {
if (ModConfig.FIX_BOOKSHELVES_DROP.get()) {
return ItemType.book.id;
}

View File

@ -8,10 +8,12 @@ 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.client.Minecraft;
import net.minecraft.container.ChestContainer;
import net.minecraft.entity.player.ClientPlayer;
import net.minecraft.entity.player.Player;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemInstance;
import xyz.pixelatedw.finalbeta.ModConfig;
import xyz.pixelatedw.finalbeta.WyHelper;
@ -22,9 +24,25 @@ public class ClientPlayerMixin {
@Inject(method = "method_136", at = @At("TAIL"))
public void onKeyPressed(int key, boolean state, CallbackInfo ci) {
if (WyHelper.isDebug() && key == Keyboard.KEY_Z && state) {
Minecraft mc = WyHelper.getInstance();
Player player = (Player) (Object) this;
if (player.vehicle != null && key == Keyboard.KEY_LSHIFT) {
player.startRiding(null);
return;
}
if (ModConfig.STACK_DROP.get() && key == mc.options.dropKey.key && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
ItemInstance heldItem = player.inventory.getHeldItem();
if (heldItem != null && heldItem.count > 0) {
player.dropItem(player.inventory.takeInvItem(player.inventory.selectedHotbarSlot, heldItem.count), false);
return;
}
}
if (WyHelper.isDebug() && key == Keyboard.KEY_Z && state) {
WyHelper.cheatCommand(player);
return;
}
}

View File

@ -6,6 +6,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.animal.Chicken;
import net.minecraft.entity.animal.Pig;
import net.minecraft.item.ItemType;
import xyz.pixelatedw.finalbeta.ModConfig;
@ -13,6 +14,16 @@ import xyz.pixelatedw.finalbeta.ModConfig;
@Mixin(LivingEntity.class)
public class LivingEntityMixin {
@Inject(method = "setSize", at = @At("HEAD"), cancellable = true)
public void setSize(float f, float f1, CallbackInfo ci) {
LivingEntity entity = (LivingEntity) (Object) this;
if (entity instanceof Chicken) {
entity.width = 0.3F;
entity.height = 0.7F;
ci.cancel();
}
}
@Inject(method = "dropLoot", at = @At("TAIL"))
public void dropLoot(CallbackInfo ci) {
if (ModConfig.FIX_SADDLES_NOT_DROPPING.get()) {

View File

@ -32,7 +32,8 @@
"BookshelfTileMixin",
"FenceTileMixin",
"LevelMonsterSpawnerMixin",
"BedTileMixin"
"BedTileMixin",
"BoatMixin"
],
"injectors": {
"defaultRequire": -1