Skip to content

Commit

Permalink
Enhance compatibility for redstone chest/hopper minecart construction…
Browse files Browse the repository at this point in the history
…s (They are 100% vanilla now. The hook was changed to only apply to rideable minecarts)
  • Loading branch information
audaki committed Feb 20, 2023
1 parent 477546a commit 9ff409d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.1] - 2023-02-20
- Enhance compatibility for redstone chest/hopper minecart constructions (They are 100% vanilla now. The hook was changed to only apply to rideable minecarts)

## [2.0.0] - 2022-09-25
- Refactor infra to support multiple MC versions

## [1.0.2] - 2022-01-06
- Increase compatibility to other mods

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ yarn_mappings=1.19.3+build.5
loader_version=0.14.12

# Mod Properties
mod_version = v2.0.0
mod_version = v2.0.1
maven_group = audaki.minecraft
archives_base_name = audaki_cart_engine
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
import net.minecraft.entity.MovementType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
import net.minecraft.entity.vehicle.AbstractMinecartEntity.Type;
import net.minecraft.util.math.*;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
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.CallbackInfo;

import java.util.ArrayList;
import java.util.HashSet;
Expand All @@ -41,17 +45,26 @@ public AbstractMinecartEntityMixin(EntityType<?> type, World world) {
@Shadow
protected abstract double getMaxSpeed();

@Shadow
protected abstract Type getMinecartType();

@Shadow
private static Pair<Vec3i, Vec3i> getAdjacentRailPositionsByShape(RailShape shape) {
return null;
}

/**
* @author audaki
* @reason modify minecart behavior
*/
@Overwrite
public void moveOnRail(BlockPos pos, BlockState state) {
@Inject(at = @At("HEAD"), method = "moveOnRail", cancellable = true)
protected void moveOnRailOverwrite(BlockPos pos, BlockState state, CallbackInfo ci) {
// We only change logic for rideable minecarts so we don't break hopper/chest minecart creations
if (this.getMinecartType() != Type.RIDEABLE) {
return;
}

this.modifiedMoveOnRail(pos, state);
ci.cancel();
}

protected void modifiedMoveOnRail(BlockPos pos, BlockState state) {
this.onLanding();
double d = this.getX();
double e = this.getY();
Expand Down

0 comments on commit 9ff409d

Please sign in to comment.