mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
OK, the bucket logic is... "better".
Renders fluid now...
This commit is contained in:
parent
99521c64a1
commit
66132ecdba
4 changed files with 17 additions and 13 deletions
|
@ -24,6 +24,7 @@ import net.minecraft.util.math.shapes.ISelectionContext;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.world.IBlockReader;
|
import net.minecraft.world.IBlockReader;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.fluids.FluidUtil;
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -52,16 +53,17 @@ public class BlockCanolaPress extends BlockContainerBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
public ActionResultType use(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
|
||||||
if (!world.isClientSide) {
|
TileEntityCanolaPress tile = (TileEntityCanolaPress) world.getBlockEntity(pos);
|
||||||
TileEntityCanolaPress tile = (TileEntityCanolaPress) world.getBlockEntity(pos);
|
if (tile == null)
|
||||||
if (tile != null) {
|
return ActionResultType.PASS; //TODO this logic all needs to be rechecked...
|
||||||
if (!this.tryUseItemOnTank(player, hand, tile.tank)) {
|
if (world.isClientSide)
|
||||||
NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
|
return ActionResultType.SUCCESS;
|
||||||
}
|
if (!player.isShiftKeyDown()) {
|
||||||
}
|
if (!FluidUtil.interactWithFluidHandler(player, hand, tile.tank))
|
||||||
return ActionResultType.PASS;
|
NetworkHooks.openGui((ServerPlayerEntity) player, tile, pos);
|
||||||
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
return super.use(state, world, pos, player, hand, hit);
|
return ActionResultType.PASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.inventory;
|
package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
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.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
@ -22,6 +23,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.network.PacketBuffer;
|
import net.minecraft.network.PacketBuffer;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class ContainerCanolaPress extends Container {
|
public class ContainerCanolaPress extends Container {
|
||||||
|
|
||||||
|
@ -63,7 +65,8 @@ public class ContainerCanolaPress extends Container {
|
||||||
//Other Slots in Inventory excluded
|
//Other Slots in Inventory excluded
|
||||||
if (slot >= inventoryStart) {
|
if (slot >= inventoryStart) {
|
||||||
//Shift from Inventory
|
//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)) {
|
if (!this.moveItemStackTo(newStack, 0, 1, false)) {
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,8 +93,7 @@ public class FluidDisplay extends AbstractGui {
|
||||||
GlStateManager._disableAlphaTest();
|
GlStateManager._disableAlphaTest();
|
||||||
GlStateManager._blendFuncSeparate(770, 771, 1, 0);
|
GlStateManager._blendFuncSeparate(770, 771, 1, 0);
|
||||||
int i = this.fluidReference.getFluid().getAmount() * 83 / this.fluidReference.getCapacity();
|
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);
|
this.blit(matrices, barX + 1, barY + 84 - i, 36, 172, 16, i); //drawModalRectWithCustomSizedTexture(barX + 1, barY + 84 - i, 36, 172, 16, i, 16, 512);
|
||||||
//drawModalRectWithCustomSizedTexture(barX + 1, barY + 84 - i, 36, 172, 16, i, 16, 512);
|
|
||||||
GlStateManager._disableBlend();
|
GlStateManager._disableBlend();
|
||||||
GlStateManager._enableAlphaTest();
|
GlStateManager._enableAlphaTest();
|
||||||
GlStateManager._popMatrix();
|
GlStateManager._popMatrix();
|
||||||
|
|
|
@ -139,7 +139,7 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IN
|
||||||
return getRecipeForInput(stack).isPresent();
|
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();
|
return ActuallyAdditionsAPI.PRESSING_RECIPES.stream().filter(recipe -> recipe.matches(new SingleItem(stack), null)).findFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue