Compare commits
2 Commits
22891a9692
...
c32eaeedb7
Author | SHA1 | Date |
---|---|---|
Shadowfacts | c32eaeedb7 | |
Shadowfacts | dd92515c2f |
|
@ -6,14 +6,17 @@ import net.minecraft.fluid.FluidState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
|
import net.minecraft.world.IWorld;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldView;
|
import net.minecraft.world.WorldView;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
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.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import net.shadowfacts.extrahoppers.util.FluidFlowControllable;
|
import net.shadowfacts.extrahoppers.util.DynamicFluidStateProvider;
|
||||||
import net.shadowfacts.extrahoppers.util.PositionedFluidStateProvider;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author shadowfacts
|
* @author shadowfacts
|
||||||
|
@ -31,8 +34,8 @@ public abstract class MixinBaseFluid {
|
||||||
private FluidState getUpdatedState(FluidState initial, WorldView world, BlockPos pos, BlockState state) {
|
private FluidState getUpdatedState(FluidState initial, WorldView world, BlockPos pos, BlockState state) {
|
||||||
BlockPos up = pos.up();
|
BlockPos up = pos.up();
|
||||||
BlockState upState = world.getBlockState(up);
|
BlockState upState = world.getBlockState(up);
|
||||||
if (upState.getBlock() instanceof PositionedFluidStateProvider) {
|
if (upState.getBlock() instanceof DynamicFluidStateProvider) {
|
||||||
return ((PositionedFluidStateProvider)upState.getBlock()).getFluidState(upState, world, up);
|
return ((DynamicFluidStateProvider)upState.getBlock()).getFluidState(upState, world, up);
|
||||||
}
|
}
|
||||||
return initial;
|
return initial;
|
||||||
}
|
}
|
||||||
|
@ -43,16 +46,33 @@ public abstract class MixinBaseFluid {
|
||||||
cancellable = true
|
cancellable = true
|
||||||
)
|
)
|
||||||
private void receivesFlow(Direction direction, BlockView world, BlockPos pos, BlockState state, BlockPos fromPos, BlockState fromState, CallbackInfoReturnable<Boolean> cir) {
|
private void receivesFlow(Direction direction, BlockView world, BlockPos pos, BlockState state, BlockPos fromPos, BlockState fromState, CallbackInfoReturnable<Boolean> cir) {
|
||||||
FluidFlowControllable.Result result = FluidFlowControllable.Result.DEFAULT;
|
DynamicFluidStateProvider.FlowResult result = DynamicFluidStateProvider.FlowResult.DEFAULT;
|
||||||
if (state.getBlock() instanceof FluidFlowControllable) {
|
if (state.getBlock() instanceof DynamicFluidStateProvider) {
|
||||||
result = ((FluidFlowControllable)state.getBlock()).allowsFlow(direction, state, world, pos);
|
result = ((DynamicFluidStateProvider)state.getBlock()).allowsFlow(direction, state, world, pos);
|
||||||
}
|
}
|
||||||
if (result != FluidFlowControllable.Result.DENY && fromState.getBlock() instanceof FluidFlowControllable) {
|
if (result != DynamicFluidStateProvider.FlowResult.DENY && fromState.getBlock() instanceof DynamicFluidStateProvider) {
|
||||||
result = ((FluidFlowControllable)fromState.getBlock()).allowsFlow(direction, fromState, world, fromPos);
|
result = ((DynamicFluidStateProvider)fromState.getBlock()).allowsFlow(direction, fromState, world, fromPos);
|
||||||
}
|
}
|
||||||
if (result != FluidFlowControllable.Result.DEFAULT) {
|
if (result != DynamicFluidStateProvider.FlowResult.DEFAULT) {
|
||||||
cir.setReturnValue(result == FluidFlowControllable.Result.ALLOW);
|
cir.setReturnValue(result == DynamicFluidStateProvider.FlowResult.ALLOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(
|
||||||
|
method = "onScheduledTick(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/fluid/FluidState;)V",
|
||||||
|
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"),
|
||||||
|
cancellable = true
|
||||||
|
)
|
||||||
|
private void onScheduledTick(World world, BlockPos pos, FluidState fluidState, CallbackInfo ci) {
|
||||||
|
BlockState state = world.getBlockState(pos);
|
||||||
|
if (state.getBlock() instanceof DynamicFluidStateProvider) {
|
||||||
|
((DynamicFluidStateProvider)state.getBlock()).setEmptyFluid(world, pos);
|
||||||
|
this.tryFlow(world, pos, fluidState);
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
protected abstract void tryFlow(IWorld world, BlockPos pos, FluidState state);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package net.shadowfacts.extrahoppers.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.fluid.Fluid;
|
||||||
|
import net.minecraft.fluid.Fluids;
|
||||||
|
import net.minecraft.item.BucketItem;
|
||||||
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.shadowfacts.extrahoppers.util.DynamicFluidStateProvider;
|
||||||
|
import org.objectweb.asm.Opcodes;
|
||||||
|
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.Redirect;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author shadowfacts
|
||||||
|
*/
|
||||||
|
@Mixin(BucketItem.class)
|
||||||
|
public abstract class MixinBucketItem {
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
private Fluid fluid;
|
||||||
|
|
||||||
|
@Redirect(
|
||||||
|
method = "placeFluid(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/hit/BlockHitResult;)Z",
|
||||||
|
at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/item/BucketItem;fluid:Lnet/minecraft/fluid/Fluid;", ordinal = 4)
|
||||||
|
)
|
||||||
|
private Fluid getFluid(BucketItem item, PlayerEntity player, World world, BlockPos pos, BlockHitResult result) {
|
||||||
|
if (world.getBlockState(pos).getBlock() instanceof DynamicFluidStateProvider) {
|
||||||
|
return Fluids.WATER;
|
||||||
|
} else {
|
||||||
|
return this.fluid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
import net.shadowfacts.extrahoppers.util.PositionedFluidStateProvider;
|
import net.shadowfacts.extrahoppers.util.DynamicFluidStateProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author shadowfacts
|
* @author shadowfacts
|
||||||
|
@ -26,8 +26,8 @@ public abstract class MixinWorldChunk implements Chunk {
|
||||||
public void getFluidState(int x, int y, int z, CallbackInfoReturnable<FluidState> cir) {
|
public void getFluidState(int x, int y, int z, CallbackInfoReturnable<FluidState> cir) {
|
||||||
BlockPos pos = new BlockPos(x, y, z);
|
BlockPos pos = new BlockPos(x, y, z);
|
||||||
BlockState state = getBlockState(pos);
|
BlockState state = getBlockState(pos);
|
||||||
if (state.getBlock() instanceof PositionedFluidStateProvider) {
|
if (state.getBlock() instanceof DynamicFluidStateProvider) {
|
||||||
FluidState fluidState = ((PositionedFluidStateProvider)state.getBlock()).getFluidState(state, world, pos);
|
FluidState fluidState = ((DynamicFluidStateProvider)state.getBlock()).getFluidState(state, world, pos);
|
||||||
cir.setReturnValue(fluidState);
|
cir.setReturnValue(fluidState);
|
||||||
cir.cancel();
|
cir.cancel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package net.shadowfacts.extrahoppers.util;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.fluid.FluidState;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.world.BlockView;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author shadowfacts
|
||||||
|
*/
|
||||||
|
public interface DynamicFluidStateProvider {
|
||||||
|
FluidState getFluidState(@NotNull BlockState state, @NotNull BlockView world, @NotNull BlockPos pos);
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
FlowResult allowsFlow(@NotNull Direction toSide, @NotNull BlockState state, @NotNull BlockView world, @NotNull BlockPos pos);
|
||||||
|
|
||||||
|
void setEmptyFluid(@NotNull World world, @NotNull BlockPos pos);
|
||||||
|
|
||||||
|
enum FlowResult {
|
||||||
|
ALLOW,
|
||||||
|
DENY,
|
||||||
|
DEFAULT
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,23 +0,0 @@
|
||||||
package net.shadowfacts.extrahoppers.util;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.Direction;
|
|
||||||
import net.minecraft.world.BlockView;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author shadowfacts
|
|
||||||
*/
|
|
||||||
public interface FluidFlowControllable {
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
Result allowsFlow(@NotNull Direction toSide, @NotNull BlockState state, @NotNull BlockView world, @NotNull BlockPos pos);
|
|
||||||
|
|
||||||
enum Result {
|
|
||||||
ALLOW,
|
|
||||||
DENY,
|
|
||||||
DEFAULT
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package net.shadowfacts.extrahoppers.util;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.fluid.FluidState;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.BlockView;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author shadowfacts
|
|
||||||
*/
|
|
||||||
public interface PositionedFluidStateProvider {
|
|
||||||
FluidState getFluidState(@NotNull BlockState state, @NotNull BlockView world, @NotNull BlockPos pos);
|
|
||||||
}
|
|
|
@ -1,18 +1,23 @@
|
||||||
package net.shadowfacts.extrahoppers
|
package net.shadowfacts.extrahoppers
|
||||||
|
|
||||||
import net.fabricmc.api.ClientModInitializer
|
import net.fabricmc.api.ClientModInitializer
|
||||||
|
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap
|
||||||
import net.fabricmc.fabric.api.client.screen.ContainerScreenFactory
|
import net.fabricmc.fabric.api.client.screen.ContainerScreenFactory
|
||||||
import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry
|
import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry
|
||||||
|
import net.minecraft.client.render.RenderLayer
|
||||||
import net.shadowfacts.extrahoppers.block.gold.GoldHopperContainer
|
import net.shadowfacts.extrahoppers.block.gold.GoldHopperContainer
|
||||||
import net.shadowfacts.extrahoppers.block.gold.GoldHopperScreen
|
import net.shadowfacts.extrahoppers.block.gold.GoldHopperScreen
|
||||||
import net.shadowfacts.extrahoppers.block.wood.WoodHopperContainer
|
import net.shadowfacts.extrahoppers.block.wood.WoodHopperContainer
|
||||||
import net.shadowfacts.extrahoppers.block.wood.WoodHopperScreen
|
import net.shadowfacts.extrahoppers.block.wood.WoodHopperScreen
|
||||||
|
import net.shadowfacts.extrahoppers.init.EHBlocks
|
||||||
|
|
||||||
object ExtraHoppersClient: ClientModInitializer {
|
object ExtraHoppersClient: ClientModInitializer {
|
||||||
|
|
||||||
override fun onInitializeClient() {
|
override fun onInitializeClient() {
|
||||||
ScreenProviderRegistry.INSTANCE.registerFactory(WoodHopperContainer.ID, ContainerScreenFactory(WoodHopperScreen.Companion::create))
|
ScreenProviderRegistry.INSTANCE.registerFactory(WoodHopperContainer.ID, ContainerScreenFactory(WoodHopperScreen.Companion::create))
|
||||||
ScreenProviderRegistry.INSTANCE.registerFactory(GoldHopperContainer.ID, ContainerScreenFactory(GoldHopperScreen.Companion::create))
|
ScreenProviderRegistry.INSTANCE.registerFactory(GoldHopperContainer.ID, ContainerScreenFactory(GoldHopperScreen.Companion::create))
|
||||||
|
|
||||||
|
BlockRenderLayerMap.INSTANCE.putBlock(EHBlocks.GRATE, RenderLayer.getCutout())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import net.fabricmc.fabric.api.block.FabricBlockSettings
|
||||||
import net.minecraft.block.*
|
import net.minecraft.block.*
|
||||||
import net.minecraft.block.enums.BlockHalf
|
import net.minecraft.block.enums.BlockHalf
|
||||||
import net.minecraft.entity.EntityContext
|
import net.minecraft.entity.EntityContext
|
||||||
|
import net.minecraft.entity.EntityType
|
||||||
import net.minecraft.fluid.Fluid
|
import net.minecraft.fluid.Fluid
|
||||||
import net.minecraft.fluid.FluidState
|
import net.minecraft.fluid.FluidState
|
||||||
import net.minecraft.fluid.Fluids
|
import net.minecraft.fluid.Fluids
|
||||||
|
@ -17,9 +18,9 @@ import net.minecraft.util.math.Direction
|
||||||
import net.minecraft.util.shape.VoxelShape
|
import net.minecraft.util.shape.VoxelShape
|
||||||
import net.minecraft.world.BlockView
|
import net.minecraft.world.BlockView
|
||||||
import net.minecraft.world.IWorld
|
import net.minecraft.world.IWorld
|
||||||
|
import net.minecraft.world.World
|
||||||
import net.shadowfacts.extrahoppers.block.base.BlockWithEntity
|
import net.shadowfacts.extrahoppers.block.base.BlockWithEntity
|
||||||
import net.shadowfacts.extrahoppers.util.FluidFlowControllable
|
import net.shadowfacts.extrahoppers.util.DynamicFluidStateProvider
|
||||||
import net.shadowfacts.extrahoppers.util.PositionedFluidStateProvider
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author shadowfacts
|
* @author shadowfacts
|
||||||
|
@ -30,15 +31,15 @@ class GrateBlock: BlockWithEntity<GrateBlockEntity>(
|
||||||
.sounds(BlockSoundGroup.METAL)
|
.sounds(BlockSoundGroup.METAL)
|
||||||
.nonOpaque()
|
.nonOpaque()
|
||||||
.build()
|
.build()
|
||||||
), PositionedFluidStateProvider, FluidFlowControllable, FluidFillable, FluidDrainable {
|
), DynamicFluidStateProvider, FluidFillable, FluidDrainable {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ID = Identifier("extrahoppers", "grate")
|
val ID = Identifier("extrahoppers", "grate")
|
||||||
|
|
||||||
val HALF = Properties.BLOCK_HALF
|
val HALF = Properties.BLOCK_HALF
|
||||||
|
|
||||||
val TOP_SHAPE = createCuboidShape(0.0, 15.0, 0.0, 16.0, 16.0, 16.0)
|
val TOP_SHAPE = createCuboidShape(0.0, 14.0, 0.0, 16.0, 16.0, 16.0)
|
||||||
val BOTTOM_SHAPE = createCuboidShape(0.0, 0.0, 0.0, 16.0, 1.0, 16.0)
|
val BOTTOM_SHAPE = createCuboidShape(0.0, 0.0, 0.0, 16.0, 2.0, 16.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -75,14 +76,46 @@ class GrateBlock: BlockWithEntity<GrateBlockEntity>(
|
||||||
|
|
||||||
override fun createBlockEntity(world: BlockView) = GrateBlockEntity()
|
override fun createBlockEntity(world: BlockView) = GrateBlockEntity()
|
||||||
|
|
||||||
|
override fun isTranslucent(state: BlockState, world: BlockView, pos: BlockPos): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isSimpleFullBlock(state: BlockState, world: BlockView, pos: BlockPos): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun allowsSpawning(state: BlockState, world: BlockView, pos: BlockPos, entityType: EntityType<*>): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
override fun getFluidState(state: BlockState, world: BlockView, pos: BlockPos): FluidState {
|
override fun getFluidState(state: BlockState, world: BlockView, pos: BlockPos): FluidState {
|
||||||
return getBlockEntity(world, pos)?.fluidState ?: Fluids.EMPTY.defaultState
|
return getBlockEntity(world, pos)?.fluidState ?: Fluids.EMPTY.defaultState
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun allowsFlow(toSide: Direction, state: BlockState, world: BlockView, pos: BlockPos): FluidFlowControllable.Result {
|
override fun setEmptyFluid(world: World, pos: BlockPos) {
|
||||||
return FluidFlowControllable.Result.ALLOW
|
val be = getBlockEntity(world, pos) ?: return
|
||||||
|
be.fluidState = null
|
||||||
|
if (!world.isClient) {
|
||||||
|
be.sync()
|
||||||
|
}
|
||||||
|
triggerFluidUpdate(world, pos, world.getBlockState(pos))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun allowsFlow(toSide: Direction, state: BlockState, world: BlockView, pos: BlockPos): DynamicFluidStateProvider.FlowResult {
|
||||||
|
return DynamicFluidStateProvider.FlowResult.ALLOW
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun neighborUpdate(state: BlockState, world: World, pos: BlockPos, block: Block, neighborPos: BlockPos, bl: Boolean) {
|
||||||
|
val fluidState = getFluidState(state, world, pos)
|
||||||
|
if (!fluidState.isEmpty) {
|
||||||
|
world.fluidTickScheduler.schedule(pos, fluidState.fluid, fluidState.fluid.getTickRate(world))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun triggerFluidUpdate(world: World, pos: BlockPos, state: BlockState) {
|
||||||
|
world.updateListeners(pos, state, state, 3)
|
||||||
|
world.updateNeighbors(pos, state.block)
|
||||||
|
}
|
||||||
|
|
||||||
// Fluid Fillable
|
// Fluid Fillable
|
||||||
|
|
||||||
|
@ -94,11 +127,14 @@ class GrateBlock: BlockWithEntity<GrateBlockEntity>(
|
||||||
override fun tryFillWithFluid(world: IWorld, pos: BlockPos, state: BlockState, fluidState: FluidState): Boolean {
|
override fun tryFillWithFluid(world: IWorld, pos: BlockPos, state: BlockState, fluidState: FluidState): Boolean {
|
||||||
val be = getBlockEntity(world, pos)
|
val be = getBlockEntity(world, pos)
|
||||||
return if (be != null) {
|
return if (be != null) {
|
||||||
|
be.fluidState = fluidState
|
||||||
if (!world.isClient) {
|
if (!world.isClient) {
|
||||||
be.fluidState = fluidState
|
|
||||||
world.fluidTickScheduler.schedule(pos, fluidState.fluid, fluidState.fluid.getTickRate(world))
|
world.fluidTickScheduler.schedule(pos, fluidState.fluid, fluidState.fluid.getTickRate(world))
|
||||||
be.sync()
|
be.sync()
|
||||||
}
|
}
|
||||||
|
if (world is World) {
|
||||||
|
triggerFluidUpdate(world, pos, state)
|
||||||
|
}
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
@ -109,10 +145,13 @@ class GrateBlock: BlockWithEntity<GrateBlockEntity>(
|
||||||
val be = getBlockEntity(world, pos) ?: return Fluids.EMPTY
|
val be = getBlockEntity(world, pos) ?: return Fluids.EMPTY
|
||||||
val fluidState = be.fluidState ?: return Fluids.EMPTY
|
val fluidState = be.fluidState ?: return Fluids.EMPTY
|
||||||
return if (fluidState.isStill) {
|
return if (fluidState.isStill) {
|
||||||
|
be.fluidState = null
|
||||||
if (!world.isClient) {
|
if (!world.isClient) {
|
||||||
be.fluidState = null
|
|
||||||
be.sync()
|
be.sync()
|
||||||
}
|
}
|
||||||
|
if (world is World) {
|
||||||
|
triggerFluidUpdate(world, pos, state)
|
||||||
|
}
|
||||||
fluidState.fluid
|
fluidState.fluid
|
||||||
} else {
|
} else {
|
||||||
Fluids.EMPTY
|
Fluids.EMPTY
|
||||||
|
|
|
@ -24,8 +24,10 @@ class GrateBlockEntity: BlockEntity(EHBlockEntities.GRATE), BlockEntityClientSer
|
||||||
|
|
||||||
override fun fromTag(tag: CompoundTag) {
|
override fun fromTag(tag: CompoundTag) {
|
||||||
super.fromTag(tag)
|
super.fromTag(tag)
|
||||||
if (tag.contains("fluid", NbtType.COMPOUND)) {
|
fluidState = if (tag.contains("fluid", NbtType.COMPOUND)) {
|
||||||
fluidState = NbtHelper.toBlockState(tag.getCompound("fluid")).fluidState
|
NbtHelper.toBlockState(tag.getCompound("fluid")).fluidState
|
||||||
|
} else {
|
||||||
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,9 +39,12 @@ class GrateBlockEntity: BlockEntity(EHBlockEntities.GRATE), BlockEntityClientSer
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun fromClientTag(tag: CompoundTag) {
|
override fun fromClientTag(tag: CompoundTag) {
|
||||||
if (tag.contains("fluid", NbtType.COMPOUND)) {
|
fluidState = if (tag.contains("fluid", NbtType.COMPOUND)) {
|
||||||
fluidState = NbtHelper.toBlockState(tag.getCompound("fluid")).fluidState
|
NbtHelper.toBlockState(tag.getCompound("fluid")).fluidState
|
||||||
|
} else {
|
||||||
|
null
|
||||||
}
|
}
|
||||||
|
world?.updateListeners(pos, cachedState, cachedState, 3)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,124 @@
|
||||||
{
|
{
|
||||||
"ambientocclusion": false,
|
"ambientocclusion": false,
|
||||||
"textures": {
|
"textures": {
|
||||||
"face": "extrahoppers:block/grate/face",
|
"face": "extrahoppers:block/grate",
|
||||||
"edge": "extrahoppers:block/grate/edge"
|
"edge": "extrahoppers:block/grate_edge",
|
||||||
|
"internal": "extrahoppers:block/grate_internal",
|
||||||
|
"particle": "#face"
|
||||||
},
|
},
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"from": [0, 15, 0],
|
"from": [0, 14, 0],
|
||||||
|
"to": [1, 16, 16],
|
||||||
|
"faces": {
|
||||||
|
"down": {"texture": "#face"},
|
||||||
|
"up": {"texture": "#face", "cullface": "up"},
|
||||||
|
"west": {"texture": "#edge", "cullface": "west"},
|
||||||
|
"east": {"texture": "#edge"},
|
||||||
|
"north": {"texture": "#edge", "cullface": "north"},
|
||||||
|
"south": {"texture": "#edge", "cullface": "south"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": [15, 14, 0],
|
||||||
"to": [16, 16, 16],
|
"to": [16, 16, 16],
|
||||||
"faces": {
|
"faces": {
|
||||||
"down": {"texture": "#face"},
|
"down": {"texture": "#face"},
|
||||||
"up": {"texture": "#face", "cullface": "up"},
|
"up": {"texture": "#face", "cullface": "up"},
|
||||||
|
"west": {"texture": "#edge"},
|
||||||
|
"east": {"texture": "#edge", "cullface": "east"},
|
||||||
"north": {"texture": "#edge", "cullface": "north"},
|
"north": {"texture": "#edge", "cullface": "north"},
|
||||||
"south": {"texture": "#edge", "cullface": "south"},
|
"south": {"texture": "#edge", "cullface": "south"}
|
||||||
"west": {"texture": "#edge", "cullface": "west"},
|
}
|
||||||
"east": {"texture": "#edge", "cullface": "east"}
|
},
|
||||||
|
{
|
||||||
|
"from": [1, 14, 0],
|
||||||
|
"to": [15, 16, 1],
|
||||||
|
"faces": {
|
||||||
|
"down": {"texture": "#face", "uv": [1, 0, 15, 1]},
|
||||||
|
"up": {"texture": "#face", "cullface": "up", "uv": [1, 0, 15, 1]},
|
||||||
|
"north": {"texture": "#edge"},
|
||||||
|
"south": {"texture": "#edge", "cullface": "south"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": [1, 14, 15],
|
||||||
|
"to": [15, 16, 16],
|
||||||
|
"faces": {
|
||||||
|
"down": {"texture": "#face", "uv": [1, 0, 15, 1]},
|
||||||
|
"up": {"texture": "#face", "cullface": "up", "uv": [1, 0, 15, 1]},
|
||||||
|
"north": {"texture": "#edge", "cullface": "north"},
|
||||||
|
"south": {"texture": "#edge"}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": [1, 14, 7],
|
||||||
|
"to": [2, 16, 9],
|
||||||
|
"faces": {
|
||||||
|
"down": {"texture": "#face", "uv": [1, 7, 2, 9]},
|
||||||
|
"up": {"texture": "#face", "cullface": "up", "uv": [1, 7, 2, 9]},
|
||||||
|
"north": {"texture": "#face", "uv": [1, 7, 2, 9]},
|
||||||
|
"south": {"texture": "#face", "uv": [1, 7, 2, 9]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": [2, 14, 1],
|
||||||
|
"to": [4, 16, 15],
|
||||||
|
"faces": {
|
||||||
|
"down": {"texture": "#face", "uv": [2, 1, 4, 15]},
|
||||||
|
"up": {"texture": "#face", "cullface": "up", "uv": [2, 1, 4, 15]},
|
||||||
|
"west": {"texture": "#internal", "uv": [1, 2, 15, 4]},
|
||||||
|
"east": {"texture": "#internal", "uv": [1, 2, 15, 4]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": [4, 14, 2],
|
||||||
|
"to": [7, 16, 4],
|
||||||
|
"faces": {
|
||||||
|
"down": {"texture": "#face", "uv": [4, 2, 7, 4]},
|
||||||
|
"up": {"texture": "#face", "cullface": "up", "uv": [4, 2, 7, 4]},
|
||||||
|
"north": {"texture": "#face", "uv": [4, 2, 7, 4]},
|
||||||
|
"south": {"texture": "#face", "uv": [4, 2, 7, 4]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": [7, 14, 1],
|
||||||
|
"to": [9, 16, 15],
|
||||||
|
"faces": {
|
||||||
|
"down": {"texture": "#face", "uv": [7, 1, 9, 15]},
|
||||||
|
"up": {"texture": "#face", "cullface": "up", "uv": [7, 1, 9, 15]},
|
||||||
|
"west": {"texture": "#internal", "uv": [1, 7, 15, 9]},
|
||||||
|
"east": {"texture": "#internal", "uv": [1, 7, 15, 9]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": [9, 14, 12],
|
||||||
|
"to": [12, 16, 14],
|
||||||
|
"faces": {
|
||||||
|
"down": {"texture": "#face", "uv": [9, 12, 12, 14]},
|
||||||
|
"up": {"texture": "#face", "cullface": "up", "uv": [9, 12, 12, 14]},
|
||||||
|
"north": {"texture": "#face", "uv": [9, 12, 12, 14]},
|
||||||
|
"south": {"texture": "#face", "uv": [9, 12, 12, 14]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": [12, 14, 1],
|
||||||
|
"to": [14, 16, 15],
|
||||||
|
"faces": {
|
||||||
|
"down": {"texture": "#face", "uv": [12, 1, 14, 15]},
|
||||||
|
"up": {"texture": "#face", "cullface": "up", "uv": [12, 1, 14, 15]},
|
||||||
|
"west": {"texture": "#internal", "uv": [1, 12, 15, 14]},
|
||||||
|
"east": {"texture": "#internal", "uv": [1, 12, 15, 14]}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"from": [14, 14, 7],
|
||||||
|
"to": [15, 16, 9],
|
||||||
|
"faces": {
|
||||||
|
"down": {"texture": "#face", "uv": [14, 7, 15, 9]},
|
||||||
|
"up": {"texture": "#face", "cullface": "up", "uv": [14, 7, 15, 9]},
|
||||||
|
"north": {"texture": "#face", "uv": [14, 7, 15, 9]},
|
||||||
|
"south": {"texture": "#face", "uv": [14, 7, 15, 9]}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
|
@ -3,8 +3,9 @@
|
||||||
"package": "net.shadowfacts.extrahoppers.mixin",
|
"package": "net.shadowfacts.extrahoppers.mixin",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"MixinWorldChunk",
|
"MixinBaseFluid",
|
||||||
"MixinBaseFluid"
|
"MixinBucketItem",
|
||||||
|
"MixinWorldChunk"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue