-
Notifications
You must be signed in to change notification settings - Fork 0
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
4 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
44 changes: 44 additions & 0 deletions
44
src/main/java/net/rober/robercarpet/mixin/FallingBlockMixin.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,44 @@ | ||
package net.rober.robercarpet.mixin; | ||
|
||
import net.minecraft.block.AbstractBlock; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.entity.FallingBlockEntity; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Vec3d; | ||
import net.rober.robercarpet.RoberCarpetSettings; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(FallingBlockEntity.class) | ||
public abstract class FallingBlockMixin { | ||
@Redirect(method = "tick()V",at=@At(value="INVOKE",target="Lnet/minecraft/block/BlockState;isOf(Lnet/minecraft/block/Block;)Z")) | ||
private boolean FallingBlockBehaviorMixin(BlockState blockHitResult, Block arg){ | ||
FallingBlockEntity self = (FallingBlockEntity) (Object) this; | ||
BlockPos pos = new BlockPos(self.getPos().getX(),Math.ceil(self.getPos().getY()),self.getPos().getZ()).down(); | ||
Block underneath = self.world.getBlockState(pos).getBlock(); | ||
return blockHitResult.isOf(arg)||(underneath==Blocks.AIR&& RoberCarpetSettings.OldFallingBehavior); | ||
} | ||
@Redirect(method="tick()V",at=@At(value="INVOKE",target = "Lnet/minecraft/util/math/Vec3d;multiply(DDD)Lnet/minecraft/util/math/Vec3d;",ordinal = 0)) | ||
private Vec3d FrictionMixin(Vec3d vec,double x,double y,double z){ | ||
FallingBlockEntity self = (FallingBlockEntity) (Object) this; | ||
BlockPos pos = new BlockPos(self.getPos().getX(),Math.ceil(self.getPos().getY()),self.getPos().getZ()).down(); | ||
Block underneath = self.world.getBlockState(pos).getBlock(); | ||
return underneath==Blocks.AIR&&RoberCarpetSettings.FallingBlockNoFrictionWithWalls?vec:vec.multiply(x,y,z); | ||
} | ||
|
||
@ModifyConstant(method = "tick()V",constant = @Constant(intValue = 600)) | ||
private int AgeMixin(int a){ | ||
if(RoberCarpetSettings.FallingBlockDieAge==-1) { | ||
return (int) Double.POSITIVE_INFINITY; | ||
} else if (RoberCarpetSettings.FallingBlockDieAge>0) { | ||
return RoberCarpetSettings.FallingBlockDieAge; | ||
} | ||
return 600; | ||
} | ||
|
||
} |
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