Furnace minecarts pushing other minecarts and excess fuel dropping from them
parent
b90a18346d
commit
94ceb63a1f
|
@ -44,6 +44,8 @@ public class ModConfig {
|
|||
"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,
|
||||
"Makes the box model held by players and skeletons bigger and facing forward");
|
||||
|
|
|
@ -87,6 +87,10 @@ public class WyHelper {
|
|||
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) {
|
||||
// player.dropItem(new ItemInstance(Tile.LADDER, 64));
|
||||
// player.dropItem(new ItemInstance(ItemType.minecartChest, 1));
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.Minecart;
|
||||
import net.minecraft.entity.projectile.Arrow;
|
||||
import net.minecraft.item.ItemType;
|
||||
import net.minecraft.tile.RailTile;
|
||||
import net.minecraft.util.maths.Box;
|
||||
import net.minecraft.util.maths.MathsHelper;
|
||||
|
@ -23,6 +24,25 @@ public class MinecartMixin {
|
|||
|
||||
private static final double EXTRA_MINECART_XZ_SIZE = 0.4;
|
||||
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)
|
||||
public void onCollision(Entity other, CallbackInfoReturnable<Box> ci) {
|
||||
|
@ -31,6 +51,15 @@ public class MinecartMixin {
|
|||
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))
|
||||
|
|
Loading…
Reference in New Issue