Compare commits

...

3 Commits

8 changed files with 107 additions and 6 deletions

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.1.0 mod_version = 1.2.0
maven_group = xyz.pixelatedw.finalbeta maven_group = xyz.pixelatedw.finalbeta
archives_base_name = finalbeta archives_base_name = finalbeta

View File

@ -22,6 +22,8 @@ public class ModConfig {
"Disables id tags showing above entities in F3 mode"); "Disables id tags showing above entities in F3 mode");
public static final Option<Boolean> FENCE_SLIM_HITBOX = make("Slim Hitbox for Fences", true, 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)"); "Uses slim hitbox for fences on the X and Z axies (the height of the fence is not changed)");
public static final Option<Boolean> FENCE_CONNECT = make("Fence connections", true,
"Visually connects fences with nearby solid blocks");
public static final Option<Boolean> REMOVE_NIGHTMARES = make("Remove Nightmares", false, public static final Option<Boolean> REMOVE_NIGHTMARES = make("Remove Nightmares", false,
"Removes nightmares completely"); "Removes nightmares completely");
public static final Option<Boolean> DISABLE_BEDS = make("Disable Beds", false, public static final Option<Boolean> DISABLE_BEDS = make("Disable Beds", false,
@ -38,6 +40,12 @@ public class ModConfig {
"Allows dyed wool to be dyed back white using bone meal"); "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, 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"); "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> FURNACE_MINECART_PUSH = make("Enable furnace minecarts push", true,
"Enables furance minecarts to push forward the first minecart it comes in contact with");
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

@ -86,12 +86,16 @@ public class WyHelper {
public static float clamp(float val, float min, float max) { public static float clamp(float val, float min, float max) {
return val < min ? min : Math.min(val, max); return val < min ? min : Math.min(val, max);
} }
public static int clamp(int val, int min, int max) {
return val < min ? min : Math.min(val, max);
}
public static void cheatCommand(Player player) { 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.minecartChest, 1));
// player.dropItem(new ItemInstance(ItemType.coal, 64)); // 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.setLevelTime(0);
player.level.getProperties().setRaining(false); 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

@ -55,7 +55,7 @@ public class LivingEntityMixin {
@Inject(method = "travel", at = @At("HEAD")) @Inject(method = "travel", at = @At("HEAD"))
public void travel(float f, float f1, CallbackInfo ci) { public void travel(float f, float f1, CallbackInfo ci) {
LivingEntity entity = (LivingEntity) (Object) this; LivingEntity entity = (LivingEntity) (Object) this;
if (ModConfig.ADD_MORE_SOUNDS.get() && entity.isOnLadder() && entity.velocityY != 0 && entity.field_1645 % 20 == 0 && !entity.onGround) { if (ModConfig.ADD_MORE_SOUNDS.get() && entity.isOnLadder() && (entity.velocityY > 0.1 || entity.velocityY < -0.1) && entity.field_1645 % 15 == 0 && !entity.onGround) {
float pitch = WyHelper.clamp(0.85f + entity.level.rand.nextFloat() / 2, 0.0f, 1.0f); float pitch = WyHelper.clamp(0.85f + entity.level.rand.nextFloat() / 2, 0.0f, 1.0f);
entity.level.playSound(entity.x, entity.y, entity.z, "sound3.step.ladder", 0.3f, pitch); entity.level.playSound(entity.x, entity.y, entity.z, "sound3.step.ladder", 0.3f, pitch);
} }

View File

@ -2,7 +2,9 @@ package xyz.pixelatedw.finalbeta.mixin;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; 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.Inject;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@ -10,6 +12,7 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity; import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.Minecart; import net.minecraft.entity.Minecart;
import net.minecraft.entity.projectile.Arrow; import net.minecraft.entity.projectile.Arrow;
import net.minecraft.item.ItemType;
import net.minecraft.tile.RailTile; import net.minecraft.tile.RailTile;
import net.minecraft.util.maths.Box; import net.minecraft.util.maths.Box;
import net.minecraft.util.maths.MathsHelper; import net.minecraft.util.maths.MathsHelper;
@ -21,7 +24,26 @@ public class MinecartMixin {
private static final double EXTRA_MINECART_XZ_SIZE = 0.4; private static final double EXTRA_MINECART_XZ_SIZE = 0.4;
private static final double EXTRA_MINECART_Y_SIZE = 0.0; private static final double EXTRA_MINECART_Y_SIZE = 0.0;
private static final int COAL_FUEL = 1200;
@Inject(method = "damage", at = @At("HEAD"))
public void onDamage(Entity entity, int damage, CallbackInfoReturnable<Boolean> ci) {
Minecart minecart = ((Minecart) (Object) this);
if (!minecart.level.isClient && minecart.type == 2) {
int coal = minecart.fuel / COAL_FUEL;
if (coal > 0) {
while (coal > 0) {
if (coal < 64) {
minecart.dropItem(ItemType.coal.id, coal, 0.0F);
break;
}
minecart.dropItem(ItemType.coal.id, 64, 0.0F);
coal -= 64;
}
}
}
}
@Inject(method = "method_1379", at = @At("HEAD"), cancellable = true) @Inject(method = "method_1379", at = @At("HEAD"), cancellable = true)
public void onCollision(Entity other, CallbackInfoReturnable<Box> ci) { public void onCollision(Entity other, CallbackInfoReturnable<Box> ci) {
if (ModConfig.FIX_MINECART_STOPPING_ON_ITEMS.get()) { if (ModConfig.FIX_MINECART_STOPPING_ON_ITEMS.get()) {
@ -29,8 +51,22 @@ public class MinecartMixin {
ci.setReturnValue(null); ci.setReturnValue(null);
} }
} }
if (ModConfig.FURNACE_MINECART_PUSH.get()) {
Minecart minecart = ((Minecart) (Object) this);
if (minecart.type == 2 && other instanceof Minecart) {
Minecart otherMinecart = (Minecart) other;
otherMinecart.velocityX = minecart.pushX * 1.02;
otherMinecart.velocityZ = minecart.pushZ * 1.02;
}
}
} }
@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")) @Inject(method = "tick", at = @At("TAIL"))
public void tick(CallbackInfo ci) { public void tick(CallbackInfo ci) {
Minecart minecart = (Minecart) (Object) this; Minecart minecart = (Minecart) (Object) this;

View File

@ -13,6 +13,7 @@ import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.TileRenderer; import net.minecraft.client.render.TileRenderer;
import net.minecraft.level.TileView; import net.minecraft.level.TileView;
import net.minecraft.tile.Tile; import net.minecraft.tile.Tile;
import xyz.pixelatedw.finalbeta.ModConfig;
@Mixin(TileRenderer.class) @Mixin(TileRenderer.class)
public class TileRendererMixin { public class TileRendererMixin {
@ -26,6 +27,10 @@ public class TileRendererMixin {
// Fence renderer to handle it connecting with other non-fence blocks // Fence renderer to handle it connecting with other non-fence blocks
@Inject(method = "method_78", at = @At("HEAD"), cancellable = true) @Inject(method = "method_78", at = @At("HEAD"), cancellable = true)
public void fenceRenderer(Tile tile, int x, int y, int z, CallbackInfoReturnable<Boolean> cir) { public void fenceRenderer(Tile tile, int x, int y, int z, CallbackInfoReturnable<Boolean> cir) {
if (!ModConfig.FENCE_CONNECT.get()) {
return;
}
TileRenderer renderer = (TileRenderer) (Object) this; TileRenderer renderer = (TileRenderer) (Object) this;
int var5 = 0; int var5 = 0;

View File

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