-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent lava from loading chunks (#491)
- Loading branch information
1 parent
f413e28
commit 7a5129f
Showing
3 changed files
with
57 additions
and
0 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
48 changes: 48 additions & 0 deletions
48
src/main/java/com/mitchej123/hodgepodge/mixins/early/minecraft/MixinBlockStaticLiquid.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,48 @@ | ||
package com.mitchej123.hodgepodge.mixins.early.minecraft; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockStaticLiquid; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraft.world.World; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(BlockStaticLiquid.class) | ||
public class MixinBlockStaticLiquid { | ||
|
||
@Redirect( | ||
method = "updateTick", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlock(III)Lnet/minecraft/block/Block;")) | ||
public Block wrapperUpdateTickGetBlock(World world, int x, int y, int z) { | ||
if (!world.blockExists(x, y, z)) { | ||
// return something that isn't air, but also doesn't block movement so that the loop continues | ||
return Blocks.grass; | ||
} else { | ||
return world.getBlock(x, y, z); | ||
} | ||
} | ||
|
||
@Redirect(method = "updateTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isAirBlock(III)Z")) | ||
public boolean wrapperUpdateTickIsAirBlock(World world, int x, int y, int z) { | ||
if (!world.blockExists(x, y, z)) { | ||
// return false so that this.isFlammable doesn't run | ||
return false; | ||
} else { | ||
return world.isAirBlock(x, y, z); | ||
} | ||
} | ||
|
||
@Redirect( | ||
method = "isFlammable", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlock(III)Lnet/minecraft/block/Block;")) | ||
public Block wrapperIsFlammableGetBlock(World world, int x, int y, int z) { | ||
if (!world.blockExists(x, y, z)) { | ||
// return something that isn't flammable so that the or's short circuit | ||
return Blocks.air; | ||
} else { | ||
return world.getBlock(x, y, z); | ||
} | ||
} | ||
} |