More moves and compilation fixes
This commit is contained in:
@@ -24,6 +24,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
@@ -233,7 +234,7 @@ public class FluidTerminalScreen extends AEBaseMEScreen<FluidTerminalContainer>
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
|
||||
InputMappings.Input input = InputMappings.getInputByCode(keyCode, scanCode);
|
||||
InputUtil.Key input = InputMappings.getInputByCode(keyCode, scanCode);
|
||||
|
||||
if (keyCode != GLFW.GLFW_KEY_ESCAPE && !this.checkHotbarKeys(input)) {
|
||||
if (AppEng.proxy.isActionKey(ActionKey.TOGGLE_FOCUS, input)) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.Collections;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -41,8 +41,8 @@ public class FluidSlotWidget extends CustomSlotWidget {
|
||||
RenderSystem.disableBlend();
|
||||
final Fluid fluid = fs.getFluid();
|
||||
final FluidAttributes attributes = fluid.getAttributes();
|
||||
mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||
final Sprite sprite = mc.getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE)
|
||||
mc.getTextureManager().bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEX);
|
||||
final Sprite sprite = mc.getAtlasSpriteGetter(SpriteAtlasTexture.BLOCK_ATLAS_TEX)
|
||||
.apply(attributes.getStillTexture(fs.getFluidStack()));
|
||||
|
||||
// Set color for dynamic fluids
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.fabricmc.api.Environment;
|
||||
@@ -63,8 +63,8 @@ public class FluidTankWidget extends Widget implements ITooltip {
|
||||
RenderSystem.color3f(red, green, blue);
|
||||
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||
final Sprite sprite = mc.getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE)
|
||||
mc.getTextureManager().bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEX);
|
||||
final Sprite sprite = mc.getAtlasSpriteGetter(SpriteAtlasTexture.BLOCK_ATLAS_TEX)
|
||||
.apply(attributes.getStillTexture(fluidStack.getFluidStack()));
|
||||
|
||||
final int scaledHeight = (int) (this.height
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.Map;
|
||||
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.inventory.container.IContainerListener;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
@@ -24,7 +24,7 @@ import appeng.util.Platform;
|
||||
public abstract class FluidConfigurableContainer extends UpgradeableContainer implements IFluidSyncContainer {
|
||||
private FluidSyncHelper sync = null;
|
||||
|
||||
public FluidConfigurableContainer(ContainerType<?> containerType, int id, PlayerInventory ip, IUpgradeableHost te) {
|
||||
public FluidConfigurableContainer(ScreenHandlerType<?> containerType, int id, PlayerInventory ip, IUpgradeableHost te) {
|
||||
super(containerType, id, ip, te);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package appeng.fluids.container;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
@@ -18,7 +18,7 @@ import appeng.fluids.util.IAEFluidTank;
|
||||
|
||||
public class FluidFormationPlaneContainer extends FluidConfigurableContainer {
|
||||
|
||||
public static ContainerType<FluidFormationPlaneContainer> TYPE;
|
||||
public static ScreenHandlerType<FluidFormationPlaneContainer> TYPE;
|
||||
|
||||
private static final ContainerHelper<FluidFormationPlaneContainer, FluidFormationPlanePart> helper = new ContainerHelper<>(
|
||||
FluidFormationPlaneContainer::new, FluidFormationPlanePart.class, SecurityPermissions.BUILD);
|
||||
|
||||
@@ -20,7 +20,7 @@ package appeng.fluids.container;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
@@ -36,7 +36,7 @@ import appeng.fluids.util.IAEFluidTank;
|
||||
*/
|
||||
public class FluidIOContainer extends FluidConfigurableContainer {
|
||||
|
||||
public static ContainerType<FluidIOContainer> TYPE;
|
||||
public static ScreenHandlerType<FluidIOContainer> TYPE;
|
||||
|
||||
private static final ContainerHelper<FluidIOContainer, SharedFluidBusPart> helper = new ContainerHelper<>(
|
||||
FluidIOContainer::new, SharedFluidBusPart.class, SecurityPermissions.BUILD);
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.inventory.container.IContainerListener;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
|
||||
@@ -40,7 +40,7 @@ import appeng.util.Platform;
|
||||
|
||||
public class FluidInterfaceContainer extends FluidConfigurableContainer {
|
||||
|
||||
public static ContainerType<FluidInterfaceContainer> TYPE;
|
||||
public static ScreenHandlerType<FluidInterfaceContainer> TYPE;
|
||||
|
||||
private static final ContainerHelper<FluidInterfaceContainer, IFluidInterfaceHost> helper = new ContainerHelper<>(
|
||||
FluidInterfaceContainer::new, IFluidInterfaceHost.class, SecurityPermissions.BUILD);
|
||||
|
||||
@@ -3,7 +3,7 @@ package appeng.fluids.container;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
@@ -19,7 +19,7 @@ import appeng.fluids.util.IAEFluidTank;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class FluidLevelEmitterContainer extends FluidConfigurableContainer {
|
||||
public static ContainerType<FluidLevelEmitterContainer> TYPE;
|
||||
public static ScreenHandlerType<FluidLevelEmitterContainer> TYPE;
|
||||
|
||||
private static final ContainerHelper<FluidLevelEmitterContainer, FluidLevelEmitterPart> helper = new ContainerHelper<>(
|
||||
FluidLevelEmitterContainer::new, FluidLevelEmitterPart.class, SecurityPermissions.BUILD);
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.Iterator;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
@@ -53,7 +53,7 @@ import appeng.util.iterators.NullIterator;
|
||||
*/
|
||||
public class FluidStorageBusContainer extends FluidConfigurableContainer {
|
||||
|
||||
public static ContainerType<FluidStorageBusContainer> TYPE;
|
||||
public static ScreenHandlerType<FluidStorageBusContainer> TYPE;
|
||||
|
||||
private static final ContainerHelper<FluidStorageBusContainer, FluidStorageBusPart> helper = new ContainerHelper<>(
|
||||
FluidStorageBusContainer::new, FluidStorageBusPart.class);
|
||||
|
||||
@@ -27,7 +27,7 @@ import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.inventory.container.IContainerListener;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
@@ -85,7 +85,7 @@ import appeng.util.Platform;
|
||||
public class FluidTerminalContainer extends AEBaseContainer
|
||||
implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEFluidStack> {
|
||||
|
||||
public static ContainerType<FluidTerminalContainer> TYPE;
|
||||
public static ScreenHandlerType<FluidTerminalContainer> TYPE;
|
||||
|
||||
private static final ContainerHelper<FluidTerminalContainer, ITerminalHost> helper = new ContainerHelper<>(
|
||||
FluidTerminalContainer::new, ITerminalHost.class, SecurityPermissions.BUILD);
|
||||
|
||||
@@ -63,7 +63,7 @@ public class FluidCellConfig extends CellConfig {
|
||||
@Override
|
||||
public void setStackInSlot(int slot, @Nonnull ItemStack stack) {
|
||||
if (stack.isEmpty() || stack.getItem() instanceof FluidDummyItem) {
|
||||
super.setStackInSlot(slot, stack);
|
||||
super.setInvStack(slot, stack);
|
||||
}
|
||||
LazyOptional<FluidVolume> fluidOpt = FluidUtil.getFluidContained(stack);
|
||||
if (!fluidOpt.isPresent()
|
||||
@@ -76,7 +76,7 @@ public class FluidCellConfig extends CellConfig {
|
||||
ItemStack is = AEApi.instance().definitions().items().dummyFluidItem().maybeStack(1).get();
|
||||
FluidDummyItem item = (FluidDummyItem) is.getItem();
|
||||
item.setFluidStack(is, fluid);
|
||||
super.setStackInSlot(slot, is);
|
||||
super.setInvStack(slot, is);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.fluids.items;
|
||||
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
|
||||
import appeng.items.AEBaseItem;
|
||||
|
||||
/**
|
||||
* Dummy item to display the fluid Icon
|
||||
*
|
||||
* @author DrummerMC
|
||||
* @version rv6 - 2018-01-22
|
||||
* @since rv6 2018-01-22
|
||||
*/
|
||||
public class FluidDummyItem extends AEBaseItem {
|
||||
|
||||
public FluidDummyItem(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationKey(ItemStack stack) {
|
||||
FluidVolume fluidStack = this.getFluidStack(stack);
|
||||
if (fluidStack.isEmpty()) {
|
||||
fluidStack = new FluidVolume(Fluids.WATER, FluidAttributes.BUCKET_VOLUME);
|
||||
}
|
||||
return fluidStack.getTranslationKey();
|
||||
}
|
||||
|
||||
public FluidVolume getFluidStack(ItemStack is) {
|
||||
if (is.hasTag()) {
|
||||
CompoundTag tag = is.getTag();
|
||||
return FluidVolume.loadFluidStackFromNBT(tag);
|
||||
}
|
||||
return FluidVolume.EMPTY;
|
||||
}
|
||||
|
||||
public void setFluidStack(ItemStack is, FluidVolume fs) {
|
||||
if (fs.isEmpty()) {
|
||||
is.setTag(null);
|
||||
} else {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
fs.writeToNBT(tag);
|
||||
is.setTag(tag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items) {
|
||||
// Don't show this item in CreativeTabs
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import javax.annotation.Nonnull;
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
@@ -218,7 +218,7 @@ public class FluidFormationPlanePart extends AbstractFormationPlanePart<IAEFluid
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerType<?> getContainerType() {
|
||||
public ScreenHandlerType<?> getContainerType() {
|
||||
return FluidFormationPlaneContainer.TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ package appeng.fluids.parts;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
@@ -210,7 +210,7 @@ public class FluidInterfacePart extends BasicStatePart
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerType<?> getContainerType() {
|
||||
public ScreenHandlerType<?> getContainerType() {
|
||||
return FluidInterfaceContainer.TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.particles.RedstoneParticleData;
|
||||
import net.minecraft.particle.DustParticleEffect;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -275,7 +275,7 @@ public class FluidLevelEmitterPart extends UpgradeablePart
|
||||
final double d1 = d.yOffset * 0.45F + (r.nextFloat() - 0.5F) * 0.2D;
|
||||
final double d2 = d.zOffset * 0.45F + (r.nextFloat() - 0.5F) * 0.2D;
|
||||
|
||||
world.addParticle(RedstoneParticleData.REDSTONE_DUST, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1,
|
||||
world.addParticle(DustParticleEffect.REDSTONE_DUST, 0.5 + pos.getX() + d0, 0.5 + pos.getY() + d1,
|
||||
0.5 + pos.getZ() + d2, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.Identifier;
|
||||
@@ -438,7 +438,7 @@ public class FluidStorageBusPart extends SharedStorageBusPart
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerType<?> getContainerType() {
|
||||
public ScreenHandlerType<?> getContainerType() {
|
||||
return FluidStorageBusContainer.TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
package appeng.fluids.parts;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class FluidTerminalPart extends AbstractTerminalPart {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerType<?> getContainerType(PlayerEntity player) {
|
||||
public ScreenHandlerType<?> getContainerType(PlayerEntity player) {
|
||||
return FluidTerminalContainer.TYPE;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ public abstract class SharedFluidBusPart extends UpgradeablePart implements IGri
|
||||
private BlockEntity getBlockEntity(final BlockEntity self, final BlockPos pos) {
|
||||
final World w = self.getWorld();
|
||||
|
||||
if (w.getChunkProvider().isChunkLoaded(new ChunkPos(pos))) {
|
||||
if (w.getChunkManager().isChunkLoaded(new ChunkPos(pos))) {
|
||||
return w.getBlockEntity(pos);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.screen.ScreenHandlerType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
@@ -163,7 +163,7 @@ public class FluidInterfaceBlockEntity extends AENetworkBlockEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerType<?> getContainerType() {
|
||||
public ScreenHandlerType<?> getContainerType() {
|
||||
return FluidInterfaceContainer.TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +76,9 @@ public class AEFluidInventory implements IAEFluidTank {
|
||||
@Override
|
||||
public FluidVolume getFluidInTank(int tank) {
|
||||
if (tank < 0 || tank >= fluids.length) {
|
||||
return FluidVolume.EMPTY;
|
||||
return FluidVolumeUtil.EMPTY;
|
||||
}
|
||||
return fluids[tank] == null ? FluidVolume.EMPTY : fluids[tank].getFluidStack();
|
||||
return fluids[tank] == null ? FluidVolumeUtil.EMPTY : fluids[tank].getFluidStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,7 +88,7 @@ public class AEFluidInventory implements IAEFluidTank {
|
||||
|
||||
@Override
|
||||
public boolean isFluidValid(int tank, @Nonnull FluidVolume stack) {
|
||||
return stack != FluidVolume.EMPTY;
|
||||
return stack != FluidVolumeUtil.EMPTY;
|
||||
}
|
||||
|
||||
public int fill(final int slot, final FluidVolume resource, final boolean doFill) {
|
||||
@@ -162,12 +162,12 @@ public class AEFluidInventory implements IAEFluidTank {
|
||||
@Override
|
||||
public FluidVolume drain(final FluidVolume fluid, final FluidAction action) {
|
||||
if (fluid.isEmpty() || fluid.getAmount() <= 0) {
|
||||
return FluidVolume.EMPTY;
|
||||
return FluidVolumeUtil.EMPTY;
|
||||
}
|
||||
|
||||
final FluidVolume resource = fluid.copy();
|
||||
|
||||
FluidVolume totalDrained = FluidVolume.EMPTY;
|
||||
FluidVolume totalDrained = FluidVolumeUtil.EMPTY;
|
||||
for (int slot = 0; slot < this.getSlots(); ++slot) {
|
||||
FluidVolume drain = this.drain(slot, resource, action == FluidAction.EXECUTE);
|
||||
if (drain != null) {
|
||||
@@ -189,10 +189,10 @@ public class AEFluidInventory implements IAEFluidTank {
|
||||
@Override
|
||||
public FluidVolume drain(final int maxDrain, final FluidAction action) {
|
||||
if (maxDrain == 0) {
|
||||
return FluidVolume.EMPTY;
|
||||
return FluidVolumeUtil.EMPTY;
|
||||
}
|
||||
|
||||
FluidVolume totalDrained = FluidVolume.EMPTY;
|
||||
FluidVolume totalDrained = FluidVolumeUtil.EMPTY;
|
||||
int toDrain = maxDrain;
|
||||
|
||||
for (int slot = 0; slot < this.getSlots(); ++slot) {
|
||||
|
||||
@@ -1,265 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.fluids.util;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.fluids.items.FluidDummyItem;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEStack;
|
||||
|
||||
public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFluidStack, Comparable<AEFluidStack> {
|
||||
private static final String NBT_STACKSIZE = "cnt";
|
||||
private static final String NBT_REQUESTABLE = "req";
|
||||
private static final String NBT_CRAFTABLE = "craft";
|
||||
private static final String NBT_FLUID_ID = "f";
|
||||
private static final String NBT_FLUID_TAG = "ft";
|
||||
|
||||
private final Fluid fluid;
|
||||
private CompoundTag tagCompound;
|
||||
|
||||
private AEFluidStack(final AEFluidStack fluidStack) {
|
||||
this.fluid = fluidStack.fluid;
|
||||
this.setStackSize(fluidStack.getStackSize());
|
||||
|
||||
// priority = is.priority;
|
||||
this.setCraftable(fluidStack.isCraftable());
|
||||
this.setCountRequestable(fluidStack.getCountRequestable());
|
||||
|
||||
if (fluidStack.hasTagCompound()) {
|
||||
this.tagCompound = fluidStack.tagCompound.copy();
|
||||
}
|
||||
}
|
||||
|
||||
private AEFluidStack(@Nonnull Fluid fluid, long amount, @Nullable CompoundTag tag) {
|
||||
if (fluid == Fluids.EMPTY) {
|
||||
System.out.println();
|
||||
}
|
||||
this.fluid = Preconditions.checkNotNull(fluid);
|
||||
this.setStackSize(amount);
|
||||
this.setCraftable(false);
|
||||
this.setCountRequestable(0);
|
||||
this.tagCompound = tag;
|
||||
}
|
||||
|
||||
public static AEFluidStack fromFluidStack(final FluidVolume input) {
|
||||
if (input.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Fluid fluid = input.getFluid();
|
||||
if (fluid == null) {
|
||||
throw new IllegalArgumentException("Fluid is null.");
|
||||
}
|
||||
|
||||
long amount = input.getAmount();
|
||||
CompoundTag tag = null;
|
||||
if (input.getTag() != null) {
|
||||
tag = input.getTag().copy();
|
||||
}
|
||||
return new AEFluidStack(fluid, amount, tag);
|
||||
}
|
||||
|
||||
public static IAEFluidStack fromNBT(final CompoundTag data) {
|
||||
Identifier fluidId = new Identifier(data.getString(NBT_FLUID_ID));
|
||||
Fluid fluid = ForgeRegistries.FLUIDS.getValue(fluidId);
|
||||
if (fluid == null || fluid == Fluids.EMPTY) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CompoundTag tag = null;
|
||||
if (data.contains(NBT_FLUID_TAG, Constants.NBT.TAG_COMPOUND)) {
|
||||
tag = data.getCompound(NBT_FLUID_TAG);
|
||||
}
|
||||
|
||||
long amount = data.getLong(NBT_STACKSIZE);
|
||||
|
||||
AEFluidStack fluidStack = new AEFluidStack(fluid, amount, tag);
|
||||
fluidStack.setCountRequestable(data.getLong(NBT_REQUESTABLE));
|
||||
fluidStack.setCraftable(data.getBoolean(NBT_CRAFTABLE));
|
||||
return fluidStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(final IAEFluidStack option) {
|
||||
if (option == null) {
|
||||
return;
|
||||
}
|
||||
this.incStackSize(option.getStackSize());
|
||||
this.setCountRequestable(this.getCountRequestable() + option.getCountRequestable());
|
||||
this.setCraftable(this.isCraftable() || option.isCraftable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(final CompoundTag data) {
|
||||
data.putString(NBT_FLUID_ID, this.fluid.getRegistryName().toString());
|
||||
if (this.hasTagCompound()) {
|
||||
data.put(NBT_FLUID_TAG, this.tagCompound);
|
||||
}
|
||||
data.putLong(NBT_STACKSIZE, this.getStackSize());
|
||||
data.putLong(NBT_REQUESTABLE, this.getCountRequestable());
|
||||
data.putBoolean(NBT_CRAFTABLE, this.isCraftable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fuzzyComparison(final IAEFluidStack other, final FuzzyMode mode) {
|
||||
return this.fluid == other.getFluid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack copy() {
|
||||
return new AEFluidStack(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack empty() {
|
||||
final IAEFluidStack dup = this.copy();
|
||||
dup.reset();
|
||||
return dup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItem() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFluid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageChannel<IAEFluidStack> getChannel() {
|
||||
return AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final AEFluidStack other) {
|
||||
if (this.fluid != other.fluid) {
|
||||
return this.fluid.getRegistryName().compareTo(other.fluid.getRegistryName());
|
||||
}
|
||||
|
||||
if (Platform.itemComparisons().isNbtTagEqual(this.tagCompound, other.tagCompound)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this.tagCompound.hashCode() - other.tagCompound.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((this.fluid == null) ? 0 : this.fluid.hashCode());
|
||||
result = prime * result + ((this.tagCompound == null) ? 0 : this.tagCompound.hashCode());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object other) {
|
||||
if (other instanceof AEFluidStack) {
|
||||
final AEFluidStack is = (AEFluidStack) other;
|
||||
return is.fluid == this.fluid && Platform.itemComparisons().isNbtTagEqual(this.tagCompound, is.tagCompound);
|
||||
} else if (other instanceof FluidVolume) {
|
||||
final FluidVolume is = (FluidVolume) other;
|
||||
return is.getFluid() == this.fluid
|
||||
&& Platform.itemComparisons().isNbtTagEqual(this.tagCompound, is.getTag());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getStackSize() + "x" + this.getFluidStack().getFluid().getRegistryName() + " " + this.tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTagCompound() {
|
||||
return this.tagCompound != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidVolume getFluidStack() {
|
||||
final int amount = (int) Math.min(Integer.MAX_VALUE, this.getStackSize());
|
||||
final FluidVolume is = new FluidVolume(this.fluid, amount, this.tagCompound);
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fluid getFluid() {
|
||||
return this.fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack asItemStackRepresentation() {
|
||||
ItemStack is = AEApi.instance().definitions().items().dummyFluidItem().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
if (!is.isEmpty()) {
|
||||
FluidDummyItem item = (FluidDummyItem) is.getItem();
|
||||
item.setFluidStack(is, this.getFluidStack());
|
||||
return is;
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static IAEFluidStack fromPacket(final PacketByteBuf buffer) {
|
||||
final boolean isCraftable = buffer.readBoolean();
|
||||
final FluidVolume fluidStack = buffer.readFluidStack();
|
||||
|
||||
final long stackSize = buffer.readVarLong();
|
||||
final long countRequestable = buffer.readVarLong();
|
||||
|
||||
if (fluidStack.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final AEFluidStack fluid = AEFluidStack.fromFluidStack(fluidStack);
|
||||
fluid.setStackSize(stackSize);
|
||||
fluid.setCountRequestable(countRequestable);
|
||||
fluid.setCraftable(isCraftable);
|
||||
return fluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToPacket(final PacketByteBuf buffer) {
|
||||
buffer.writeBoolean(this.isCraftable());
|
||||
buffer.writeFluidStack(this.getFluidStack());
|
||||
buffer.writeVarLong(this.getStackSize());
|
||||
buffer.writeVarLong(this.getCountRequestable());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user