-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
55 additions
and
2 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
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
50 changes: 50 additions & 0 deletions
50
src/main/java/mendedminecarts/mixin/HopperMinecartEntityMixin.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,50 @@ | ||
package mendedminecarts.mixin; | ||
|
||
import mendedminecarts.AbstractMinecartEntityAccess; | ||
import mendedminecarts.MendedMinecartsMod; | ||
import mendedminecarts.MinecartDisplayData; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.HopperBlock; | ||
import net.minecraft.entity.vehicle.HopperMinecartEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(HopperMinecartEntity.class) | ||
public class HopperMinecartEntityMixin { | ||
|
||
@Inject( | ||
method = "getDefaultContainedBlock", at = @At("RETURN"), cancellable = true | ||
) | ||
private void displayLockedHopperWhenLocked(CallbackInfoReturnable<BlockState> cir) { | ||
if (MendedMinecartsMod.VISUAL_HOPPER_CART_LOCKING.isEnabled() && this instanceof AbstractMinecartEntityAccess entityAccess) { | ||
MinecartDisplayData displayInfo = entityAccess.getDisplayInfo(); | ||
if (displayInfo == null) { | ||
return; | ||
} | ||
if (displayInfo.hopperLocked()) { | ||
BlockState disabledHopper = cir.getReturnValue(); | ||
disabledHopper = disabledHopper.withIfExists(HopperBlock.ENABLED, false); | ||
cir.setReturnValue(disabledHopper); | ||
} | ||
|
||
} | ||
} | ||
|
||
@Inject( | ||
method = "getDefaultBlockOffset", at = @At("RETURN"), cancellable = true | ||
) | ||
private void displayHopperLowerWhenLocked(CallbackInfoReturnable<Integer> cir) { | ||
if (MendedMinecartsMod.VISUAL_HOPPER_CART_LOCKING.isEnabled() && this instanceof AbstractMinecartEntityAccess entityAccess) { | ||
MinecartDisplayData displayInfo = entityAccess.getDisplayInfo(); | ||
if (displayInfo == null) { | ||
return; | ||
} | ||
if (displayInfo.hopperLocked()) { | ||
cir.setReturnValue(-1); | ||
} | ||
|
||
} | ||
} | ||
} |
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