renewableBlackstone

This commit is contained in:
gnembon committed 2020-07-01 15:07:17 -03:00
1 parent c69f65e68e
commit 150c1d41a7
9 files changed
+69 -14

No files matched your search

@@ -0,0 +1,47 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.FluidBlock;
import net.minecraft.fluid.FlowableFluid;
import net.minecraft.tag.FluidTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import org.spongepowered.asm.mixin.Final;
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;
@Mixin(FluidBlock.class)
public abstract class FluidBlock_renewableBlackstoneMixin
{
@Shadow @Final protected FlowableFluid fluid;
@Shadow protected abstract void playExtinguishSound(WorldAccess world, BlockPos pos);
@Inject(method = "receiveNeighborFluids", at = @At("TAIL"), cancellable = true)
private void receiveFluidToBlackstone(World world, BlockPos pos, BlockState state, CallbackInfoReturnable<Boolean> cir)
{
if (CarpetSettings.renewableBlackstone)
{
if (fluid.isIn(FluidTags.LAVA)) {
for(Direction direction : Direction.values())
{
if (direction != Direction.DOWN) {
BlockPos blockPos = pos.offset(direction);
if (world.getBlockState(blockPos).isOf(Blocks.BLUE_ICE)) {
world.setBlockState(pos, Blocks.BLACKSTONE.getDefaultState());
playExtinguishSound(world, pos);
cir.setReturnValue(false);
}
}
}
}
}
}
}
@@ -63,7 +63,7 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
*/
// Cancel a while statement
@Redirect(method = "method_29741", at = @At(value = "FIELD", target = "Lnet/minecraft/server/MinecraftServer;running:Z"))
@Redirect(method = "runServer", at = @At(value = "FIELD", target = "Lnet/minecraft/server/MinecraftServer;running:Z"))
private boolean cancelRunLoop(MinecraftServer server)
{
return false;
@@ -72,7 +72,7 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
// Replaced the above cancelled while statement with this one
// could possibly just inject that mspt selection at the beginning of the loop, but then adding all mspt's to
// replace 50L will be a hassle
@Inject(method = "method_29741", at = @At(value = "INVOKE", shift = At.Shift.AFTER,
@Inject(method = "runServer", at = @At(value = "INVOKE", shift = At.Shift.AFTER,
target = "Lnet/minecraft/server/MinecraftServer;setFavicon(Lnet/minecraft/server/ServerMetadata;)V"))
private void modifiedRunLoop(CallbackInfo ci)
{
@@ -33,14 +33,14 @@ public class PortalForcer_portalSuffocationMixin
@Redirect(method = "usePortal", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/entity/Entity;positAfterTeleport(DDD)V"
target = "Lnet/minecraft/entity/Entity;refreshPositionAfterTeleport(DDD)V"
))
private void alternativeSetPositionAndAngles(Entity entity, double d, double e, double f)
{
if (CarpetSettings.portalSuffocationFix && CarpetSettings.fixedPosition != null)
entity.positAfterTeleport(CarpetSettings.fixedPosition.x, CarpetSettings.fixedPosition.y, CarpetSettings.fixedPosition.z);
entity.refreshPositionAfterTeleport(CarpetSettings.fixedPosition.x, CarpetSettings.fixedPosition.y, CarpetSettings.fixedPosition.z);
else
entity.positAfterTeleport(d, e, f);
entity.refreshPositionAfterTeleport(d, e, f);
}