Increased minecart max speed and boosted speed

master
Wynd 2024-08-18 18:46:02 +03:00
parent 4f2151e5c7
commit 9e9e91fb01
6 changed files with 63 additions and 4 deletions

View File

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

View File

@ -38,6 +38,10 @@ public class ModConfig {
"Allows dyed wool to be dyed back white using bone meal");
public static final Option<Boolean> ENABLE_GHASTS_INSTA_DEATH = make("Enable Ghast Insta Death", true,
"Allows ghasts to die in 1 shot when their fireballs get reflected at them");
public static final Option<Double> MINECART_MAX_SPEED = make("Minecart maximum speed limit", 0.5,
"Maximum allowed speed for minecarts\nVanilla default is 0.4");
public static final Option<Double> MINECART_POWERED_BOOST = make("Powered rails speed boost", 1.15,
"Extra speed modifier when minecarts go over powered rails\nVanilla default is 1.0");
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");

View File

@ -88,10 +88,10 @@ public class WyHelper {
}
public static void cheatCommand(Player player) {
// player.dropItem(new ItemInstance(ItemType.minecartFurnace, 1));
// player.dropItem(new ItemInstance(Tile.LADDER, 64));
// player.dropItem(new ItemInstance(ItemType.minecartChest, 1));
// player.dropItem(new ItemInstance(ItemType.coal, 64));
// player.dropItem(new ItemInstance(Tile.WOODEN_PRESSURE_PLATE, 2));
// player.dropItem(new ItemInstance(Tile.GOLDEN_RAIL, 64));
player.level.setLevelTime(0);
player.level.getProperties().setRaining(false);

View File

@ -0,0 +1,47 @@
package xyz.pixelatedw.finalbeta.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.Minecart;
import net.minecraft.tile.Tile;
import net.minecraft.util.maths.MathsHelper;
import xyz.pixelatedw.finalbeta.ModConfig;
@Mixin(Entity.class)
public class EntityMixin {
@ModifyVariable(method = "move(DDD)V", at = @At("HEAD"), ordinal = 0)
private double boostXSpeed(double xSpeed) {
Entity entity = ((Entity) (Object) this);
if (entity instanceof Minecart && !entity.field_1642) {
Minecart minecart = (Minecart) entity;
boostSpeed(minecart, xSpeed);
}
return xSpeed;
}
@ModifyVariable(method = "move(DDD)V", at = @At("HEAD"), ordinal = 2)
private double boostZSpeed(double zSpeed) {
Entity entity = ((Entity) (Object) this);
if (entity instanceof Minecart && !entity.field_1642) {
Minecart minecart = (Minecart) entity;
boostSpeed(minecart, zSpeed);
}
return zSpeed;
}
private double boostSpeed(Minecart minecart, double original) {
int x = MathsHelper.floor(minecart.x);
int y = MathsHelper.floor(minecart.y);
int z = MathsHelper.floor(minecart.z);
int tileId = minecart.level.getTileId(x, y, z);
if (tileId == Tile.GOLDEN_RAIL.id) {
double boostedSpeed = Math.min(original * ModConfig.MINECART_POWERED_BOOST.get(), ModConfig.MINECART_MAX_SPEED.get());
return boostedSpeed;
}
return original;
}
}

View File

@ -2,7 +2,9 @@ package xyz.pixelatedw.finalbeta.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@ -31,6 +33,11 @@ public class MinecartMixin {
}
}
@ModifyConstant(method = "tick", constant = @Constant(doubleValue = 0.4))
private double getSpeedLimit(final double speedLimit) {
return ModConfig.MINECART_MAX_SPEED.get();
}
@Inject(method = "tick", at = @At("TAIL"))
public void tick(CallbackInfo ci) {
Minecart minecart = (Minecart) (Object) this;

View File

@ -40,7 +40,8 @@
"CraftingContainerMixin",
"CraftingInventoryMixin",
"RecipeRegistryMixin",
"SnowballMixin"
"SnowballMixin",
"EntityMixin"
],
"injectors": {
"defaultRequire": -1