-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from RandmlyCoding/CustomizableFurnaceMinecart…
…sSpeed Made the minecart with furnace speed customizable
- Loading branch information
Showing
5 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
.../java/dev/symphony/harmony/mixin/transportation/minecarts/FurnaceMinecartEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package dev.symphony.harmony.mixin.transportation.minecarts; | ||
|
||
import dev.symphony.harmony.config.HarmonyConfig; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.entity.vehicle.AbstractMinecartEntity; | ||
import net.minecraft.entity.vehicle.FurnaceMinecartEntity; | ||
import net.minecraft.item.FuelRegistry; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.math.Vec3d; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
/** | ||
* FEATURE: Made Furnace Minecart speeds customizable. | ||
* @author RandomVideos | ||
*/ | ||
@Mixin(FurnaceMinecartEntity.class) | ||
public class FurnaceMinecartEntityMixin extends AbstractMinecartEntity { | ||
@Shadow private int fuel; | ||
@Shadow public Vec3d pushVec; | ||
|
||
protected FurnaceMinecartEntityMixin(EntityType<?> entityType, World world) {super(entityType, world);} | ||
|
||
@Inject(method = "getMaxSpeed",at= @At("RETURN"), cancellable = true) | ||
void ChangeFurnaceMinecartSpeed(ServerWorld world, CallbackInfoReturnable<Double> cir){ | ||
if(super.isTouchingWater()) | ||
cir.setReturnValue(super.getMaxSpeed(world) * HarmonyConfig.furnaceMinecartSpeedInWater); | ||
else | ||
cir.setReturnValue(super.getMaxSpeed(world) * HarmonyConfig.furnaceMinecartSpeed); | ||
} | ||
|
||
@Inject(method = "interact",at= @At(value = "HEAD"), cancellable = true) | ||
void AllowMoreFuels(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir){ | ||
ItemStack itemStack = player.getStackInHand(hand); | ||
FuelRegistry fuelRegistry = player.getWorld().getFuelRegistry(); | ||
if (fuelRegistry.isFuel(itemStack)) { | ||
if(fuelRegistry.getFuelTicks(itemStack)*2.25f+fuel < 32000) { | ||
itemStack.decrementUnlessCreative(1, player); | ||
this.fuel += (int) (fuelRegistry.getFuelTicks(itemStack)*2.25f); | ||
} | ||
} | ||
|
||
if (this.fuel > 0) { | ||
this.pushVec = this.getPos().subtract(player.getPos()).getHorizontal(); | ||
} | ||
|
||
cir.setReturnValue(ActionResult.SUCCESS); | ||
} | ||
|
||
@Override public ItemStack getPickBlockStack() {return new ItemStack(Items.FURNACE_MINECART);} | ||
@Override public Item asItem() {return Items.FURNACE_MINECART;} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters