OK, the bucket logic is... "better".

Renders fluid now...
This commit is contained in:
Flanks255 2022-01-06 18:40:19 -06:00
parent 99521c64a1
commit 66132ecdba
4 changed files with 17 additions and 13 deletions

View file

@ -24,6 +24,7 @@ import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fml.network.NetworkHooks;
import javax.annotation.Nullable;
@ -52,16 +53,17 @@ public class BlockCanolaPress extends BlockContainerBase {
@Override
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
if (!world.isClientSide) {
TileEntityCanolaPress tile = (TileEntityCanolaPress) world.getBlockEntity(pos);
if (tile != null) {
if (!this.tryUseItemOnTank(player, hand, tile.tank)) {
NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
}
}
return ActionResultType.PASS;
TileEntityCanolaPress tile = (TileEntityCanolaPress) world.getBlockEntity(pos);
if (tile == null)
return ActionResultType.PASS; //TODO this logic all needs to be rechecked...
if (world.isClientSide)
return ActionResultType.SUCCESS;
if (!player.isShiftKeyDown()) {
if (!FluidUtil.interactWithFluidHandler(player, hand, tile.tank))
NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
return ActionResultType.SUCCESS;
}
return super.use(state, world, pos, player, hand, hit);
return ActionResultType.PASS;
}
@Override

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.inventory;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
@ -22,6 +23,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import java.util.Objects;
import java.util.Optional;
public class ContainerCanolaPress extends Container {
@ -63,7 +65,8 @@ public class ContainerCanolaPress extends Container {
//Other Slots in Inventory excluded
if (slot >= inventoryStart) {
//Shift from Inventory
if (newStack.getItem() == ActuallyBlocks.CANOLA.getItem()) {
Optional<PressingRecipe> recipeOptional = TileEntityCanolaPress.getRecipeForInput(newStack);
if (recipeOptional.isPresent()) {
if (!this.moveItemStackTo(newStack, 0, 1, false)) {
return StackUtil.getEmpty();
}

View file

@ -93,8 +93,7 @@ public class FluidDisplay extends AbstractGui {
GlStateManager._disableAlphaTest();
GlStateManager._blendFuncSeparate(770, 771, 1, 0);
int i = this.fluidReference.getFluid().getAmount() * 83 / this.fluidReference.getCapacity();
blit(matrices, barX + 1, barY + 84 - i, 0, 0, 36, 172, 16, i, 16, 512);
//drawModalRectWithCustomSizedTexture(barX + 1, barY + 84 - i, 36, 172, 16, i, 16, 512);
this.blit(matrices, barX + 1, barY + 84 - i, 36, 172, 16, i); //drawModalRectWithCustomSizedTexture(barX + 1, barY + 84 - i, 36, 172, 16, i, 16, 512);
GlStateManager._disableBlend();
GlStateManager._enableAlphaTest();
GlStateManager._popMatrix();

View file

@ -139,7 +139,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IN
return getRecipeForInput(stack).isPresent();
}
public Optional<PressingRecipe> getRecipeForInput(ItemStack stack) {
public static Optional<PressingRecipe> getRecipeForInput(ItemStack stack) {
return ActuallyAdditionsAPI.PRESSING_RECIPES.stream().filter(recipe -> recipe.matches(new SingleItem(stack), null)).findFirst();
}