Add filter, refactor GUIs a bit, nonnull FluidStacks
This commit is contained in:
@@ -5,17 +5,23 @@ import com.raoulvdberge.refinedstorage.apiimpl.storage.FluidStorageType;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.ItemStorageType;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryFluid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryItem;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerFilter;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiFilter;
|
||||
import com.raoulvdberge.refinedstorage.item.*;
|
||||
import com.raoulvdberge.refinedstorage.item.group.MainItemGroup;
|
||||
import com.raoulvdberge.refinedstorage.network.NetworkHandler;
|
||||
import com.raoulvdberge.refinedstorage.recipe.UpgradeWithEnchantedBookRecipeSerializer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.ScreenManager;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraftforge.common.extensions.IForgeContainerType;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
@@ -31,8 +37,10 @@ public final class RS {
|
||||
|
||||
public RS() {
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onClientSetup);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(Item.class, this::onRegisterItems);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(IRecipeSerializer.class, this::onRegisterRecipeSerializers);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addGenericListener(ContainerType.class, this::onRegisterContainers);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -43,6 +51,11 @@ public final class RS {
|
||||
API.instance().getStorageDiskRegistry().add(StorageDiskFactoryFluid.ID, new StorageDiskFactoryFluid());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onClientSetup(FMLClientSetupEvent e) {
|
||||
ScreenManager.registerFactory(RSContainers.FILTER, GuiFilter::new);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRegisterRecipeSerializers(RegistryEvent.Register<IRecipeSerializer<?>> e) {
|
||||
e.getRegistry().register(new UpgradeWithEnchantedBookRecipeSerializer().setRegistryName(RS.ID, "upgrade_with_enchanted_book"));
|
||||
@@ -53,6 +66,11 @@ public final class RS {
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRegisterContainers(RegistryEvent.Register<ContainerType<?>> e) {
|
||||
e.getRegistry().register(IForgeContainerType.create((windowId, inv, data) -> new ContainerFilter(inv.player, inv.getCurrentItem(), windowId)).setRegistryName(RS.ID, "filter"));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRegisterItems(RegistryEvent.Register<Item> e) {
|
||||
e.getRegistry().register(new ItemCore(ItemCore.Type.CONSTRUCTION));
|
||||
@@ -94,6 +112,7 @@ public final class RS {
|
||||
|
||||
e.getRegistry().register(new ItemWrench());
|
||||
e.getRegistry().register(new ItemPattern());
|
||||
e.getRegistry().register(new ItemFilter());
|
||||
}
|
||||
|
||||
/* TODO
|
||||
|
@@ -5,6 +5,7 @@ import com.raoulvdberge.refinedstorage.container.factory.TileContainerFactory;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraftforge.common.extensions.IForgeContainerType;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
public final class RSContainers {
|
||||
//@ObjectHolder(RS.ID + ":constructor")
|
||||
@@ -29,8 +30,10 @@ public final class RSContainers {
|
||||
public static final ContainerType<ContainerExporter> EXPORTER = null;
|
||||
//@ObjectHolder(RS.ID + ":external_storage")
|
||||
public static final ContainerType<ContainerExternalStorage> EXTERNAL_STORAGE = null;
|
||||
//@ObjectHolder(RS.ID + ":filter")
|
||||
|
||||
@ObjectHolder(RS.ID + ":filter")
|
||||
public static final ContainerType<ContainerFilter> FILTER = null;
|
||||
|
||||
//@ObjectHolder(RS.ID + ":fluid_interface")
|
||||
public static final ContainerType<ContainerFluidInterface> FLUID_INTERFACE = null;
|
||||
//@ObjectHolder(RS.ID + ":fluid_storage")
|
||||
|
@@ -7,29 +7,35 @@ public final class RSItems {
|
||||
public static final ItemWirelessGrid WIRELESS_GRID = new ItemWirelessGrid();
|
||||
public static final ItemWirelessFluidGrid WIRELESS_FLUID_GRID = new ItemWirelessFluidGrid();
|
||||
public static final ItemWirelessCraftingMonitor WIRELESS_CRAFTING_MONITOR = new ItemWirelessCraftingMonitor();
|
||||
public static final ItemCover COVER = new ItemCover();
|
||||
public static final ItemHollowCover HOLLOW_COVER = new ItemHollowCover();
|
||||
|
||||
@ObjectHolder(RS.ID + ":quartz_enriched_iron")
|
||||
public static final ItemQuartzEnrichedIron QUARTZ_ENRICHED_IRON = null;
|
||||
@ObjectHolder(RS.ID + ":silicon")
|
||||
public static final ItemSilicon SILICON = null;
|
||||
@ObjectHolder(RS.ID + ":processor_binding")
|
||||
public static final ItemProcessorBinding PROCESSOR_BINDING = null;
|
||||
@ObjectHolder(RS.ID + ":wrench")
|
||||
public static final ItemWrench WRENCH = null;
|
||||
@ObjectHolder(RS.ID + ":pattern")
|
||||
public static final ItemPattern PATTERN = null;
|
||||
@ObjectHolder(RS.ID + ":filter")
|
||||
public static final ItemFilter FILTER = null;
|
||||
@ObjectHolder(RS.ID + ":storage_housing")
|
||||
public static final ItemStorageHousing STORAGE_HOUSING = null;
|
||||
@ObjectHolder(RS.ID + ":cutting_tool")
|
||||
public static final ItemCuttingTool CUTTING_TOOL = null;
|
||||
@ObjectHolder(RS.ID + ":network_card")
|
||||
public static final ItemNetworkCard NETWORK_CARD = null;
|
||||
@ObjectHolder(RS.ID + ":security_card")
|
||||
public static final ItemSecurityCard SECURITY_CARD = null;
|
||||
|
||||
@ObjectHolder(RS.ID + ":construction_core")
|
||||
public static final ItemCore CONSTRUCTION_CORE = null;
|
||||
@ObjectHolder(RS.ID + ":destruction_core")
|
||||
public static final ItemCore DESTRUCTION_CORE = null;
|
||||
|
||||
@ObjectHolder(RS.ID + ":silicon")
|
||||
public static final ItemSilicon SILICON = null;
|
||||
|
||||
@ObjectHolder(RS.ID + ":processor_binding")
|
||||
public static final ItemProcessorBinding PROCESSOR_BINDING = null;
|
||||
|
||||
@ObjectHolder(RS.ID + ":wrench")
|
||||
public static final ItemWrench WRENCH = null;
|
||||
|
||||
@ObjectHolder(RS.ID + ":pattern")
|
||||
public static final ItemPattern PATTERN = null;
|
||||
|
||||
public static final ItemFilter FILTER = new ItemFilter();
|
||||
|
||||
@ObjectHolder(RS.ID + ":raw_basic_processor")
|
||||
public static final ItemProcessor RAW_BASIC_PROCESSOR = null;
|
||||
@ObjectHolder(RS.ID + ":raw_improved_processor")
|
||||
@@ -44,6 +50,25 @@ public final class RSItems {
|
||||
@ObjectHolder(RS.ID + ":advanced_processor")
|
||||
public static final ItemProcessor ADVANCED_PROCESSOR = null;
|
||||
|
||||
@ObjectHolder(RS.ID + ":upgrade")
|
||||
public static final ItemUpgrade UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":speed_upgrade")
|
||||
public static final ItemUpgrade SPEED_UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":range_upgrade")
|
||||
public static final ItemUpgrade RANGE_UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":crafting_upgrade")
|
||||
public static final ItemUpgrade CRAFTING_UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":stack_upgrade")
|
||||
public static final ItemUpgrade STACK_UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":silk_touch_upgrade")
|
||||
public static final ItemUpgrade SILK_TOUCH_UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":fortune_1_upgrade")
|
||||
public static final ItemUpgrade FORTUNE_1_UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":fortune_2_upgrade")
|
||||
public static final ItemUpgrade FORTUNE_2_UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":fortune_3_upgrade")
|
||||
public static final ItemUpgrade FORTUNE_3_UPGRADE = null;
|
||||
|
||||
@ObjectHolder(RS.ID + ":1k_storage_part")
|
||||
public static final ItemStoragePart ONE_K_STORAGE_PART = null;
|
||||
@ObjectHolder(RS.ID + ":4k_storage_part")
|
||||
@@ -64,31 +89,6 @@ public final class RSItems {
|
||||
@ObjectHolder(RS.ID + ":creative_storage_disk")
|
||||
public static final ItemStorageDisk CREATIVE_STORAGE_DISK = null;
|
||||
|
||||
@ObjectHolder(RS.ID + ":upgrade")
|
||||
public static final ItemUpgrade UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":speed_upgrade")
|
||||
public static final ItemUpgrade SPEED_UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":range_upgrade")
|
||||
public static final ItemUpgrade RANGE_UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":crafting_upgrade")
|
||||
public static final ItemUpgrade CRAFTING_UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":stack_upgrade")
|
||||
public static final ItemUpgrade STACK_UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":silk_touch_upgrade")
|
||||
public static final ItemUpgrade SILK_TOUCH_UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":fortune_1_upgrade")
|
||||
public static final ItemUpgrade FORTUNE_1_UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":fortune_2_upgrade")
|
||||
public static final ItemUpgrade FORTUNE_2_UPGRADE = null;
|
||||
@ObjectHolder(RS.ID + ":fortune_3_upgrade")
|
||||
public static final ItemUpgrade FORTUNE_3_UPGRADE = null;
|
||||
|
||||
@ObjectHolder(RS.ID + ":network_card")
|
||||
public static final ItemNetworkCard NETWORK_CARD = null;
|
||||
|
||||
@ObjectHolder(RS.ID + ":security_card")
|
||||
public static final ItemSecurityCard SECURITY_CARD = null;
|
||||
|
||||
@ObjectHolder(RS.ID + ":64k_fluid_storage_part")
|
||||
public static final ItemFluidStoragePart SIXTY_FOUR_K_FLUID_STORAGE_PART = null;
|
||||
@ObjectHolder(RS.ID + ":256k_fluid_storage_part")
|
||||
@@ -108,13 +108,4 @@ public final class RSItems {
|
||||
public static final ItemFluidStorageDisk FOUR_THOUSAND_NINETY_SIX_K_FLUID_STORAGE_DISK = null;
|
||||
@ObjectHolder(RS.ID + ":creative_fluid_storage_disk")
|
||||
public static final ItemFluidStorageDisk CREATIVE_FLUID_STORAGE_DISK = null;
|
||||
|
||||
@ObjectHolder(RS.ID + ":storage_housing")
|
||||
public static final ItemStorageHousing STORAGE_HOUSING = null;
|
||||
|
||||
@ObjectHolder(RS.ID + ":cutting_tool")
|
||||
public static final ItemCuttingTool CUTTING_TOOL = null;
|
||||
|
||||
public static final ItemCover COVER = new ItemCover();
|
||||
public static final ItemHollowCover HOLLOW_COVER = new ItemHollowCover();
|
||||
}
|
||||
|
@@ -4,8 +4,8 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -78,13 +78,13 @@ public class CraftingPreviewElementFluidStack implements ICraftingPreviewElement
|
||||
|
||||
if (getToCraft() > 0) {
|
||||
String format = hasMissing() ? "gui.refinedstorage:crafting_preview.missing" : "gui.refinedstorage:crafting_preview.to_craft";
|
||||
drawers.getStringDrawer().draw(RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), GuiBase.t(format, API.instance().getQuantityFormatter().formatInBucketForm(getToCraft())));
|
||||
drawers.getStringDrawer().draw(RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), I18n.format(format, API.instance().getQuantityFormatter().formatInBucketForm(getToCraft())));
|
||||
|
||||
y += 7;
|
||||
}
|
||||
|
||||
if (getAvailable() > 0) {
|
||||
drawers.getStringDrawer().draw(RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), GuiBase.t("gui.refinedstorage:crafting_preview.available", API.instance().getQuantityFormatter().formatInBucketForm(getAvailable())));
|
||||
drawers.getStringDrawer().draw(RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), I18n.format("gui.refinedstorage:crafting_preview.available", API.instance().getQuantityFormatter().formatInBucketForm(getAvailable())));
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
|
@@ -3,8 +3,8 @@ package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@@ -87,13 +87,13 @@ public class CraftingPreviewElementItemStack implements ICraftingPreviewElement<
|
||||
|
||||
if (getToCraft() > 0) {
|
||||
String format = hasMissing() ? "gui.refinedstorage:crafting_preview.missing" : "gui.refinedstorage:crafting_preview.to_craft";
|
||||
drawers.getStringDrawer().draw(RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), GuiBase.t(format, getToCraft()));
|
||||
drawers.getStringDrawer().draw(RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), I18n.format(format, getToCraft()));
|
||||
|
||||
y += 7;
|
||||
}
|
||||
|
||||
if (getAvailable() > 0) {
|
||||
drawers.getStringDrawer().draw(RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), GuiBase.t("gui.refinedstorage:crafting_preview.available", getAvailable()));
|
||||
drawers.getStringDrawer().draw(RenderUtils.getOffsetOnScale(x + 23, scale), RenderUtils.getOffsetOnScale(y, scale), I18n.format("gui.refinedstorage:crafting_preview.available", getAvailable()));
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
|
@@ -86,7 +86,7 @@ public class FluidGridHandler implements IFluidGridHandler {
|
||||
|
||||
Pair<ItemStack, FluidStack> result = StackUtils.getFluid(container, true);
|
||||
|
||||
if (result.getValue() != null && network.insertFluid(result.getValue(), result.getValue().getAmount(), Action.SIMULATE) == null) {
|
||||
if (network.insertFluid(result.getValue(), result.getValue().getAmount(), Action.SIMULATE) == null) {
|
||||
network.getFluidStorageTracker().changed(player, result.getValue().copy());
|
||||
|
||||
result = StackUtils.getFluid(container, false);
|
||||
|
@@ -74,7 +74,7 @@ public class FluidGridHandlerPortable implements IFluidGridHandler {
|
||||
public ItemStack onInsert(ServerPlayerEntity player, ItemStack container) {
|
||||
Pair<ItemStack, FluidStack> result = StackUtils.getFluid(container, true);
|
||||
|
||||
if (result.getValue() != null && portableGrid.getFluidStorage().insert(result.getValue(), result.getValue().getAmount(), Action.SIMULATE) == null) {
|
||||
if (portableGrid.getFluidStorage().insert(result.getValue(), result.getValue().getAmount(), Action.SIMULATE) == null) {
|
||||
portableGrid.getFluidStorageTracker().changed(player, result.getValue().copy());
|
||||
|
||||
result = StackUtils.getFluid(container, false);
|
||||
|
@@ -101,7 +101,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
|
||||
dropItem();
|
||||
}
|
||||
}
|
||||
} else if (type == IType.FLUIDS && fluidFilters.getFluid(0) != null) {
|
||||
} else if (type == IType.FLUIDS && !fluidFilters.getFluid(0).isEmpty()) {
|
||||
/*TODO FluidStack stack = fluidFilters.getFluid(0);
|
||||
|
||||
if (stack != null && stack.getFluid().getAttributes().canBePlacedInWorld()) {
|
||||
|
@@ -82,7 +82,7 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy
|
||||
} else if (type == IType.FLUIDS) {
|
||||
FluidStack slot = fluidFilters.getFluid(0);
|
||||
|
||||
if (slot != null) {
|
||||
if (!slot.isEmpty()) {
|
||||
FluidStack stack = network.getFluidStorageCache().getList().get(slot, compare);
|
||||
|
||||
powered = isPowered(stack == null ? null : stack.getAmount());
|
||||
|
@@ -53,7 +53,7 @@ public class NetworkNodeFluidInterface extends NetworkNode {
|
||||
|
||||
private FluidHandlerProxy tank = new FluidHandlerProxy(tankIn, tankOut);
|
||||
|
||||
private ItemHandlerBase in = new ItemHandlerBase(1, new ListenerNetworkNode(this), stack -> StackUtils.getFluid(stack, true).getRight() != null);
|
||||
private ItemHandlerBase in = new ItemHandlerBase(1, new ListenerNetworkNode(this), stack -> StackUtils.getFluid(stack, true).getValue() != null);
|
||||
private FluidInventory out = new FluidInventory(1, TANK_CAPACITY, new ListenerNetworkNode(this));
|
||||
|
||||
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ListenerNetworkNode(this)/* TODO, ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK, ItemUpgrade.TYPE_CRAFTING*/);
|
||||
@@ -72,7 +72,7 @@ public class NetworkNodeFluidInterface extends NetworkNode {
|
||||
if (!container.isEmpty()) {
|
||||
Pair<ItemStack, FluidStack> result = StackUtils.getFluid(container, true);
|
||||
|
||||
if (result.getValue() != null && tankIn.fill(result.getValue(), IFluidHandler.FluidAction.SIMULATE) == result.getValue().getAmount()) {
|
||||
if (tankIn.fill(result.getValue(), IFluidHandler.FluidAction.SIMULATE) == result.getValue().getAmount()) {
|
||||
result = StackUtils.getFluid(container, false);
|
||||
|
||||
tankIn.fill(result.getValue(), IFluidHandler.FluidAction.EXECUTE);
|
||||
@@ -97,18 +97,18 @@ public class NetworkNodeFluidInterface extends NetworkNode {
|
||||
FluidStack wanted = out.getFluid(0);
|
||||
FluidStack got = tankOut.getFluid();
|
||||
|
||||
if (wanted == null) {
|
||||
if (got != null) {
|
||||
if (!wanted.isEmpty()) {
|
||||
if (!got.isEmpty()) {
|
||||
tankOut.setFluid(network.insertFluidTracked(got, got.getAmount()));
|
||||
|
||||
onTankOutChanged();
|
||||
}
|
||||
} else if (got != null && !API.instance().getComparer().isEqual(wanted, got, IComparer.COMPARE_NBT)) {
|
||||
} else if (!got.isEmpty() && !API.instance().getComparer().isEqual(wanted, got, IComparer.COMPARE_NBT)) {
|
||||
tankOut.setFluid(network.insertFluidTracked(got, got.getAmount()));
|
||||
|
||||
onTankOutChanged();
|
||||
} else {
|
||||
int delta = got == null ? wanted.getAmount() : (wanted.getAmount() - got.getAmount());
|
||||
int delta = got.isEmpty() ? wanted.getAmount() : (wanted.getAmount() - got.getAmount());
|
||||
|
||||
if (delta > 0) {
|
||||
final boolean actingAsStorage = isActingAsStorage();
|
||||
|
@@ -22,6 +22,7 @@ import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
|
||||
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter;
|
||||
import com.raoulvdberge.refinedstorage.inventory.item.validator.ItemValidatorBasic;
|
||||
import com.raoulvdberge.refinedstorage.inventory.listener.ListenerNetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemPattern;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||
@@ -440,7 +441,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
|
||||
}
|
||||
|
||||
for (int i = 0; i < processingMatrixFluids.getSlots(); ++i) {
|
||||
processingMatrixFluids.setFluid(i, null);
|
||||
processingMatrixFluids.setFluid(i, FluidStack.EMPTY);
|
||||
}
|
||||
|
||||
for (int i = 0; i < matrix.getSizeInventory(); ++i) {
|
||||
@@ -547,26 +548,26 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
|
||||
|
||||
ItemStack pattern = new ItemStack(RSItems.PATTERN);
|
||||
|
||||
/*TODO ItemPattern.setVersion(pattern);
|
||||
ItemPattern.setToCurrentVersion(pattern);
|
||||
ItemPattern.setOredict(pattern, oredictPattern);
|
||||
ItemPattern.setProcessing(pattern, processingPattern);
|
||||
*/
|
||||
|
||||
if (processingPattern) {
|
||||
for (int i = 0; i < 18; ++i) {
|
||||
if (!processingMatrix.getStackInSlot(i).isEmpty()) {
|
||||
if (i >= 9) {
|
||||
// TODO ItemPattern.setOutputSlot(pattern, i - 9, processingMatrix.getStackInSlot(i));
|
||||
ItemPattern.setOutputSlot(pattern, i - 9, processingMatrix.getStackInSlot(i));
|
||||
} else {
|
||||
// TODO ItemPattern.setInputSlot(pattern, i, processingMatrix.getStackInSlot(i));
|
||||
ItemPattern.setInputSlot(pattern, i, processingMatrix.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
|
||||
FluidStack fluid = processingMatrixFluids.getFluid(i);
|
||||
if (fluid != null) {
|
||||
if (!fluid.isEmpty()) {
|
||||
if (i >= 9) {
|
||||
// TODO ItemPattern.setFluidOutputSlot(pattern, i - 9, fluid);
|
||||
ItemPattern.setFluidOutputSlot(pattern, i - 9, fluid);
|
||||
} else {
|
||||
// TODO ItemPattern.setFluidInputSlot(pattern, i, fluid);
|
||||
ItemPattern.setFluidInputSlot(pattern, i, fluid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -575,7 +576,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
|
||||
ItemStack ingredient = matrix.getStackInSlot(i);
|
||||
|
||||
if (!ingredient.isEmpty()) {
|
||||
// TODO ItemPattern.setInputSlot(pattern, i, ingredient);
|
||||
ItemPattern.setInputSlot(pattern, i, ingredient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -344,13 +344,13 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
|
||||
}
|
||||
} else {
|
||||
while (fluidFilters.getSlots() > i && extracted == null) {
|
||||
FluidStack filterStack = null;
|
||||
FluidStack filterStack = FluidStack.EMPTY;
|
||||
|
||||
while (fluidFilters.getSlots() > i && filterStack == null) {
|
||||
while (fluidFilters.getSlots() > i && filterStack.isEmpty()) {
|
||||
filterStack = fluidFilters.getFluid(i++);
|
||||
}
|
||||
|
||||
if (filterStack != null) {
|
||||
if (!filterStack.isEmpty()) {
|
||||
extracted = network.extractFluid(filterStack, upgrades.getItemInteractCount(), compare, Action.PERFORM);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,44 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.render;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawer;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
||||
public class CraftingMonitorElementDrawers extends ElementDrawers {
|
||||
private int itemWidth;
|
||||
private int itemHeight;
|
||||
|
||||
private IElementDrawer<Integer> overlayDrawer = (x, y, color) -> {
|
||||
GlStateManager.color4f(1, 1, 1, 1);
|
||||
GlStateManager.disableLighting();
|
||||
|
||||
gui.fill(x, y, x + itemWidth, y + itemHeight, color);
|
||||
};
|
||||
|
||||
private IElementDrawer errorDrawer = (x, y, nothing) -> {
|
||||
GlStateManager.color4f(1, 1, 1, 1);
|
||||
GlStateManager.disableLighting();
|
||||
|
||||
gui.bindTexture("gui/crafting_preview.png");
|
||||
|
||||
gui.blit(x + itemWidth - 12 - 2, y + itemHeight - 12 - 2, 0, 244, 12, 12);
|
||||
};
|
||||
|
||||
public CraftingMonitorElementDrawers(GuiBase gui, FontRenderer fontRenderer, int itemWidth, int itemHeight) {
|
||||
super(gui, fontRenderer);
|
||||
|
||||
this.itemWidth = itemWidth;
|
||||
this.itemHeight = itemHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementDrawer<Integer> getOverlayDrawer() {
|
||||
return overlayDrawer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementDrawer getErrorDrawer() {
|
||||
return errorDrawer;
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.render;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawer;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiCraftingPreview;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
||||
public class CraftingPreviewElementDrawers extends ElementDrawers {
|
||||
private GuiCraftingPreview gui;
|
||||
private IElementDrawer<Integer> overlayDrawer = (x, y, colour) -> {
|
||||
GlStateManager.color4f(1, 1, 1, 1);
|
||||
GlStateManager.disableLighting();
|
||||
|
||||
gui.fill(x, y, x + 73, y + 29, colour);
|
||||
};
|
||||
|
||||
public CraftingPreviewElementDrawers(GuiCraftingPreview gui, FontRenderer fontRenderer) {
|
||||
super(gui, fontRenderer);
|
||||
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementDrawer<Integer> getOverlayDrawer() {
|
||||
return overlayDrawer;
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.render;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawer;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.render.FluidRenderer;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class ElementDrawers implements IElementDrawers {
|
||||
protected GuiBase gui;
|
||||
private FontRenderer fontRenderer;
|
||||
|
||||
public ElementDrawers(GuiBase gui, FontRenderer fontRenderer) {
|
||||
this.gui = gui;
|
||||
this.fontRenderer = fontRenderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementDrawer<ItemStack> getItemDrawer() {
|
||||
return gui::renderItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementDrawer<FluidStack> getFluidDrawer() {
|
||||
return FluidRenderer.INSTANCE::render;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementDrawer<String> getStringDrawer() {
|
||||
return gui::renderString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FontRenderer getFontRenderer() {
|
||||
return fontRenderer;
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
package com.raoulvdberge.refinedstorage.container;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.SlotFilter;
|
||||
@@ -7,6 +8,7 @@ import com.raoulvdberge.refinedstorage.container.slot.filter.SlotFilterFluid;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.SlotLegacyDisabled;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.SlotLegacyFilter;
|
||||
import com.raoulvdberge.refinedstorage.container.transfer.TransferManager;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageSlotFilterFluidUpdate;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataWatcher;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -187,7 +189,7 @@ public abstract class ContainerBase extends Container {
|
||||
if (!API.instance().getComparer().isEqual(cached, actual, IComparer.COMPARE_QUANTITY | IComparer.COMPARE_NBT)) {
|
||||
this.fluids.set(i, actual);
|
||||
|
||||
// TODO RS.INSTANCE.network.sendTo(new MessageSlotFilterFluidUpdate(slot.slotNumber, actual), (ServerPlayerEntity) this.getPlayer());
|
||||
RS.NETWORK_HANDLER.sendTo((ServerPlayerEntity) getPlayer(), new MessageSlotFilterFluidUpdate(slot.slotNumber, actual));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,15 @@
|
||||
package com.raoulvdberge.refinedstorage.container;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSContainers;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.SlotFilter;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.SlotFilterFluid;
|
||||
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
|
||||
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventoryFilter;
|
||||
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventoryFilterIcon;
|
||||
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilterIcon;
|
||||
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilterItems;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemFilter;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -20,13 +25,11 @@ public class ContainerFilter extends ContainerBase {
|
||||
int x = 8;
|
||||
|
||||
ItemHandlerFilterItems filter = new ItemHandlerFilterItems(stack);
|
||||
|
||||
FluidInventoryFilterIcon fluidIcon = new FluidInventoryFilterIcon(stack);
|
||||
FluidInventory fluidFilter = new FluidInventoryFilter(stack);
|
||||
|
||||
for (int i = 0; i < 27; ++i) {
|
||||
// TODO addSlot(new SlotFilter(filter, i, x, y).setEnableHandler(() -> ItemFilter.getType(stack) == IType.ITEMS));
|
||||
// TODO addSlot(new SlotFilterFluid(fluidFilter, i, x, y).setEnableHandler(() -> ItemFilter.getType(stack) == IType.FLUIDS));
|
||||
addSlot(new SlotFilter(filter, i, x, y).setEnableHandler(() -> ItemFilter.getType(stack) == IType.ITEMS));
|
||||
addSlot(new SlotFilterFluid(fluidFilter, i, x, y).setEnableHandler(() -> ItemFilter.getType(stack) == IType.FLUIDS));
|
||||
|
||||
if ((i + 1) % 9 == 0) {
|
||||
x = 8;
|
||||
@@ -36,12 +39,12 @@ public class ContainerFilter extends ContainerBase {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO addSlot(new SlotFilter(new ItemHandlerFilterIcon(stack), 0, 8, 117).setEnableHandler(() -> ItemFilter.getType(stack) == IType.ITEMS));
|
||||
// TODO addSlot(new SlotFilterFluid(fluidIcon, 0, 8, 117).setEnableHandler(() -> ItemFilter.getType(stack) == IType.FLUIDS));
|
||||
addSlot(new SlotFilter(new ItemHandlerFilterIcon(stack), 0, 8, 117).setEnableHandler(() -> ItemFilter.getType(stack) == IType.ITEMS));
|
||||
addSlot(new SlotFilterFluid(new FluidInventoryFilterIcon(stack), 0, 8, 117).setEnableHandler(() -> ItemFilter.getType(stack) == IType.FLUIDS));
|
||||
|
||||
addPlayerInventory(8, 149);
|
||||
|
||||
// TODO transferManager.addFilterTransfer(player.inventory, filter, fluidFilter, () -> ItemFilter.getType(stack));
|
||||
transferManager.addFilterTransfer(player.inventory, filter, fluidFilter, () -> ItemFilter.getType(stack));
|
||||
}
|
||||
|
||||
public ItemStack getStack() {
|
||||
|
@@ -4,7 +4,6 @@ import com.raoulvdberge.refinedstorage.container.slot.SlotBase;
|
||||
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -32,15 +31,7 @@ public class SlotFilterFluid extends SlotBase {
|
||||
}
|
||||
|
||||
public void onContainerClicked(@Nonnull ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
fluidInventory.setFluid(getSlotIndex(), null);
|
||||
} else {
|
||||
FluidStack fluid = StackUtils.getFluid(stack, true).getValue();
|
||||
|
||||
if (fluid != null) {
|
||||
fluidInventory.setFluid(getSlotIndex(), fluid);
|
||||
}
|
||||
}
|
||||
fluidInventory.setFluid(getSlotIndex(), StackUtils.getFluid(stack, true).getValue());
|
||||
}
|
||||
|
||||
public boolean isSizeAllowed() {
|
||||
|
@@ -21,7 +21,7 @@ class InventoryWrapperFilterFluid implements IInventoryWrapper {
|
||||
|
||||
FluidStack fluidInContainer = StackUtils.getFluid(stack, true).getValue();
|
||||
|
||||
if (fluidInContainer == null) {
|
||||
if (fluidInContainer.isEmpty()) {
|
||||
return stop;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class InventoryWrapperFilterFluid implements IInventoryWrapper {
|
||||
}
|
||||
|
||||
for (int i = 0; i < filterInv.getSlots(); ++i) {
|
||||
if (filterInv.getFluid(i) == null) {
|
||||
if (filterInv.getFluid(i).isEmpty()) {
|
||||
filterInv.setFluid(i, StackUtils.copy(fluidInContainer, FluidAttributes.BUCKET_VOLUME));
|
||||
|
||||
return stop;
|
||||
|
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerAmount;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -35,12 +36,12 @@ public class GuiAmount extends GuiAmountSpecifying<ContainerAmount> {
|
||||
|
||||
@Override
|
||||
protected String getOkButtonText() {
|
||||
return t("misc.refinedstorage:set");
|
||||
return I18n.format("misc.refinedstorage:set");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getGuiTitle() {
|
||||
return t("gui.refinedstorage:item_amount");
|
||||
return I18n.format("gui.refinedstorage:item_amount");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -48,8 +49,10 @@ public abstract class GuiAmountSpecifying<T extends Container> extends GuiBase<T
|
||||
public void init(int x, int y) {
|
||||
Pair<Integer, Integer> pos = getOkCancelPos();
|
||||
|
||||
okButton = addButton(x + pos.getLeft(), y + pos.getRight(), 50, 20, getOkButtonText());
|
||||
cancelButton = addButton(x + pos.getLeft(), y + pos.getRight() + 24, 50, 20, t("gui.cancel"));
|
||||
okButton = addButton(x + pos.getLeft(), y + pos.getRight(), 50, 20, getOkButtonText(), true, true, btn -> {
|
||||
});
|
||||
cancelButton = addButton(x + pos.getLeft(), y + pos.getRight() + 24, 50, 20, I18n.format("gui.cancel"), true, true, btn -> {
|
||||
});
|
||||
|
||||
amountField = new TextFieldWidget(font, x + getAmountPos().getLeft(), y + getAmountPos().getRight(), 69 - 6, font.FONT_HEIGHT, "");
|
||||
amountField.setEnableBackgroundDrawing(false);
|
||||
@@ -71,7 +74,8 @@ public abstract class GuiAmountSpecifying<T extends Container> extends GuiBase<T
|
||||
text = "+1B";
|
||||
}
|
||||
|
||||
incrementButtons[i] = addButton(x + xx, y + 20, width, 20, text);
|
||||
incrementButtons[i] = addButton(x + xx, y + 20, width, 20, text, true, true, btn -> {
|
||||
});
|
||||
|
||||
xx += width + 3;
|
||||
}
|
||||
@@ -85,29 +89,30 @@ public abstract class GuiAmountSpecifying<T extends Container> extends GuiBase<T
|
||||
text = "-1B";
|
||||
}
|
||||
|
||||
incrementButtons[3 + i] = addButton(x + xx, y + screenHeight - 20 - 7, width, 20, text);
|
||||
incrementButtons[3 + i] = addButton(x + xx, y + ySize - 20 - 7, width, 20, text, true, true, btn -> {
|
||||
});
|
||||
|
||||
xx += width + 3;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture(getTexture());
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
|
||||
amountField.renderButton(0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, getGuiTitle());
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, getGuiTitle());
|
||||
}
|
||||
|
||||
/* TODO
|
||||
|
@@ -2,18 +2,14 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawer;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.SlotFilterFluid;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.Scrollbar;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButton;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.CheckBoxWidget;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButton;
|
||||
import com.raoulvdberge.refinedstorage.render.FluidRenderer;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
@@ -30,59 +26,26 @@ import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public abstract class GuiBase<T extends Container> extends ContainerScreen {
|
||||
public abstract class GuiBase<T extends Container> extends ContainerScreen<T> {
|
||||
private static final Map<String, ResourceLocation> TEXTURE_CACHE = new HashMap<>();
|
||||
private static final Map<Class, Queue<Consumer>> RUNNABLES = new HashMap<>();
|
||||
private static final Map<Class, Queue<Consumer>> ACTIONS = new HashMap<>();
|
||||
|
||||
public static final RenderUtils.FluidRenderer FLUID_RENDERER = new RenderUtils.FluidRenderer(-1, 16, 16);
|
||||
private int sideButtonY;
|
||||
|
||||
public class ElementDrawers implements IElementDrawers {
|
||||
private IElementDrawer<FluidStack> fluidDrawer = (x, y, element) -> FLUID_RENDERER.draw(GuiBase.this.minecraft, x, y, element);
|
||||
|
||||
@Override
|
||||
public IElementDrawer<ItemStack> getItemDrawer() {
|
||||
return GuiBase.this::drawItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementDrawer<FluidStack> getFluidDrawer() {
|
||||
return fluidDrawer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementDrawer<String> getStringDrawer() {
|
||||
return GuiBase.this::drawString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FontRenderer getFontRenderer() {
|
||||
return font;
|
||||
}
|
||||
}
|
||||
|
||||
private int lastButtonId;
|
||||
private int lastSideButtonY;
|
||||
|
||||
private String hoveringFluid = null;
|
||||
|
||||
protected int screenWidth;
|
||||
protected int screenHeight;
|
||||
|
||||
protected Scrollbar scrollbar;
|
||||
|
||||
private boolean initializing;
|
||||
|
||||
public GuiBase(T container, int screenWidth, int screenHeight, PlayerInventory inventory, ITextComponent title) {
|
||||
public GuiBase(T container, int xSize, int ySize, PlayerInventory inventory, ITextComponent title) {
|
||||
super(container, inventory, title);
|
||||
|
||||
this.screenWidth = screenWidth;
|
||||
this.screenHeight = screenHeight;
|
||||
this.xSize = screenWidth;
|
||||
this.ySize = screenHeight;
|
||||
this.xSize = xSize;
|
||||
this.ySize = ySize;
|
||||
}
|
||||
|
||||
private void runRunnables() {
|
||||
Queue<Consumer> queue = RUNNABLES.get(getClass());
|
||||
private void runActions() {
|
||||
runActions(getClass());
|
||||
runActions(ContainerScreen.class);
|
||||
}
|
||||
|
||||
private void runActions(Class clazz) {
|
||||
Queue<Consumer> queue = ACTIONS.get(clazz);
|
||||
|
||||
if (queue != null && !queue.isEmpty()) {
|
||||
Consumer callback;
|
||||
@@ -90,111 +53,54 @@ public abstract class GuiBase<T extends Container> extends ContainerScreen {
|
||||
callback.accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
queue = RUNNABLES.get(ContainerScreen.class);
|
||||
|
||||
if (queue != null && !queue.isEmpty()) {
|
||||
Consumer callback;
|
||||
while ((callback = queue.poll()) != null) {
|
||||
callback.accept(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getScreenWidth() {
|
||||
return screenWidth;
|
||||
}
|
||||
|
||||
public int getScreenHeight() {
|
||||
return screenHeight;
|
||||
}
|
||||
|
||||
public Scrollbar getScrollbar() {
|
||||
return scrollbar;
|
||||
}
|
||||
|
||||
public boolean isMouseOverSlotPublic(Slot slot, int mx, int my) {
|
||||
return this.isPointInRegion(slot.xPos, slot.yPos, 16, 16, mx, my);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
if (initializing) { // Fix double initialize because of runRunnables
|
||||
return;
|
||||
}
|
||||
|
||||
initializing = true;
|
||||
|
||||
// TODO Keyboard.enableRepeatEvents(true);
|
||||
|
||||
calcHeight();
|
||||
minecraft.keyboardListener.enableRepeatEvents(true);
|
||||
|
||||
super.init();
|
||||
|
||||
if (!buttons.isEmpty()) {
|
||||
buttons.removeIf(b -> !b.getClass().getName().contains("net.blay09.mods.craftingtweaks")); // Prevent crafting tweaks buttons from resetting
|
||||
}
|
||||
buttons.clear();
|
||||
children.clear();
|
||||
|
||||
lastButtonId = 0;
|
||||
lastSideButtonY = getSideButtonYStart();
|
||||
sideButtonY = 6;
|
||||
|
||||
init(guiLeft, guiTop);
|
||||
|
||||
runRunnables();
|
||||
|
||||
initializing = false;
|
||||
runActions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose() {
|
||||
super.onClose();
|
||||
|
||||
// TODO Keyboard.enableRepeatEvents(false);
|
||||
}
|
||||
|
||||
protected void calcHeight() {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
protected int getSideButtonYStart() {
|
||||
return 6;
|
||||
minecraft.keyboardListener.enableRepeatEvents(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
runRunnables();
|
||||
runActions();
|
||||
|
||||
update(guiLeft, guiTop);
|
||||
tick(guiLeft, guiTop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
renderBackground();
|
||||
|
||||
try {
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
} catch (Exception e) {
|
||||
// NO OP: Prevent a MC crash (see #1483)
|
||||
// TODO ^can be removed?
|
||||
}
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
|
||||
renderHoveredToolTip(mouseX, mouseY);
|
||||
|
||||
// Prevent accidental scrollbar click after clicking recipe transfer button
|
||||
if (scrollbar != null /* TODO && (!IntegrationJEI.isLoaded() || System.currentTimeMillis() - RecipeTransferHandlerGrid.LAST_TRANSFER > RecipeTransferHandlerGrid.TRANSFER_SCROLL_DELAY_MS)*/) {
|
||||
scrollbar.update(this, mouseX - guiLeft, mouseY - guiTop);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float renderPartialTicks, int mouseX, int mouseY) {
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
drawBackground(guiLeft, guiTop, mouseX, mouseY);
|
||||
|
||||
this.hoveringFluid = null;
|
||||
renderBackground(guiLeft, guiTop, mouseX, mouseY);
|
||||
|
||||
for (int i = 0; i < this.container.inventorySlots.size(); ++i) {
|
||||
Slot slot = container.inventorySlots.get(i);
|
||||
@@ -202,27 +108,17 @@ public abstract class GuiBase<T extends Container> extends ContainerScreen {
|
||||
if (slot.isEnabled() && slot instanceof SlotFilterFluid) {
|
||||
FluidStack stack = ((SlotFilterFluid) slot).getFluidInventory().getFluid(slot.getSlotIndex());
|
||||
|
||||
if (stack != null) {
|
||||
FLUID_RENDERER.draw(minecraft, guiLeft + slot.xPos, guiTop + slot.yPos, stack);
|
||||
if (!stack.isEmpty()) {
|
||||
FluidRenderer.INSTANCE.render(guiLeft + slot.xPos, guiTop + slot.yPos, stack);
|
||||
|
||||
if (((SlotFilterFluid) slot).isSizeAllowed()) {
|
||||
drawQuantity(guiLeft + slot.xPos, guiTop + slot.yPos, API.instance().getQuantityFormatter().formatInBucketForm(stack.getAmount()));
|
||||
renderQuantity(guiLeft + slot.xPos, guiTop + slot.yPos, API.instance().getQuantityFormatter().formatInBucketForm(stack.getAmount()));
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
}
|
||||
|
||||
if (inBounds(guiLeft + slot.xPos, guiTop + slot.yPos, 17, 17, mouseX, mouseY)) {
|
||||
this.hoveringFluid = stack.getDisplayName().getFormattedText(); // TODO wrong
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scrollbar != null) {
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
scrollbar.draw(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -232,20 +128,26 @@ public abstract class GuiBase<T extends Container> extends ContainerScreen {
|
||||
mouseX -= guiLeft;
|
||||
mouseY -= guiTop;
|
||||
|
||||
String sideButtonTooltip = null;
|
||||
renderForeground(mouseX, mouseY);
|
||||
|
||||
for (int i = 0; i < this.buttons.size(); ++i) {
|
||||
Widget button = buttons.get(i);
|
||||
|
||||
if (button instanceof SideButton && button.isHovered()) {
|
||||
sideButtonTooltip = ((SideButton) button).getTooltip();
|
||||
renderTooltip(mouseX, mouseY, ((SideButton) button).getTooltip());
|
||||
}
|
||||
}
|
||||
|
||||
drawForeground(mouseX, mouseY);
|
||||
for (int i = 0; i < this.container.inventorySlots.size(); ++i) {
|
||||
Slot slot = container.inventorySlots.get(i);
|
||||
|
||||
if (sideButtonTooltip != null || hoveringFluid != null) {
|
||||
drawTooltip(mouseX, mouseY, sideButtonTooltip != null ? sideButtonTooltip : hoveringFluid);
|
||||
if (slot.isEnabled() && slot instanceof SlotFilterFluid) {
|
||||
FluidStack stack = ((SlotFilterFluid) slot).getFluidInventory().getFluid(slot.getSlotIndex());
|
||||
|
||||
if (!stack.isEmpty() && inBounds(slot.xPos, slot.yPos, 17, 17, mouseX, mouseY)) {
|
||||
renderTooltip(mouseX, mouseY, stack.getDisplayName().getFormattedText());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,36 +196,32 @@ public abstract class GuiBase<T extends Container> extends ContainerScreen {
|
||||
}
|
||||
}*/
|
||||
|
||||
public GuiCheckBox addCheckBox(int x, int y, String text, boolean checked) {
|
||||
GuiCheckBox checkBox = new GuiCheckBox(x, y, text, checked);
|
||||
public GuiCheckBox addCheckBox(int x, int y, String text, boolean checked, Button.IPressable onPress) {
|
||||
CheckBoxWidget checkBox = new CheckBoxWidget(x, y, text, checked, onPress);
|
||||
|
||||
buttons.add(checkBox);
|
||||
this.addButton(checkBox);
|
||||
|
||||
return checkBox;
|
||||
}
|
||||
|
||||
public Button addButton(int x, int y, int w, int h, String text) {
|
||||
return addButton(x, y, w, h, text, true, true);
|
||||
}
|
||||
public Button addButton(int x, int y, int w, int h, String text, boolean enabled, boolean visible, Button.IPressable onPress) {
|
||||
Button button = new Button(x, y, w, h, text, onPress);
|
||||
|
||||
public Button addButton(int x, int y, int w, int h, String text, boolean enabled, boolean visible) {
|
||||
Button button = new Button(x, y, w, h, text, (btn) -> {
|
||||
});
|
||||
button.active = enabled;// TODO is active correct?
|
||||
button.active = enabled;
|
||||
button.visible = visible;
|
||||
|
||||
buttons.add(button);
|
||||
this.addButton(button);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
public SideButton addSideButton(SideButton button) {
|
||||
button.x = guiLeft + -SideButton.WIDTH - 2;
|
||||
button.y = guiTop + lastSideButtonY;
|
||||
button.y = guiTop + sideButtonY;
|
||||
|
||||
lastSideButtonY += SideButton.HEIGHT + 2;
|
||||
sideButtonY += SideButton.HEIGHT + 2;
|
||||
|
||||
this.buttons.add(button);
|
||||
this.addButton(button);
|
||||
|
||||
return button;
|
||||
}
|
||||
@@ -337,25 +235,18 @@ public abstract class GuiBase<T extends Container> extends ContainerScreen {
|
||||
}
|
||||
|
||||
public void bindTexture(String base, String file) {
|
||||
String id = base + ":" + file;
|
||||
|
||||
if (!TEXTURE_CACHE.containsKey(id)) {
|
||||
TEXTURE_CACHE.put(id, new ResourceLocation(base, "textures/" + file));
|
||||
}
|
||||
|
||||
minecraft.getTextureManager().bindTexture(TEXTURE_CACHE.get(id));
|
||||
minecraft.getTextureManager().bindTexture(TEXTURE_CACHE.computeIfAbsent(base + ":" + file, (newId) -> new ResourceLocation(base, "textures/" + file)));
|
||||
}
|
||||
|
||||
public void drawItem(int x, int y, ItemStack stack) {
|
||||
drawItem(x, y, stack, false);
|
||||
public void renderItem(int x, int y, ItemStack stack) {
|
||||
renderItem(x, y, stack, false);
|
||||
}
|
||||
|
||||
public void drawItem(int x, int y, ItemStack stack, boolean withOverlay) {
|
||||
drawItem(x, y, stack, withOverlay, null);
|
||||
public void renderItem(int x, int y, ItemStack stack, boolean withOverlay) {
|
||||
renderItem(x, y, stack, withOverlay, null);
|
||||
}
|
||||
|
||||
public void drawItem(int x, int y, ItemStack stack, boolean withOverlay, @Nullable String text) {
|
||||
// TODO zLevel = 200.0F;
|
||||
public void renderItem(int x, int y, ItemStack stack, boolean withOverlay, @Nullable String text) {
|
||||
itemRenderer.zLevel = 200.0F;
|
||||
|
||||
try {
|
||||
@@ -365,14 +256,13 @@ public abstract class GuiBase<T extends Container> extends ContainerScreen {
|
||||
}
|
||||
|
||||
if (withOverlay) {
|
||||
drawItemOverlay(stack, text, x, y);
|
||||
renderItemOverlay(stack, text, x, y);
|
||||
}
|
||||
|
||||
// TODO zLevel = 0.0F;
|
||||
itemRenderer.zLevel = 0.0F;
|
||||
}
|
||||
|
||||
public void drawItemOverlay(ItemStack stack, @Nullable String text, int x, int y) {
|
||||
public void renderItemOverlay(ItemStack stack, @Nullable String text, int x, int y) {
|
||||
try {
|
||||
this.itemRenderer.renderItemOverlayIntoGUI(font, stack, x, y, "");
|
||||
} catch (Throwable t) {
|
||||
@@ -380,11 +270,11 @@ public abstract class GuiBase<T extends Container> extends ContainerScreen {
|
||||
}
|
||||
|
||||
if (text != null) {
|
||||
drawQuantity(x, y, text);
|
||||
renderQuantity(x, y, text);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawQuantity(int x, int y, String qty) {
|
||||
public void renderQuantity(int x, int y, String qty) {
|
||||
boolean large = /* TODO font.getUnicodeFlag() ||*/ RS.INSTANCE.config.largeFont;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
@@ -411,60 +301,43 @@ public abstract class GuiBase<T extends Container> extends ContainerScreen {
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
public void drawString(int x, int y, String message) {
|
||||
drawString(x, y, message, 4210752);
|
||||
public void renderString(int x, int y, String message) {
|
||||
renderString(x, y, message, 4210752);
|
||||
}
|
||||
|
||||
public void drawString(int x, int y, String message, int color) {
|
||||
public void renderString(int x, int y, String message, int color) {
|
||||
GlStateManager.disableLighting();
|
||||
font.drawString(message, x, y, color);
|
||||
GlStateManager.enableLighting();
|
||||
}
|
||||
|
||||
public void drawTooltip(@Nonnull ItemStack stack, int x, int y, String lines) {
|
||||
drawTooltip(stack, x, y, Arrays.asList(lines.split("\n")));
|
||||
public void renderTooltip(int x, int y, String lines) {
|
||||
renderTooltip(ItemStack.EMPTY, x, y, lines);
|
||||
}
|
||||
|
||||
public void drawTooltip(int x, int y, String lines) {
|
||||
drawTooltip(ItemStack.EMPTY, x, y, lines);
|
||||
public void renderTooltip(@Nonnull ItemStack stack, int x, int y, String lines) {
|
||||
renderTooltip(stack, x, y, Arrays.asList(lines.split("\n")));
|
||||
}
|
||||
|
||||
public void drawTooltip(@Nonnull ItemStack stack, int x, int y, List<String> lines) {
|
||||
public void renderTooltip(@Nonnull ItemStack stack, int x, int y, List<String> lines) {
|
||||
GlStateManager.disableLighting();
|
||||
GuiUtils.drawHoveringText(stack, lines, x, y, width - guiLeft, height, -1, font);
|
||||
GlStateManager.enableLighting();
|
||||
}
|
||||
|
||||
// TODO: Probably can be removed.
|
||||
public void drawTexture(int x, int y, int textureX, int textureY, int width, int height) {
|
||||
this.blit(x, y, textureX, textureY, width, height);
|
||||
}
|
||||
|
||||
public static String t(String name, Object... format) {
|
||||
return I18n.format(name, format);
|
||||
}
|
||||
|
||||
public abstract void init(int x, int y);
|
||||
|
||||
public abstract void update(int x, int y);
|
||||
public abstract void tick(int x, int y);
|
||||
|
||||
public abstract void drawBackground(int x, int y, int mouseX, int mouseY);
|
||||
public abstract void renderBackground(int x, int y, int mouseX, int mouseY);
|
||||
|
||||
public abstract void drawForeground(int mouseX, int mouseY);
|
||||
|
||||
public int getGuiLeft() {
|
||||
return guiLeft;
|
||||
}
|
||||
|
||||
public int getGuiTop() {
|
||||
return guiTop;
|
||||
}
|
||||
public abstract void renderForeground(int mouseX, int mouseY);
|
||||
|
||||
public static <T> void executeLater(Class<T> clazz, Consumer<T> callback) {
|
||||
Queue<Consumer> queue = RUNNABLES.get(clazz);
|
||||
Queue<Consumer> queue = ACTIONS.get(clazz);
|
||||
|
||||
if (queue == null) {
|
||||
RUNNABLES.put(clazz, queue = new ArrayDeque<>());
|
||||
ACTIONS.put(clazz, queue = new ArrayDeque<>());
|
||||
}
|
||||
|
||||
queue.add(callback);
|
||||
|
@@ -2,11 +2,12 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerConstructor;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonCompare;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonConstuctorDrop;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonType;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonCompare;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonConstuctorDrop;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonType;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileConstructor;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class GuiConstructor extends GuiBase<ContainerConstructor> {
|
||||
@@ -25,19 +26,19 @@ public class GuiConstructor extends GuiBase<ContainerConstructor> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/constructor.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:constructor"));
|
||||
drawString(7, 43, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:constructor"));
|
||||
renderString(7, 43, I18n.format("container.inventory"));
|
||||
}
|
||||
}
|
||||
|
@@ -2,12 +2,13 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerController;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.Scrollbar;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.ScrollbarWidget;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.ClientNode;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileController;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import java.util.List;
|
||||
@@ -22,12 +23,14 @@ public class GuiController extends GuiBase<ContainerController> {
|
||||
private int barWidth = 16;
|
||||
private int barHeight = 59;
|
||||
|
||||
private ScrollbarWidget scrollbar;
|
||||
|
||||
public GuiController(ContainerController container, TileController controller, PlayerInventory inventory) {
|
||||
super(container, 176, 181, inventory, null);
|
||||
|
||||
this.controller = controller;
|
||||
|
||||
this.scrollbar = new Scrollbar(157, 20, 12, 59);
|
||||
this.scrollbar = new ScrollbarWidget(157, 20, 12, 59);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,7 +39,7 @@ public class GuiController extends GuiBase<ContainerController> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
if (scrollbar != null) {
|
||||
scrollbar.setEnabled(getRows() > VISIBLE_ROWS);
|
||||
scrollbar.setMaxOffset(getRows() - VISIBLE_ROWS);
|
||||
@@ -44,20 +47,20 @@ public class GuiController extends GuiBase<ContainerController> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/controller.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
|
||||
int barHeightNew = TileController.getEnergyScaled(TileController.ENERGY_STORED.getValue(), TileController.ENERGY_CAPACITY.getValue(), barHeight);
|
||||
|
||||
drawTexture(x + barX, y + barY + barHeight - barHeightNew, 178, barHeight - barHeightNew, barWidth, barHeightNew);
|
||||
blit(x + barX, y + barY + barHeight - barHeightNew, 178, barHeight - barHeightNew, barWidth, barHeightNew);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:controller." + controller.getControllerType().getId()));
|
||||
drawString(7, 87, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:controller." + controller.getControllerType().getId()));
|
||||
renderString(7, 87, I18n.format("container.inventory"));
|
||||
|
||||
int x = 33;
|
||||
int y = 26;
|
||||
@@ -74,19 +77,19 @@ public class GuiController extends GuiBase<ContainerController> {
|
||||
if (slot < nodes.size()) {
|
||||
ClientNode node = nodes.get(slot);
|
||||
|
||||
drawItem(x, y + 5, node.getStack());
|
||||
renderItem(x, y + 5, node.getStack());
|
||||
|
||||
float scale = /*TODO fontRenderer.getUnicodeFlag() ? 1F :*/ 0.5F;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scalef(scale, scale, 1);
|
||||
|
||||
drawString(
|
||||
renderString(
|
||||
RenderUtils.getOffsetOnScale(x + 1, scale),
|
||||
RenderUtils.getOffsetOnScale(y - 2, scale),
|
||||
trimNameIfNeeded(/*TODO !fontRenderer.getUnicodeFlag()*/false, node.getStack().getDisplayName().getString()) // TODO
|
||||
);
|
||||
drawString(RenderUtils.getOffsetOnScale(x + 21, scale), RenderUtils.getOffsetOnScale(y + 10, scale), node.getAmount() + "x");
|
||||
renderString(RenderUtils.getOffsetOnScale(x + 21, scale), RenderUtils.getOffsetOnScale(y + 10, scale), node.getAmount() + "x");
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
@@ -106,11 +109,11 @@ public class GuiController extends GuiBase<ContainerController> {
|
||||
}
|
||||
|
||||
if (nodeHovering != null) {
|
||||
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:energy_usage_minimal", nodeHovering.getEnergyUsage()));
|
||||
renderTooltip(mouseX, mouseY, I18n.format("misc.refinedstorage:energy_usage_minimal", nodeHovering.getEnergyUsage()));
|
||||
}
|
||||
|
||||
if (inBounds(barX, barY, barWidth, barHeight, mouseX, mouseY)) {
|
||||
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:energy_usage", TileController.ENERGY_USAGE.getValue()) + "\n" + t("misc.refinedstorage:energy_stored", TileController.ENERGY_STORED.getValue(), TileController.ENERGY_CAPACITY.getValue()));
|
||||
renderTooltip(mouseX, mouseY, I18n.format("misc.refinedstorage:energy_usage", TileController.ENERGY_USAGE.getValue()) + "\n" + I18n.format("misc.refinedstorage:energy_stored", TileController.ENERGY_STORED.getValue(), TileController.ENERGY_CAPACITY.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerCrafter;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileCrafter;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class GuiCrafter extends GuiBase<ContainerCrafter> {
|
||||
@@ -15,19 +16,19 @@ public class GuiCrafter extends GuiBase<ContainerCrafter> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/crafter.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, RenderUtils.shorten(t(TileCrafter.NAME.getValue()), 26));
|
||||
drawString(7, 43, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, RenderUtils.shorten(I18n.format(TileCrafter.NAME.getValue()), 26));
|
||||
renderString(7, 43, I18n.format("container.inventory"));
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,11 @@ import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCrafterManager;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerCrafterManager;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.SlotCrafterManager;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.*;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.ScrollbarWidget;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.SearchWidget;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonCrafterManagerSearchBoxMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonGridSize;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileCrafterManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
@@ -21,7 +25,8 @@ public class GuiCrafterManager extends GuiBase<ContainerCrafterManager> implemen
|
||||
private ContainerCrafterManager container;
|
||||
private NetworkNodeCrafterManager crafterManager;
|
||||
|
||||
private TextFieldSearch searchField;
|
||||
private ScrollbarWidget scrollbar;
|
||||
private SearchWidget searchField;
|
||||
|
||||
public GuiCrafterManager(NetworkNodeCrafterManager crafterManager, PlayerInventory inventory) {
|
||||
super(null, 193, 0, inventory, null);
|
||||
@@ -37,11 +42,12 @@ public class GuiCrafterManager extends GuiBase<ContainerCrafterManager> implemen
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
/* TODO
|
||||
@Override
|
||||
protected void calcHeight() {
|
||||
this.ySize = getTopHeight() + getBottomHeight() + (getVisibleRows() * 18);
|
||||
this.screenHeight = ySize;
|
||||
}
|
||||
this.ySize = ySize;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public int getTopHeight() {
|
||||
@@ -95,7 +101,7 @@ public class GuiCrafterManager extends GuiBase<ContainerCrafterManager> implemen
|
||||
addSideButton(new SideButtonCrafterManagerSearchBoxMode(this));
|
||||
addSideButton(new SideButtonGridSize(this, () -> crafterManager.getSize(), size -> TileDataManager.setParameter(TileCrafterManager.SIZE, size)));
|
||||
|
||||
this.scrollbar = new Scrollbar(174, getTopHeight(), 12, (getVisibleRows() * 18) - 2);
|
||||
this.scrollbar = new ScrollbarWidget(174, getTopHeight(), 12, (getVisibleRows() * 18) - 2);
|
||||
this.scrollbar.addListener((oldOffset, newOffset) -> {
|
||||
if (container != null) {
|
||||
container.initSlots(null);
|
||||
@@ -108,7 +114,7 @@ public class GuiCrafterManager extends GuiBase<ContainerCrafterManager> implemen
|
||||
int sy = y + 6 + 1;
|
||||
|
||||
if (searchField == null) {
|
||||
searchField = new TextFieldSearch(font, sx, sy, 88 - 6);
|
||||
searchField = new SearchWidget(font, sx, sy, 88 - 6);
|
||||
searchField.addListener(() -> container.initSlots(null));
|
||||
searchField.setMode(crafterManager.getSearchBoxMode());
|
||||
} else {
|
||||
@@ -118,16 +124,16 @@ public class GuiCrafterManager extends GuiBase<ContainerCrafterManager> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
scrollbar.setEnabled((getRows() - 1) >= getVisibleRows());
|
||||
scrollbar.setMaxOffset(getRows() - getVisibleRows());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/crafter_manager.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, getTopHeight());
|
||||
blit(x, y, 0, 0, xSize, getTopHeight());
|
||||
|
||||
int rows = getVisibleRows();
|
||||
|
||||
@@ -136,17 +142,17 @@ public class GuiCrafterManager extends GuiBase<ContainerCrafterManager> implemen
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
yy += 18;
|
||||
|
||||
drawTexture(x, yy, 0, getTopHeight() + (i > 0 ? (i == rows - 1 ? 18 * 2 : 18) : 0), screenWidth, 18);
|
||||
blit(x, yy, 0, getTopHeight() + (i > 0 ? (i == rows - 1 ? 18 * 2 : 18) : 0), xSize, 18);
|
||||
}
|
||||
|
||||
yy += 18;
|
||||
|
||||
drawTexture(x, yy, 0, getTopHeight() + (18 * 3), screenWidth, getBottomHeight());
|
||||
blit(x, yy, 0, getTopHeight() + (18 * 3), xSize, getBottomHeight());
|
||||
|
||||
if (container != null && crafterManager.isActive()) {
|
||||
for (Slot slot : container.inventorySlots) {
|
||||
if (slot instanceof SlotCrafterManager && slot.isEnabled()) {
|
||||
drawTexture(x + slot.xPos - 1, y + slot.yPos - 1, 0, 193, 18, 18);
|
||||
blit(x + slot.xPos - 1, y + slot.yPos - 1, 0, 193, 18, 18);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,9 +190,9 @@ public class GuiCrafterManager extends GuiBase<ContainerCrafterManager> implemen
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:crafter_manager"));
|
||||
drawString(7, getYPlayerInventory() - 12, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:crafter_manager"));
|
||||
renderString(7, getYPlayerInventory() - 12, I18n.format("container.inventory"));
|
||||
|
||||
if (container != null && crafterManager.isActive()) {
|
||||
for (Map.Entry<String, Integer> heading : container.getHeadings().entrySet()) {
|
||||
@@ -198,15 +204,15 @@ public class GuiCrafterManager extends GuiBase<ContainerCrafterManager> implemen
|
||||
|
||||
bindTexture("gui/crafter_manager.png");
|
||||
|
||||
drawTexture(7, y, 0, 174, 18 * 9, 18);
|
||||
blit(7, y, 0, 174, 18 * 9, 18);
|
||||
|
||||
drawString(7 + 4, y + 6, RenderUtils.shorten(I18n.format(heading.getKey()), 25));
|
||||
renderString(7 + 4, y + 6, RenderUtils.shorten(I18n.format(heading.getKey()), 25));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TextFieldSearch getSearchField() {
|
||||
public SearchWidget getSearchField() {
|
||||
return searchField;
|
||||
}
|
||||
}
|
||||
|
@@ -9,10 +9,12 @@ import com.raoulvdberge.refinedstorage.api.render.IElementDrawer;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.render.CraftingMonitorElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.render.ElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerCraftingMonitor;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.Scrollbar;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.TabList;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.ScrollbarWidget;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.TabListWidget;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.ICraftingMonitor;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
@@ -30,33 +32,6 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GuiCraftingMonitor extends GuiBase<ContainerCraftingMonitor> {
|
||||
public class CraftingMonitorElementDrawers extends ElementDrawers {
|
||||
private IElementDrawer<Integer> overlayDrawer = (x, y, color) -> {
|
||||
GlStateManager.color4f(1, 1, 1, 1);
|
||||
GlStateManager.disableLighting();
|
||||
fill(x, y, x + ITEM_WIDTH, y + ITEM_HEIGHT, color);
|
||||
};
|
||||
|
||||
private IElementDrawer errorDrawer = (x, y, nothing) -> {
|
||||
GlStateManager.color4f(1, 1, 1, 1);
|
||||
GlStateManager.disableLighting();
|
||||
|
||||
bindTexture("gui/crafting_preview.png");
|
||||
|
||||
drawTexture(x + ITEM_WIDTH - 12 - 2, y + ITEM_HEIGHT - 12 - 2, 0, 244, 12, 12);
|
||||
};
|
||||
|
||||
@Override
|
||||
public IElementDrawer<Integer> getOverlayDrawer() {
|
||||
return overlayDrawer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IElementDrawer getErrorDrawer() {
|
||||
return errorDrawer;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CraftingMonitorTask implements IGridTab {
|
||||
private UUID id;
|
||||
private ICraftingRequestInfo requested;
|
||||
@@ -80,7 +55,7 @@ public class GuiCraftingMonitor extends GuiBase<ContainerCraftingMonitor> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTooltip(int x, int y, int screenWidth, int screenHeight, FontRenderer fontRenderer) {
|
||||
public void drawTooltip(int x, int y, int xSize, int ySize, FontRenderer fontRenderer) {
|
||||
List<String> textLines = Lists.newArrayList(requested.getItem() != null ? requested.getItem().getDisplayName().getFormattedText() : requested.getFluid().getDisplayName().getFormattedText()); // TODO
|
||||
List<String> smallTextLines = Lists.newArrayList();
|
||||
|
||||
@@ -92,7 +67,7 @@ public class GuiCraftingMonitor extends GuiBase<ContainerCraftingMonitor> {
|
||||
smallTextLines.add(String.format("%02d:%02d", minutes, seconds));
|
||||
smallTextLines.add(String.format("%d%%", completionPercentage));
|
||||
|
||||
RenderUtils.drawTooltipWithSmallText(textLines, smallTextLines, true, ItemStack.EMPTY, x, y, screenWidth, screenHeight, fontRenderer);
|
||||
RenderUtils.drawTooltipWithSmallText(textLines, smallTextLines, true, ItemStack.EMPTY, x, y, xSize, ySize, fontRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,19 +92,21 @@ public class GuiCraftingMonitor extends GuiBase<ContainerCraftingMonitor> {
|
||||
private Button cancelButton;
|
||||
private Button cancelAllButton;
|
||||
|
||||
private ScrollbarWidget scrollbar;
|
||||
|
||||
private ICraftingMonitor craftingMonitor;
|
||||
|
||||
private List<IGridTab> tasks = Collections.emptyList();
|
||||
private TabList tabs;
|
||||
private TabListWidget tabs;
|
||||
|
||||
private IElementDrawers drawers = new CraftingMonitorElementDrawers();
|
||||
private IElementDrawers drawers = new CraftingMonitorElementDrawers(this, font, ITEM_WIDTH, ITEM_HEIGHT);
|
||||
|
||||
public GuiCraftingMonitor(ContainerCraftingMonitor container, ICraftingMonitor craftingMonitor, PlayerInventory inventory) {
|
||||
super(container, 254, 201, inventory, null);
|
||||
|
||||
this.craftingMonitor = craftingMonitor;
|
||||
|
||||
this.tabs = new TabList(this, new ElementDrawers(), () -> tasks, () -> (int) Math.floor((float) Math.max(0, tasks.size() - 1) / (float) ICraftingMonitor.TABS_PER_PAGE), craftingMonitor::getTabPage, () -> {
|
||||
this.tabs = new TabListWidget(this, new ElementDrawers(this, font), () -> tasks, () -> (int) Math.floor((float) Math.max(0, tasks.size() - 1) / (float) ICraftingMonitor.TABS_PER_PAGE), craftingMonitor::getTabPage, () -> {
|
||||
IGridTab tab = getCurrentTab();
|
||||
|
||||
if (tab == null) {
|
||||
@@ -139,7 +116,7 @@ public class GuiCraftingMonitor extends GuiBase<ContainerCraftingMonitor> {
|
||||
return tasks.indexOf(tab);
|
||||
}, ICraftingMonitor.TABS_PER_PAGE);
|
||||
|
||||
this.tabs.addListener(new TabList.ITabListListener() {
|
||||
this.tabs.addListener(new TabListWidget.ITabListListener() {
|
||||
@Override
|
||||
public void onSelectionChanged(int tab) {
|
||||
craftingMonitor.onTabSelectionChanged(Optional.of(((CraftingMonitorTask) tasks.get(tab)).id));
|
||||
@@ -176,20 +153,22 @@ public class GuiCraftingMonitor extends GuiBase<ContainerCraftingMonitor> {
|
||||
public void init(int x, int y) {
|
||||
this.tabs.init(xSize);
|
||||
|
||||
this.scrollbar = new Scrollbar(235, 20, 12, 149);
|
||||
this.scrollbar = new ScrollbarWidget(235, 20, 12, 149);
|
||||
|
||||
if (craftingMonitor.getRedstoneModeParameter() != null) {
|
||||
addSideButton(new SideButtonRedstoneMode(this, craftingMonitor.getRedstoneModeParameter()));
|
||||
}
|
||||
|
||||
String cancel = t("gui.cancel");
|
||||
String cancelAll = t("misc.refinedstorage:cancel_all");
|
||||
String cancel = I18n.format("gui.cancel");
|
||||
String cancelAll = I18n.format("misc.refinedstorage:cancel_all");
|
||||
|
||||
int cancelButtonWidth = 14 + font.getStringWidth(cancel);
|
||||
int cancelAllButtonWidth = 14 + font.getStringWidth(cancelAll);
|
||||
|
||||
this.cancelButton = addButton(x + 7, y + 201 - 20 - 7, cancelButtonWidth, 20, cancel, false, true);
|
||||
this.cancelAllButton = addButton(x + 7 + cancelButtonWidth + 4, y + 201 - 20 - 7, cancelAllButtonWidth, 20, cancelAll, false, true);
|
||||
this.cancelButton = addButton(x + 7, y + 201 - 20 - 7, cancelButtonWidth, 20, cancel, false, true, btn -> {
|
||||
});
|
||||
this.cancelAllButton = addButton(x + 7 + cancelButtonWidth + 4, y + 201 - 20 - 7, cancelAllButtonWidth, 20, cancelAll, false, true, btn -> {
|
||||
});
|
||||
}
|
||||
|
||||
private void updateScrollbar() {
|
||||
@@ -204,17 +183,17 @@ public class GuiCraftingMonitor extends GuiBase<ContainerCraftingMonitor> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
updateScrollbar();
|
||||
|
||||
this.tabs.update();
|
||||
|
||||
if (cancelButton != null) {
|
||||
cancelButton.active = hasValidTabSelected(); // TODO is it active?
|
||||
cancelButton.active = hasValidTabSelected();
|
||||
}
|
||||
|
||||
if (cancelAllButton != null) {
|
||||
cancelAllButton.active = tasks.size() > 0; // TODO is it active?
|
||||
cancelAllButton.active = tasks.size() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,21 +226,21 @@ public class GuiCraftingMonitor extends GuiBase<ContainerCraftingMonitor> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
if (craftingMonitor.isActive()) {
|
||||
tabs.drawBackground(x, y - tabs.getHeight());
|
||||
}
|
||||
|
||||
bindTexture("gui/crafting_preview.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
|
||||
tabs.drawForeground(x, y - tabs.getHeight(), mouseX, mouseY, craftingMonitor.isActive());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t(craftingMonitor.getGuiTitle()));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format(craftingMonitor.getGuiTitle()));
|
||||
|
||||
int item = scrollbar != null ? scrollbar.getOffset() * 3 : 0;
|
||||
|
||||
@@ -294,7 +273,7 @@ public class GuiCraftingMonitor extends GuiBase<ContainerCraftingMonitor> {
|
||||
}
|
||||
|
||||
if (itemSelectedTooltip != null && !itemSelectedTooltip.isEmpty()) {
|
||||
drawTooltip(mouseX, mouseY, I18n.format(itemSelectedTooltip));
|
||||
renderTooltip(mouseX, mouseY, I18n.format(itemSelectedTooltip));
|
||||
}
|
||||
|
||||
tabs.drawTooltip(font, mouseX, mouseY);
|
||||
|
@@ -4,17 +4,18 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskErrorType;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawer;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementError;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementFluidStack;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementItemStack;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.Scrollbar;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.render.CraftingPreviewElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.ScrollbarWidget;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
@@ -26,25 +27,13 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiCraftingPreview extends GuiBase {
|
||||
public class CraftingPreviewElementDrawers extends ElementDrawers {
|
||||
private IElementDrawer<Integer> overlayDrawer = (x, y, colour) -> {
|
||||
GlStateManager.color4f(1, 1, 1, 1);
|
||||
GlStateManager.disableLighting();
|
||||
|
||||
fill(x, y, x + 73, y + 29, colour);
|
||||
};
|
||||
|
||||
@Override
|
||||
public IElementDrawer<Integer> getOverlayDrawer() {
|
||||
return overlayDrawer;
|
||||
}
|
||||
}
|
||||
|
||||
private static final int VISIBLE_ROWS = 5;
|
||||
|
||||
private List<ICraftingPreviewElement> stacks;
|
||||
private Screen parent;
|
||||
|
||||
private ScrollbarWidget scrollbar;
|
||||
|
||||
private int hash;
|
||||
private int quantity;
|
||||
|
||||
@@ -54,7 +43,7 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
private ItemStack hoveringStack;
|
||||
private FluidStack hoveringFluid;
|
||||
|
||||
private IElementDrawers drawers = new CraftingPreviewElementDrawers();
|
||||
private IElementDrawers drawers = new CraftingPreviewElementDrawers(this, font);
|
||||
|
||||
private boolean fluids;
|
||||
|
||||
@@ -73,18 +62,22 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
this.quantity = quantity;
|
||||
this.fluids = fluids;
|
||||
|
||||
this.scrollbar = new Scrollbar(235, 20, 12, 149);
|
||||
this.scrollbar = new ScrollbarWidget(235, 20, 12, 149);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(int x, int y) {
|
||||
cancelButton = addButton(x + 55, y + 201 - 20 - 7, 50, 20, t("gui.cancel"));
|
||||
startButton = addButton(x + 129, y + 201 - 20 - 7, 50, 20, t("misc.refinedstorage:start"));
|
||||
startButton.active = stacks.stream().noneMatch(ICraftingPreviewElement::hasMissing) && getErrorType() == null; // TODO enabled?
|
||||
cancelButton = addButton(x + 55, y + 201 - 20 - 7, 50, 20, I18n.format("gui.cancel"), true, true, btn -> {
|
||||
});
|
||||
|
||||
startButton = addButton(x + 129, y + 201 - 20 - 7, 50, 20, I18n.format("misc.refinedstorage:start"), true, true, btn -> {
|
||||
});
|
||||
|
||||
startButton.active = stacks.stream().noneMatch(ICraftingPreviewElement::hasMissing) && getErrorType() == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
if (scrollbar != null) {
|
||||
scrollbar.setEnabled(getRows() > VISIBLE_ROWS);
|
||||
scrollbar.setMaxOffset(getRows() - VISIBLE_ROWS);
|
||||
@@ -101,10 +94,10 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/crafting_preview.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
|
||||
if (getErrorType() != null) {
|
||||
fill(x + 7, y + 20, x + 228, y + 169, 0xFFDBDBDB);
|
||||
@@ -112,8 +105,8 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:crafting_preview"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:crafting_preview"));
|
||||
|
||||
int x = 7;
|
||||
int y = 15;
|
||||
@@ -124,16 +117,16 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scalef(scale, scale, 1);
|
||||
|
||||
drawString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 11, scale), t("gui.refinedstorage:crafting_preview.error"));
|
||||
renderString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 11, scale), I18n.format("gui.refinedstorage:crafting_preview.error"));
|
||||
|
||||
switch (getErrorType()) {
|
||||
case RECURSIVE: {
|
||||
drawString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 21, scale), t("gui.refinedstorage:crafting_preview.error.recursive.0"));
|
||||
drawString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 31, scale), t("gui.refinedstorage:crafting_preview.error.recursive.1"));
|
||||
drawString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 41, scale), t("gui.refinedstorage:crafting_preview.error.recursive.2"));
|
||||
drawString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 51, scale), t("gui.refinedstorage:crafting_preview.error.recursive.3"));
|
||||
renderString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 21, scale), I18n.format("gui.refinedstorage:crafting_preview.error.recursive.0"));
|
||||
renderString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 31, scale), I18n.format("gui.refinedstorage:crafting_preview.error.recursive.1"));
|
||||
renderString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 41, scale), I18n.format("gui.refinedstorage:crafting_preview.error.recursive.2"));
|
||||
renderString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 51, scale), I18n.format("gui.refinedstorage:crafting_preview.error.recursive.3"));
|
||||
|
||||
drawString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 61, scale), t("gui.refinedstorage:crafting_preview.error.recursive.4"));
|
||||
renderString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 61, scale), I18n.format("gui.refinedstorage:crafting_preview.error.recursive.4"));
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
@@ -144,12 +137,12 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
if (output != null) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scalef(scale, scale, 1);
|
||||
drawString(RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy + 6, scale), output.getDisplayName().getFormattedText()); // TODO getFOrmattedText
|
||||
renderString(RenderUtils.getOffsetOnScale(x + 25, scale), RenderUtils.getOffsetOnScale(yy + 6, scale), output.getDisplayName().getFormattedText()); // TODO getFOrmattedText
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GlStateManager.enableDepthTest();
|
||||
drawItem(x + 5, yy, output);
|
||||
renderItem(x + 5, yy, output);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
yy += 17;
|
||||
@@ -159,8 +152,8 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
break;
|
||||
}
|
||||
case TOO_COMPLEX: {
|
||||
drawString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 21, scale), t("gui.refinedstorage:crafting_preview.error.too_complex.0"));
|
||||
drawString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 31, scale), t("gui.refinedstorage:crafting_preview.error.too_complex.1"));
|
||||
renderString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 21, scale), I18n.format("gui.refinedstorage:crafting_preview.error.too_complex.0"));
|
||||
renderString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 31, scale), I18n.format("gui.refinedstorage:crafting_preview.error.too_complex.1"));
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
@@ -208,9 +201,9 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
|
||||
if (hoveringStack != null) {
|
||||
drawTooltip(hoveringStack, mouseX, mouseY, hoveringStack.getTooltip(Minecraft.getInstance().player, Minecraft.getInstance().gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL));
|
||||
renderTooltip(hoveringStack, mouseX, mouseY, hoveringStack.getTooltip(Minecraft.getInstance().player, Minecraft.getInstance().gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL));
|
||||
} else if (hoveringFluid != null) {
|
||||
drawTooltip(mouseX, mouseY, hoveringFluid.getDisplayName().getFormattedText()); // TODO gft
|
||||
renderTooltip(mouseX, mouseY, hoveringFluid.getDisplayName().getFormattedText()); // TODO gft
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,8 +2,9 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerDestructor;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.*;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileDestructor;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class GuiDestructor extends GuiBase<ContainerDestructor> {
|
||||
@@ -25,19 +26,19 @@ public class GuiDestructor extends GuiBase<ContainerDestructor> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/destructor.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:destructor"));
|
||||
drawString(7, 43, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:destructor"));
|
||||
renderString(7, 43, I18n.format("container.inventory"));
|
||||
}
|
||||
}
|
||||
|
@@ -2,11 +2,12 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerDetector;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonCompare;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonDetectorMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonType;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonCompare;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonDetectorMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonType;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileDetector;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class GuiDetector extends GuiBase<ContainerDetector> {
|
||||
@@ -34,22 +35,22 @@ public class GuiDetector extends GuiBase<ContainerDetector> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/detector.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
|
||||
amount.renderButton(0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:detector"));
|
||||
drawString(7, 43, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:detector"));
|
||||
renderString(7, 43, I18n.format("container.inventory"));
|
||||
}
|
||||
|
||||
/* TODO
|
||||
|
@@ -2,8 +2,9 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerDiskManipulator;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.*;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileDiskManipulator;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class GuiDiskManipulator extends GuiBase<ContainerDiskManipulator> {
|
||||
@@ -21,22 +22,22 @@ public class GuiDiskManipulator extends GuiBase<ContainerDiskManipulator> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/disk_manipulator.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("block.refinedstorage:disk_manipulator.name"));
|
||||
drawString(7, 117, t("container.inventory"));
|
||||
drawString(43, 45, t("gui.refinedstorage:fluid_interface.in"));
|
||||
drawString(115, 45, t("gui.refinedstorage:fluid_interface.out"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("block.refinedstorage:disk_manipulator.name"));
|
||||
renderString(7, 117, I18n.format("container.inventory"));
|
||||
renderString(43, 45, I18n.format("gui.refinedstorage:fluid_interface.in"));
|
||||
renderString(115, 45, I18n.format("gui.refinedstorage:fluid_interface.out"));
|
||||
}
|
||||
}
|
||||
|
@@ -2,10 +2,11 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerExporter;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonCompare;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonType;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonCompare;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonType;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileExporter;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class GuiExporter extends GuiBase<ContainerExporter> {
|
||||
@@ -23,19 +24,19 @@ public class GuiExporter extends GuiBase<ContainerExporter> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/exporter.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:exporter"));
|
||||
drawString(7, 43, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:exporter"));
|
||||
renderString(7, 43, I18n.format("container.inventory"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,13 +1,18 @@
|
||||
package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerFilter;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonFilterType;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonFilterType;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemFilter;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageFilterUpdate;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||
|
||||
public class GuiFilter extends GuiBase<ContainerFilter> {
|
||||
@@ -19,29 +24,43 @@ public class GuiFilter extends GuiBase<ContainerFilter> {
|
||||
private String name;
|
||||
private int type;
|
||||
|
||||
private GuiCheckBox compareNbt;
|
||||
private GuiCheckBox toggleModFilter;
|
||||
private Button toggleMode;
|
||||
private TextFieldWidget nameField;
|
||||
|
||||
public GuiFilter(ContainerFilter container, PlayerInventory inventory) {
|
||||
super(container, 176, 231, inventory, null);
|
||||
public GuiFilter(ContainerFilter container, PlayerInventory inventory, ITextComponent title) {
|
||||
super(container, 176, 231, inventory, title);
|
||||
|
||||
this.stack = container.getStack();
|
||||
|
||||
/* TODO this.compare = ItemFilter.getCompare(container.getStack());
|
||||
this.compare = ItemFilter.getCompare(container.getStack());
|
||||
this.mode = ItemFilter.getMode(container.getStack());
|
||||
this.modFilter = ItemFilter.isModFilter(container.getStack());
|
||||
this.name = ItemFilter.getName(container.getStack());
|
||||
this.type = ItemFilter.getType(container.getStack());*/
|
||||
this.type = ItemFilter.getType(container.getStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(int x, int y) {
|
||||
compareNbt = addCheckBox(x + 7, y + 77, t("gui.refinedstorage:filter.compare_nbt"), (compare & IComparer.COMPARE_NBT) == IComparer.COMPARE_NBT);
|
||||
addCheckBox(x + 7, y + 77, I18n.format("gui.refinedstorage.filter.compare_nbt"), (compare & IComparer.COMPARE_NBT) == IComparer.COMPARE_NBT, btn -> {
|
||||
compare ^= IComparer.COMPARE_NBT;
|
||||
|
||||
toggleModFilter = addCheckBox(0, y + 71 + 25, t("gui.refinedstorage:filter.mod_filter"), modFilter);
|
||||
toggleMode = addButton(x + 7, y + 71 + 21, 0, 20, "");
|
||||
sendUpdate();
|
||||
});
|
||||
|
||||
toggleModFilter = addCheckBox(0, y + 71 + 25, I18n.format("gui.refinedstorage.filter.mod_filter"), modFilter, btn -> {
|
||||
modFilter = !modFilter;
|
||||
|
||||
sendUpdate();
|
||||
});
|
||||
|
||||
toggleMode = addButton(x + 7, y + 71 + 21, 0, 20, "", true, true, btn -> {
|
||||
mode = mode == IFilter.MODE_WHITELIST ? IFilter.MODE_BLACKLIST : IFilter.MODE_WHITELIST;
|
||||
|
||||
updateModeButton(mode);
|
||||
|
||||
sendUpdate();
|
||||
});
|
||||
|
||||
updateModeButton(mode);
|
||||
|
||||
@@ -52,12 +71,20 @@ public class GuiFilter extends GuiBase<ContainerFilter> {
|
||||
nameField.setCanLoseFocus(true);
|
||||
nameField.setFocused2(false);
|
||||
nameField.setTextColor(16777215);
|
||||
nameField.func_212954_a(name -> sendUpdate());
|
||||
|
||||
addButton(nameField);
|
||||
|
||||
addSideButton(new SideButtonFilterType(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPressed_3_) {
|
||||
return nameField.keyPressed(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_) || super.keyPressed(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
private void updateModeButton(int mode) {
|
||||
String text = mode == IFilter.MODE_WHITELIST ? t("sidebutton.refinedstorage:mode.whitelist") : t("sidebutton.refinedstorage:mode.blacklist");
|
||||
String text = mode == IFilter.MODE_WHITELIST ? I18n.format("sidebutton.refinedstorage.mode.whitelist") : I18n.format("sidebutton.refinedstorage.mode.blacklist");
|
||||
|
||||
toggleMode.setWidth(font.getStringWidth(text) + 12);
|
||||
toggleMode.setMessage(text);
|
||||
@@ -65,60 +92,22 @@ public class GuiFilter extends GuiBase<ContainerFilter> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/filter.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
|
||||
nameField.renderButton(0, 0, 0);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:filter"));
|
||||
drawString(7, 137, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, title.getFormattedText());
|
||||
renderString(7, 137, I18n.format("container.inventory"));
|
||||
}
|
||||
|
||||
/* TODO
|
||||
@Override
|
||||
protected void keyTyped(char character, int keyCode) throws IOException {
|
||||
if (!checkHotbarKeys(keyCode) && nameField.textboxKeyTyped(character, keyCode)) {
|
||||
sendUpdate();
|
||||
} else {
|
||||
super.keyTyped(character, keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int clickedButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, clickedButton);
|
||||
|
||||
nameField.mouseClicked(mouseX, mouseY, clickedButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(Button button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
|
||||
if (button == compareDamage) {
|
||||
compare ^= IComparer.COMPARE_DAMAGE;
|
||||
} else if (button == compareNbt) {
|
||||
compare ^= IComparer.COMPARE_NBT;
|
||||
} else if (button == toggleMode) {
|
||||
mode = mode == IFilter.MODE_WHITELIST ? IFilter.MODE_BLACKLIST : IFilter.MODE_WHITELIST;
|
||||
|
||||
updateModeButton(mode);
|
||||
} else if (button == toggleModFilter) {
|
||||
modFilter = !modFilter;
|
||||
}
|
||||
|
||||
sendUpdate();
|
||||
}*/
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
@@ -126,10 +115,10 @@ public class GuiFilter extends GuiBase<ContainerFilter> {
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
|
||||
// TODO ItemFilter.setType(stack, type);
|
||||
ItemFilter.setType(stack, type);
|
||||
}
|
||||
|
||||
public void sendUpdate() {
|
||||
// TODO RS.INSTANCE.network.sendToServer(new MessageFilterUpdate(compare, mode, modFilter, nameField.getText(), type));
|
||||
RS.NETWORK_HANDLER.sendToServer(new MessageFilterUpdate(compare, mode, modFilter, nameField.getText(), type));
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerFluidAmount;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -35,12 +36,12 @@ public class GuiFluidAmount extends GuiAmountSpecifying<ContainerFluidAmount> {
|
||||
|
||||
@Override
|
||||
protected String getOkButtonText() {
|
||||
return t("misc.refinedstorage:set");
|
||||
return I18n.format("misc.refinedstorage:set");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getGuiTitle() {
|
||||
return t("gui.refinedstorage:fluid_amount");
|
||||
return I18n.format("gui.refinedstorage:fluid_amount");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -3,14 +3,15 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidInterface;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerFluidInterface;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.render.FluidRenderer;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class GuiFluidInterface extends GuiBase<ContainerFluidInterface> {
|
||||
private static final RenderUtils.FluidRenderer TANK_RENDERER = new RenderUtils.FluidRenderer(NetworkNodeFluidInterface.TANK_CAPACITY, 12, 47);
|
||||
private static final FluidRenderer TANK_RENDERER = new FluidRenderer(NetworkNodeFluidInterface.TANK_CAPACITY, 12, 47);
|
||||
|
||||
public GuiFluidInterface(ContainerFluidInterface container, PlayerInventory inventory) {
|
||||
super(container, 211, 204, inventory, null);
|
||||
@@ -22,39 +23,39 @@ public class GuiFluidInterface extends GuiBase<ContainerFluidInterface> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/fluid_interface.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
|
||||
if (TileFluidInterface.TANK_IN.getValue() != null) {
|
||||
TANK_RENDERER.draw(minecraft, x + 46, y + 56, TileFluidInterface.TANK_IN.getValue());
|
||||
TANK_RENDERER.render(x + 46, y + 56, TileFluidInterface.TANK_IN.getValue());
|
||||
}
|
||||
|
||||
if (TileFluidInterface.TANK_OUT.getValue() != null) {
|
||||
TANK_RENDERER.draw(minecraft, x + 118, y + 56, TileFluidInterface.TANK_OUT.getValue());
|
||||
TANK_RENDERER.render(x + 118, y + 56, TileFluidInterface.TANK_OUT.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:fluid_interface"));
|
||||
drawString(43 + 4, 20, t("gui.refinedstorage:fluid_interface.in"));
|
||||
drawString(115 + 1, 20, t("gui.refinedstorage:fluid_interface.out"));
|
||||
drawString(7, 111, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:fluid_interface"));
|
||||
renderString(43 + 4, 20, I18n.format("gui.refinedstorage:fluid_interface.in"));
|
||||
renderString(115 + 1, 20, I18n.format("gui.refinedstorage:fluid_interface.out"));
|
||||
renderString(7, 111, I18n.format("container.inventory"));
|
||||
|
||||
// TODO getFormattedText
|
||||
if (inBounds(46, 56, 12, 47, mouseX, mouseY) && TileFluidInterface.TANK_IN.getValue() != null) {
|
||||
drawTooltip(mouseX, mouseY, TileFluidInterface.TANK_IN.getValue().getDisplayName().getFormattedText() + "\n" + TextFormatting.GRAY + API.instance().getQuantityFormatter().formatInBucketForm(TileFluidInterface.TANK_IN.getValue().getAmount()) + TextFormatting.RESET);
|
||||
renderTooltip(mouseX, mouseY, TileFluidInterface.TANK_IN.getValue().getDisplayName().getFormattedText() + "\n" + TextFormatting.GRAY + API.instance().getQuantityFormatter().formatInBucketForm(TileFluidInterface.TANK_IN.getValue().getAmount()) + TextFormatting.RESET);
|
||||
}
|
||||
|
||||
// TODO getFormattedText
|
||||
if (inBounds(118, 56, 12, 47, mouseX, mouseY) && TileFluidInterface.TANK_OUT.getValue() != null) {
|
||||
drawTooltip(mouseX, mouseY, TileFluidInterface.TANK_OUT.getValue().getDisplayName().getFormattedText() + "\n" + TextFormatting.GRAY + API.instance().getQuantityFormatter().formatInBucketForm(TileFluidInterface.TANK_OUT.getValue().getAmount()) + TextFormatting.RESET);
|
||||
renderTooltip(mouseX, mouseY, TileFluidInterface.TANK_OUT.getValue().getDisplayName().getFormattedText() + "\n" + TextFormatting.GRAY + API.instance().getQuantityFormatter().formatInBucketForm(TileFluidInterface.TANK_OUT.getValue().getAmount()) + TextFormatting.RESET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,11 +2,12 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerImporter;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonCompare;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonType;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonCompare;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonType;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileImporter;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class GuiImporter extends GuiBase<ContainerImporter> {
|
||||
@@ -26,19 +27,19 @@ public class GuiImporter extends GuiBase<ContainerImporter> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/importer.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:importer"));
|
||||
drawString(7, 43, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:importer"));
|
||||
renderString(7, 43, I18n.format("container.inventory"));
|
||||
}
|
||||
}
|
||||
|
@@ -2,9 +2,10 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerInterface;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonCompare;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonCompare;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileInterface;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class GuiInterface extends GuiBase<ContainerInterface> {
|
||||
@@ -20,20 +21,20 @@ public class GuiInterface extends GuiBase<ContainerInterface> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/interface.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:interface.import"));
|
||||
drawString(7, 42, t("gui.refinedstorage:interface.export"));
|
||||
drawString(7, 122, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:interface.import"));
|
||||
renderString(7, 42, I18n.format("gui.refinedstorage:interface.export"));
|
||||
renderString(7, 122, I18n.format("container.inventory"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerNetworkTransmitter;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileNetworkTransmitter;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class GuiNetworkTransmitter extends GuiBase<ContainerNetworkTransmitter> {
|
||||
@@ -20,33 +21,33 @@ public class GuiNetworkTransmitter extends GuiBase<ContainerNetworkTransmitter>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/network_transmitter.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:network_transmitter"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:network_transmitter"));
|
||||
|
||||
String distance;
|
||||
|
||||
if (networkTransmitter.getNode().getNetworkCard().getStackInSlot(0).isEmpty()) {
|
||||
distance = t("gui.refinedstorage:network_transmitter.missing_card");
|
||||
distance = I18n.format("gui.refinedstorage:network_transmitter.missing_card");
|
||||
} else if (TileNetworkTransmitter.RECEIVER_DIMENSION.getValue() != networkTransmitter.getWorld().getDimension().getType().getId()) {
|
||||
distance = t("gui.refinedstorage:network_transmitter.dimension", TileNetworkTransmitter.RECEIVER_DIMENSION.getValue());
|
||||
distance = I18n.format("gui.refinedstorage:network_transmitter.dimension", TileNetworkTransmitter.RECEIVER_DIMENSION.getValue());
|
||||
} else if (TileNetworkTransmitter.DISTANCE.getValue() != -1) {
|
||||
distance = t("gui.refinedstorage:network_transmitter.distance", TileNetworkTransmitter.DISTANCE.getValue());
|
||||
distance = I18n.format("gui.refinedstorage:network_transmitter.distance", TileNetworkTransmitter.DISTANCE.getValue());
|
||||
} else {
|
||||
distance = t("gui.refinedstorage:network_transmitter.missing_card");
|
||||
distance = I18n.format("gui.refinedstorage:network_transmitter.missing_card");
|
||||
}
|
||||
|
||||
drawString(51, 24, distance);
|
||||
drawString(7, 42, t("container.inventory"));
|
||||
renderString(51, 24, distance);
|
||||
renderString(7, 42, I18n.format("container.inventory"));
|
||||
}
|
||||
}
|
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
@@ -29,12 +30,12 @@ public class GuiPriority extends GuiAmountSpecifying<Container> {
|
||||
|
||||
@Override
|
||||
protected String getOkButtonText() {
|
||||
return t("misc.refinedstorage:set");
|
||||
return I18n.format("misc.refinedstorage:set");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getGuiTitle() {
|
||||
return t("misc.refinedstorage:priority");
|
||||
return I18n.format("misc.refinedstorage:priority");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -3,12 +3,13 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IGuiReaderWriter;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerReaderWriter;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.Scrollbar;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.ScrollbarWidget;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -26,6 +27,8 @@ public class GuiReaderWriter extends GuiBase<ContainerReaderWriter> {
|
||||
private Button add;
|
||||
private Button remove;
|
||||
private TextFieldWidget name;
|
||||
private ScrollbarWidget scrollbar;
|
||||
|
||||
private IGuiReaderWriter readerWriter;
|
||||
|
||||
private int itemSelected = -1;
|
||||
@@ -36,15 +39,19 @@ public class GuiReaderWriter extends GuiBase<ContainerReaderWriter> {
|
||||
super(container, 176, 209, inventory, null);
|
||||
|
||||
this.readerWriter = readerWriter;
|
||||
this.scrollbar = new Scrollbar(157, 39, 12, 71);
|
||||
this.scrollbar = new ScrollbarWidget(157, 39, 12, 71);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(int x, int y) {
|
||||
addSideButton(new SideButtonRedstoneMode(this, readerWriter.getRedstoneModeParameter()));
|
||||
|
||||
add = addButton(x + 128, y + 15, 20, 20, "+");
|
||||
remove = addButton(x + 150, y + 15, 20, 20, "-");
|
||||
add = addButton(x + 128, y + 15, 20, 20, "+", true, true, btn -> {
|
||||
});
|
||||
|
||||
remove = addButton(x + 150, y + 15, 20, 20, "-", true, true, btn -> {
|
||||
});
|
||||
|
||||
name = new TextFieldWidget(font, x + 8 + 1, y + 20 + 1, 107, font.FONT_HEIGHT, "");
|
||||
name.setEnableBackgroundDrawing(false);
|
||||
name.setVisible(true);
|
||||
@@ -67,7 +74,7 @@ public class GuiReaderWriter extends GuiBase<ContainerReaderWriter> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
if (scrollbar != null) {
|
||||
scrollbar.setEnabled(getRows() > VISIBLE_ROWS);
|
||||
scrollbar.setMaxOffset(getRows() - VISIBLE_ROWS);
|
||||
@@ -83,25 +90,25 @@ public class GuiReaderWriter extends GuiBase<ContainerReaderWriter> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/readerwriter.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
|
||||
if (itemSelectedX != -1 &&
|
||||
itemSelectedY != -1 &&
|
||||
itemSelected >= 0 &&
|
||||
itemSelected < getChannels().size()) {
|
||||
drawTexture(x + itemSelectedX, y + itemSelectedY, 0, 216, ITEM_WIDTH, ITEM_HEIGHT);
|
||||
blit(x + itemSelectedX, y + itemSelectedY, 0, 216, ITEM_WIDTH, ITEM_HEIGHT);
|
||||
}
|
||||
|
||||
name.renderButton(0, 0, 0); // TODO is still needed with the new widget stuffs?
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t(readerWriter.getTitle()));
|
||||
drawString(7, 115, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format(readerWriter.getTitle()));
|
||||
renderString(7, 115, I18n.format("container.inventory"));
|
||||
|
||||
int x = 8;
|
||||
int y = 39;
|
||||
@@ -120,7 +127,7 @@ public class GuiReaderWriter extends GuiBase<ContainerReaderWriter> {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scalef(scale, scale, 1);
|
||||
|
||||
drawString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 7, scale), getChannels().get(item));
|
||||
renderString(RenderUtils.getOffsetOnScale(x + 5, scale), RenderUtils.getOffsetOnScale(y + 7, scale), getChannels().get(item));
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerRelay;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileRelay;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class GuiRelay extends GuiBase<ContainerRelay> {
|
||||
@@ -16,19 +17,19 @@ public class GuiRelay extends GuiBase<ContainerRelay> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/relay.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:relay"));
|
||||
drawString(7, 39, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:relay"));
|
||||
renderString(7, 39, I18n.format("container.inventory"));
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerSecurityManager;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileSecurityManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
@@ -25,16 +25,27 @@ public class GuiSecurityManager extends GuiBase<ContainerSecurityManager> {
|
||||
|
||||
int padding = 15;
|
||||
|
||||
permissions[0] = addCheckBox(x + 7, y + 93, I18n.format("gui.refinedstorage.security_manager.permission.0"), false);
|
||||
permissions[1] = addCheckBox(permissions[0].x, permissions[0].y + padding, I18n.format("gui.refinedstorage.security_manager.permission.1"), false);
|
||||
permissions[2] = addCheckBox(permissions[1].x, permissions[1].y + padding, I18n.format("gui.refinedstorage.security_manager.permission.2"), false);
|
||||
permissions[3] = addCheckBox(permissions[0].x + 90, permissions[0].y, I18n.format("gui.refinedstorage.security_manager.permission.3"), false);
|
||||
permissions[4] = addCheckBox(permissions[3].x, permissions[3].y + padding, I18n.format("gui.refinedstorage.security_manager.permission.4"), false);
|
||||
permissions[5] = addCheckBox(permissions[4].x, permissions[4].y + padding, I18n.format("gui.refinedstorage.security_manager.permission.5"), false);
|
||||
permissions[0] = addCheckBox(x + 7, y + 93, I18n.format("gui.refinedstorage.security_manager.permission.0"), false, btn -> {
|
||||
});
|
||||
|
||||
permissions[1] = addCheckBox(permissions[0].x, permissions[0].y + padding, I18n.format("gui.refinedstorage.security_manager.permission.1"), false, btn -> {
|
||||
});
|
||||
|
||||
permissions[2] = addCheckBox(permissions[1].x, permissions[1].y + padding, I18n.format("gui.refinedstorage.security_manager.permission.2"), false, btn -> {
|
||||
});
|
||||
|
||||
permissions[3] = addCheckBox(permissions[0].x + 90, permissions[0].y, I18n.format("gui.refinedstorage.security_manager.permission.3"), false, btn -> {
|
||||
});
|
||||
|
||||
permissions[4] = addCheckBox(permissions[3].x, permissions[3].y + padding, I18n.format("gui.refinedstorage.security_manager.permission.4"), false, btn -> {
|
||||
});
|
||||
|
||||
permissions[5] = addCheckBox(permissions[4].x, permissions[4].y + padding, I18n.format("gui.refinedstorage.security_manager.permission.5"), false, btn -> {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
ItemStack card = securityManager.getNode().getEditCard().getStackInSlot(0);
|
||||
|
||||
for (Permission permission : Permission.values()) {
|
||||
@@ -55,23 +66,23 @@ public class GuiSecurityManager extends GuiBase<ContainerSecurityManager> {
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/security_manager.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:security_manager"));
|
||||
drawString(7, 59, t("gui.refinedstorage:security_manager.configure"));
|
||||
drawString(7, 140, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:security_manager"));
|
||||
renderString(7, 59, I18n.format("gui.refinedstorage:security_manager.configure"));
|
||||
renderString(7, 140, I18n.format("container.inventory"));
|
||||
|
||||
for (int i = 0; i < permissions.length; ++i) {
|
||||
GuiCheckBox permission = permissions[i];
|
||||
|
||||
if (inBounds(permission.x - guiLeft, permission.y - guiTop, permission.getWidth(), permission.getHeight(), mouseX, mouseY)) {
|
||||
drawTooltip(mouseX, mouseY, I18n.format("gui.refinedstorage:security_manager.permission." + i + ".tooltip"));
|
||||
renderTooltip(mouseX, mouseY, I18n.format("gui.refinedstorage:security_manager.permission." + i + ".tooltip"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,8 +4,9 @@ import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IGuiStorage;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerBase;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.*;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.*;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
@@ -53,39 +54,40 @@ public class GuiStorage extends GuiBase<ContainerBase> {
|
||||
addSideButton(new SideButtonAccessType(this, gui.getAccessTypeParameter()));
|
||||
}
|
||||
|
||||
int buttonWidth = 10 + font.getStringWidth(t("misc.refinedstorage:priority"));
|
||||
int buttonWidth = 10 + font.getStringWidth(I18n.format("misc.refinedstorage:priority"));
|
||||
|
||||
priorityButton = addButton(x + 169 - buttonWidth, y + 41, buttonWidth, 20, t("misc.refinedstorage:priority"));
|
||||
priorityButton = addButton(x + 169 - buttonWidth, y + 41, buttonWidth, 20, I18n.format("misc.refinedstorage:priority"), true, true, btn -> {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture(texture);
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
|
||||
int barHeightNew = (int) ((float) gui.getStored() / (float) gui.getCapacity() * (float) barHeight);
|
||||
|
||||
drawTexture(x + barX, y + barY + barHeight - barHeightNew, 179, barHeight - barHeightNew, barWidth, barHeightNew);
|
||||
blit(x + barX, y + barY + barHeight - barHeightNew, 179, barHeight - barHeightNew, barWidth, barHeightNew);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t(gui.getGuiTitle()));
|
||||
drawString(7, 42, gui.getCapacity() == -1 ?
|
||||
t("misc.refinedstorage.storage.stored_minimal", API.instance().getQuantityFormatter().formatWithUnits(gui.getStored())) :
|
||||
t("misc.refinedstorage.storage.stored_capacity_minimal", API.instance().getQuantityFormatter().formatWithUnits(gui.getStored()), API.instance().getQuantityFormatter().formatWithUnits(gui.getCapacity()))
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format(gui.getGuiTitle()));
|
||||
renderString(7, 42, gui.getCapacity() == -1 ?
|
||||
I18n.format("misc.refinedstorage.storage.stored_minimal", API.instance().getQuantityFormatter().formatWithUnits(gui.getStored())) :
|
||||
I18n.format("misc.refinedstorage.storage.stored_capacity_minimal", API.instance().getQuantityFormatter().formatWithUnits(gui.getStored()), API.instance().getQuantityFormatter().formatWithUnits(gui.getCapacity()))
|
||||
);
|
||||
|
||||
if (texture.contains("disk_drive")) { // HACK!
|
||||
drawString(79, 42, t("gui.refinedstorage:disk_drive.disks"));
|
||||
renderString(79, 42, I18n.format("gui.refinedstorage:disk_drive.disks"));
|
||||
}
|
||||
|
||||
drawString(7, 129, t("container.inventory"));
|
||||
renderString(7, 129, I18n.format("container.inventory"));
|
||||
|
||||
if (inBounds(barX, barY, barWidth, barHeight, mouseX, mouseY)) {
|
||||
int full = 0;
|
||||
@@ -94,10 +96,10 @@ public class GuiStorage extends GuiBase<ContainerBase> {
|
||||
full = (int) ((float) gui.getStored() / (float) gui.getCapacity() * 100f);
|
||||
}
|
||||
|
||||
drawTooltip(mouseX, mouseY, (gui.getCapacity() == -1 ?
|
||||
t("misc.refinedstorage.storage.stored_minimal", API.instance().getQuantityFormatter().format(gui.getStored())) :
|
||||
t("misc.refinedstorage.storage.stored_capacity_minimal", API.instance().getQuantityFormatter().format(gui.getStored()), API.instance().getQuantityFormatter().format(gui.getCapacity()))
|
||||
) + "\n" + TextFormatting.GRAY + t("misc.refinedstorage.storage.full", full));
|
||||
renderTooltip(mouseX, mouseY, (gui.getCapacity() == -1 ?
|
||||
I18n.format("misc.refinedstorage.storage.stored_minimal", API.instance().getQuantityFormatter().format(gui.getStored())) :
|
||||
I18n.format("misc.refinedstorage.storage.stored_capacity_minimal", API.instance().getQuantityFormatter().format(gui.getStored()), API.instance().getQuantityFormatter().format(gui.getCapacity()))
|
||||
) + "\n" + TextFormatting.GRAY + I18n.format("misc.refinedstorage.storage.full", full));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,8 +2,9 @@ package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerStorageMonitor;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonCompare;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonCompare;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileStorageMonitor;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class GuiStorageMonitor extends GuiBase<ContainerStorageMonitor> {
|
||||
@@ -17,19 +18,19 @@ public class GuiStorageMonitor extends GuiBase<ContainerStorageMonitor> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/storage_monitor.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:storage_monitor"));
|
||||
drawString(7, 43, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:storage_monitor"));
|
||||
renderString(7, 43, I18n.format("container.inventory"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerWirelessTransmitter;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileWirelessTransmitter;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
|
||||
public class GuiWirelessTransmitter extends GuiBase<ContainerWirelessTransmitter> {
|
||||
@@ -16,20 +17,20 @@ public class GuiWirelessTransmitter extends GuiBase<ContainerWirelessTransmitter
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
bindTexture("gui/wireless_transmitter.png");
|
||||
|
||||
drawTexture(x, y, 0, 0, screenWidth, screenHeight);
|
||||
blit(x, y, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t("gui.refinedstorage:wireless_transmitter"));
|
||||
drawString(28, 25, t("gui.refinedstorage:wireless_transmitter.distance", TileWirelessTransmitter.RANGE.getValue()));
|
||||
drawString(7, 43, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format("gui.refinedstorage:wireless_transmitter"));
|
||||
renderString(28, 25, I18n.format("gui.refinedstorage:wireless_transmitter.distance", TileWirelessTransmitter.RANGE.getValue()));
|
||||
renderString(7, 43, I18n.format("container.inventory"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.raoulvdberge.refinedstorage.gui;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonCrafterMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.SideButtonCrafterMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameterClientListener;
|
||||
|
||||
public class TileDataParameterClientListenerCrafter implements TileDataParameterClientListener<Boolean> {
|
||||
|
@@ -1,5 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
|
||||
public interface ScrollbarListener {
|
||||
void onOffsetChanged(int oldOffset, int newOffset);
|
||||
}
|
@@ -6,16 +6,20 @@ import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.render.ElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.gui.IResizableDisplay;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.*;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.sorting.*;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.view.GridViewFluid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.view.GridViewItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.view.IGridView;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.ScrollbarWidget;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.SearchWidget;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.TabListWidget;
|
||||
import com.raoulvdberge.refinedstorage.gui.widget.sidebutton.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid;
|
||||
@@ -34,12 +38,14 @@ import java.util.List;
|
||||
public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay {
|
||||
private IGridView view;
|
||||
|
||||
private TextFieldSearch searchField;
|
||||
private SearchWidget searchField;
|
||||
private GuiCheckBox oredictPattern;
|
||||
private GuiCheckBox processingPattern;
|
||||
|
||||
private ScrollbarWidget scrollbar;
|
||||
|
||||
private IGrid grid;
|
||||
private TabList tabs;
|
||||
private TabListWidget tabs;
|
||||
|
||||
private boolean wasConnected;
|
||||
|
||||
@@ -51,8 +57,8 @@ public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay
|
||||
this.grid = grid;
|
||||
this.view = grid.getGridType() == GridType.FLUID ? new GridViewFluid(this, getDefaultSorter(), getSorters()) : new GridViewItem(this, getDefaultSorter(), getSorters());
|
||||
this.wasConnected = this.grid.isActive();
|
||||
this.tabs = new TabList(this, new ElementDrawers(), grid::getTabs, grid::getTotalTabPages, grid::getTabPage, grid::getTabSelected, IGrid.TABS_PER_PAGE);
|
||||
this.tabs.addListener(new TabList.ITabListListener() {
|
||||
this.tabs = new TabListWidget(this, new ElementDrawers(this, font), grid::getTabs, grid::getTotalTabPages, grid::getTabPage, grid::getTabSelected, IGrid.TABS_PER_PAGE);
|
||||
this.tabs.addListener(new TabListWidget.ITabListListener() {
|
||||
@Override
|
||||
public void onSelectionChanged(int tab) {
|
||||
grid.onTabSelectionChanged(tab);
|
||||
@@ -65,19 +71,20 @@ public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay
|
||||
});
|
||||
}
|
||||
|
||||
/* TODO - calcHeight
|
||||
@Override
|
||||
protected void calcHeight() {
|
||||
this.ySize = getTopHeight() + getBottomHeight() + (getVisibleRows() * 18);
|
||||
this.screenHeight = ySize;
|
||||
}
|
||||
this.ySize = ySize;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void init(int x, int y) {
|
||||
((ContainerGrid) this.container).initSlots();
|
||||
container.initSlots();
|
||||
|
||||
this.tabs.init(xSize - 32);
|
||||
|
||||
this.scrollbar = new Scrollbar(174, getTopHeight(), 12, (getVisibleRows() * 18) - 2);
|
||||
this.scrollbar = new ScrollbarWidget(174, getTopHeight(), 12, (getVisibleRows() * 18) - 2);
|
||||
|
||||
if (grid instanceof NetworkNodeGrid || grid instanceof TilePortableGrid) {
|
||||
addSideButton(new SideButtonRedstoneMode(this, grid instanceof NetworkNodeGrid ? TileGrid.REDSTONE_MODE : TilePortableGrid.REDSTONE_MODE));
|
||||
@@ -87,7 +94,7 @@ public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay
|
||||
int sy = y + 6 + 1;
|
||||
|
||||
if (searchField == null) {
|
||||
searchField = new TextFieldSearch(font, sx, sy, 88 - 6);
|
||||
searchField = new SearchWidget(font, sx, sy, 88 - 6);
|
||||
searchField.addListener(() -> {
|
||||
this.getView().sort(); // Use getter since this view can be replaced.
|
||||
});
|
||||
@@ -107,7 +114,8 @@ public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay
|
||||
addSideButton(new SideButtonGridSize(this, () -> grid.getSize(), size -> grid.onSizeChanged(size)));
|
||||
|
||||
if (grid.getGridType() == GridType.PATTERN) {
|
||||
processingPattern = addCheckBox(x + 7, y + getTopHeight() + (getVisibleRows() * 18) + 60, t("misc.refinedstorage.processing"), TileGrid.PROCESSING_PATTERN.getValue());
|
||||
processingPattern = addCheckBox(x + 7, y + getTopHeight() + (getVisibleRows() * 18) + 60, I18n.format("misc.refinedstorage.processing"), TileGrid.PROCESSING_PATTERN.getValue(), btn -> {
|
||||
});
|
||||
|
||||
boolean showOredict = true;
|
||||
if (((NetworkNodeGrid) grid).isProcessingPattern() && ((NetworkNodeGrid) grid).getType() == IType.FLUIDS) {
|
||||
@@ -115,7 +123,8 @@ public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay
|
||||
}
|
||||
|
||||
if (showOredict) {
|
||||
oredictPattern = addCheckBox(processingPattern.x + processingPattern.getWidth() + 5, y + getTopHeight() + (getVisibleRows() * 18) + 60, t("misc.refinedstorage:oredict"), TileGrid.OREDICT_PATTERN.getValue());
|
||||
oredictPattern = addCheckBox(processingPattern.x + processingPattern.getWidth() + 5, y + getTopHeight() + (getVisibleRows() * 18) + 60, I18n.format("misc.refinedstorage:oredict"), TileGrid.OREDICT_PATTERN.getValue(), btn -> {
|
||||
});
|
||||
}
|
||||
|
||||
addSideButton(new SideButtonType(this, TileGrid.PROCESSING_TYPE));
|
||||
@@ -137,7 +146,7 @@ public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
public void tick(int x, int y) {
|
||||
if (wasConnected != grid.isActive()) {
|
||||
wasConnected = grid.isActive();
|
||||
|
||||
@@ -249,7 +258,7 @@ public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(int x, int y, int mouseX, int mouseY) {
|
||||
public void renderBackground(int x, int y, int mouseX, int mouseY) {
|
||||
tabs.drawBackground(x, y - tabs.getHeight());
|
||||
|
||||
if (grid instanceof IPortableGrid) {
|
||||
@@ -264,22 +273,22 @@ public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay
|
||||
|
||||
int yy = y;
|
||||
|
||||
drawTexture(x, yy, 0, 0, screenWidth - 34, getTopHeight());
|
||||
blit(x, yy, 0, 0, xSize - 34, getTopHeight());
|
||||
|
||||
// Filters and/or portable grid disk
|
||||
drawTexture(x + screenWidth - 34 + 4, y, 197, 0, 30, grid instanceof IPortableGrid ? 114 : 82);
|
||||
blit(x + xSize - 34 + 4, y, 197, 0, 30, grid instanceof IPortableGrid ? 114 : 82);
|
||||
|
||||
int rows = getVisibleRows();
|
||||
|
||||
for (int i = 0; i < rows; ++i) {
|
||||
yy += 18;
|
||||
|
||||
drawTexture(x, yy, 0, getTopHeight() + (i > 0 ? (i == rows - 1 ? 18 * 2 : 18) : 0), screenWidth - 34, 18);
|
||||
blit(x, yy, 0, getTopHeight() + (i > 0 ? (i == rows - 1 ? 18 * 2 : 18) : 0), xSize - 34, 18);
|
||||
}
|
||||
|
||||
yy += 18;
|
||||
|
||||
drawTexture(x, yy, 0, getTopHeight() + (18 * 3), screenWidth - 34, getBottomHeight());
|
||||
blit(x, yy, 0, getTopHeight() + (18 * 3), xSize - 34, getBottomHeight());
|
||||
|
||||
if (grid.getGridType() == GridType.PATTERN) {
|
||||
int ty = 0;
|
||||
@@ -292,7 +301,7 @@ public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay
|
||||
ty = 2;
|
||||
}
|
||||
|
||||
drawTexture(x + 172, y + getTopHeight() + (getVisibleRows() * 18) + 22, 240, ty * 16, 16, 16);
|
||||
blit(x + 172, y + getTopHeight() + (getVisibleRows() * 18) + 22, 240, ty * 16, 16, 16);
|
||||
}
|
||||
|
||||
tabs.drawForeground(x, y - tabs.getHeight(), mouseX, mouseY, true);
|
||||
@@ -314,9 +323,9 @@ public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground(int mouseX, int mouseY) {
|
||||
drawString(7, 7, t(grid.getGuiTitle()));
|
||||
drawString(7, getYPlayerInventory() - 12, t("container.inventory"));
|
||||
public void renderForeground(int mouseX, int mouseY) {
|
||||
renderString(7, 7, I18n.format(grid.getGuiTitle()));
|
||||
renderString(7, getYPlayerInventory() - 12, I18n.format("container.inventory"));
|
||||
|
||||
int x = 8;
|
||||
int y = 19;
|
||||
@@ -359,11 +368,11 @@ public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay
|
||||
}
|
||||
|
||||
if (isOverClear(mouseX, mouseY)) {
|
||||
drawTooltip(mouseX, mouseY, t("misc.refinedstorage:clear"));
|
||||
renderTooltip(mouseX, mouseY, I18n.format("misc.refinedstorage:clear"));
|
||||
}
|
||||
|
||||
if (isOverCreatePattern(mouseX, mouseY)) {
|
||||
drawTooltip(mouseX, mouseY, t("gui.refinedstorage:grid.pattern_create"));
|
||||
renderTooltip(mouseX, mouseY, I18n.format("gui.refinedstorage:grid.pattern_create"));
|
||||
}
|
||||
|
||||
tabs.drawTooltip(font, mouseX, mouseY);
|
||||
@@ -383,7 +392,7 @@ public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay
|
||||
|
||||
ItemStack stack = gridStack instanceof GridStackItem ? ((GridStackItem) gridStack).getStack() : ItemStack.EMPTY;
|
||||
|
||||
RenderUtils.drawTooltipWithSmallText(textLines, smallTextLines, RS.INSTANCE.config.detailedTooltip, stack, mouseX, mouseY, screenWidth, screenHeight, font);
|
||||
RenderUtils.drawTooltipWithSmallText(textLines, smallTextLines, RS.INSTANCE.config.detailedTooltip, stack, mouseX, mouseY, xSize, ySize, font);
|
||||
}
|
||||
|
||||
/* TODO
|
||||
@@ -487,7 +496,7 @@ public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay
|
||||
}
|
||||
}*/
|
||||
|
||||
public TextFieldSearch getSearchField() {
|
||||
public SearchWidget getSearchField() {
|
||||
return searchField;
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,7 @@ import com.raoulvdberge.refinedstorage.gui.GuiAmountSpecifying;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.GridStackFluid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
|
||||
@@ -20,12 +21,12 @@ public class GuiGridCraftingSettings extends GuiAmountSpecifying<ContainerCrafti
|
||||
|
||||
@Override
|
||||
protected String getOkButtonText() {
|
||||
return t("misc.refinedstorage:start");
|
||||
return I18n.format("misc.refinedstorage:start");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getGuiTitle() {
|
||||
return t("container.crafting");
|
||||
return I18n.format("container.crafting");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,7 +70,7 @@ public class GuiGridCraftingSettings extends GuiAmountSpecifying<ContainerCrafti
|
||||
if (quantity != null && quantity > 0) {
|
||||
// TODO RS.INSTANCE.network.sendToServer(new MessageGridCraftingPreview(stack.getHash(), quantity, shiftDown, stack instanceof GridStackFluid));
|
||||
|
||||
okButton.active = false; // TODO is active correct
|
||||
okButton.active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.gui.grid.stack;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.render.FluidRenderer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -105,7 +106,7 @@ public class GridStackFluid implements IGridStack {
|
||||
|
||||
@Override
|
||||
public void draw(GuiBase gui, int x, int y) {
|
||||
GuiBase.FLUID_RENDERER.draw(gui.getMinecraft(), x, y, stack);
|
||||
FluidRenderer.INSTANCE.render(x, y, stack);
|
||||
|
||||
String text;
|
||||
|
||||
@@ -115,7 +116,7 @@ public class GridStackFluid implements IGridStack {
|
||||
text = API.instance().getQuantityFormatter().formatInBucketFormWithOnlyTrailingDigitsIfZero(getQuantity());
|
||||
}
|
||||
|
||||
gui.drawQuantity(x, y, text);
|
||||
gui.renderQuantity(x, y, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -166,7 +166,7 @@ public class GridStackItem implements IGridStack {
|
||||
text = API.instance().getQuantityFormatter().formatWithUnits(getQuantity());
|
||||
}
|
||||
|
||||
gui.drawItem(x, y, stack, true, text);
|
||||
gui.renderItem(x, y, stack, true, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -0,0 +1,22 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.widget;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.fml.client.config.GuiCheckBox;
|
||||
|
||||
public class CheckBoxWidget extends GuiCheckBox {
|
||||
private IPressable onPress;
|
||||
|
||||
public CheckBoxWidget(int xPos, int yPos, String displayString, boolean isChecked, IPressable onPress) {
|
||||
super(xPos, yPos, displayString, isChecked);
|
||||
|
||||
this.onPress = onPress;
|
||||
this.width = Minecraft.getInstance().fontRenderer.getStringWidth(displayString) + 2 + 11 + 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress() {
|
||||
super.onPress();
|
||||
|
||||
onPress.onPress(this);
|
||||
}
|
||||
}
|
@@ -1,11 +1,11 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class Scrollbar {
|
||||
public class ScrollbarWidget {
|
||||
private static final int SCROLLER_HEIGHT = 15;
|
||||
|
||||
private int x;
|
||||
@@ -20,16 +20,16 @@ public class Scrollbar {
|
||||
private boolean wasClicking = false;
|
||||
private boolean isScrolling = false;
|
||||
|
||||
private List<ScrollbarListener> listeners = new LinkedList<>();
|
||||
private List<ScrollbarWidgetListener> listeners = new LinkedList<>();
|
||||
|
||||
public Scrollbar(int x, int y, int width, int height) {
|
||||
public ScrollbarWidget(int x, int y, int width, int height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void addListener(ScrollbarListener listener) {
|
||||
public void addListener(ScrollbarWidgetListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Scrollbar {
|
||||
|
||||
public void draw(GuiBase gui) {
|
||||
gui.bindTexture("icons.png");
|
||||
gui.drawTexture(gui.getGuiLeft() + x, gui.getGuiTop() + y + (int) Math.min(height - SCROLLER_HEIGHT, (float) offset / (float) maxOffset * (float) (height - SCROLLER_HEIGHT)), isEnabled() ? 232 : 244, 0, 12, 15);
|
||||
gui.blit(gui.getGuiLeft() + x, gui.getGuiTop() + y + (int) Math.min(height - SCROLLER_HEIGHT, (float) offset / (float) maxOffset * (float) (height - SCROLLER_HEIGHT)), isEnabled() ? 232 : 244, 0, 12, 15);
|
||||
}
|
||||
|
||||
public void update(GuiBase gui, int mouseX, int mouseY) {
|
@@ -0,0 +1,5 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.widget;
|
||||
|
||||
public interface ScrollbarWidgetListener {
|
||||
void onOffsetChanged(int oldOffset, int newOffset);
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
@@ -8,7 +8,7 @@ import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class TextFieldSearch extends TextFieldWidget {
|
||||
public class SearchWidget extends TextFieldWidget {
|
||||
private static final List<String> HISTORY = new ArrayList<>();
|
||||
|
||||
private int mode;
|
||||
@@ -16,7 +16,7 @@ public class TextFieldSearch extends TextFieldWidget {
|
||||
|
||||
private List<Runnable> listeners = new LinkedList<>();
|
||||
|
||||
public TextFieldSearch(FontRenderer fontRenderer, int x, int y, int width) {
|
||||
public SearchWidget(FontRenderer fontRenderer, int x, int y, int width) {
|
||||
super(fontRenderer, x, y, width, fontRenderer.FONT_HEIGHT, "");
|
||||
|
||||
this.setEnableBackgroundDrawing(false);
|
@@ -1,7 +1,8 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridTab;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.render.ElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
@@ -10,7 +11,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class TabList {
|
||||
public class TabListWidget {
|
||||
public interface ITabListListener {
|
||||
void onSelectionChanged(int tab);
|
||||
|
||||
@@ -18,7 +19,7 @@ public class TabList {
|
||||
}
|
||||
|
||||
private GuiBase gui;
|
||||
private GuiBase.ElementDrawers drawers;
|
||||
private ElementDrawers drawers;
|
||||
|
||||
private Supplier<List<IGridTab>> tabs;
|
||||
private int tabHovering;
|
||||
@@ -35,7 +36,7 @@ public class TabList {
|
||||
|
||||
private int width;
|
||||
|
||||
public TabList(GuiBase gui, GuiBase.ElementDrawers drawers, Supplier<List<IGridTab>> tabs, Supplier<Integer> pages, Supplier<Integer> page, Supplier<Integer> selected, int tabsPerPage) {
|
||||
public TabListWidget(GuiBase gui, ElementDrawers drawers, Supplier<List<IGridTab>> tabs, Supplier<Integer> pages, Supplier<Integer> page, Supplier<Integer> selected, int tabsPerPage) {
|
||||
this.gui = gui;
|
||||
this.drawers = drawers;
|
||||
this.tabs = tabs;
|
||||
@@ -47,8 +48,10 @@ public class TabList {
|
||||
|
||||
public void init(int width) {
|
||||
this.width = width;
|
||||
this.left = gui.addButton(gui.getGuiLeft(), gui.getGuiTop() - 22, 20, 20, "<", true, pages.get() > 0);
|
||||
this.right = gui.addButton(gui.getGuiLeft() + width - 22, gui.getGuiTop() - 22, 20, 20, ">", true, pages.get() > 0);
|
||||
this.left = gui.addButton(gui.getGuiLeft(), gui.getGuiTop() - 22, 20, 20, "<", true, pages.get() > 0, btn -> {
|
||||
});
|
||||
this.right = gui.addButton(gui.getGuiLeft() + width - 22, gui.getGuiTop() - 22, 20, 20, ">", true, pages.get() > 0, btn -> {
|
||||
});
|
||||
}
|
||||
|
||||
public void addListener(ITabListListener listener) {
|
||||
@@ -89,8 +92,9 @@ public class TabList {
|
||||
|
||||
left.visible = pages.get() > 0;
|
||||
right.visible = pages.get() > 0;
|
||||
left.active = page.get() > 0; // TODO correct? active
|
||||
right.active = page.get() < pages.get(); // TODO correct? active
|
||||
|
||||
left.active = page.get() > 0;
|
||||
right.active = page.get() < pages.get();
|
||||
}
|
||||
|
||||
public void drawBackground(int x, int y) {
|
||||
@@ -150,14 +154,14 @@ public class TabList {
|
||||
uvx = 199;
|
||||
}
|
||||
|
||||
gui.drawTexture(tx, ty, uvx, uvy, tbw, IGridTab.TAB_HEIGHT);
|
||||
gui.blit(tx, ty, uvx, uvy, tbw, IGridTab.TAB_HEIGHT);
|
||||
|
||||
tab.drawIcon(otx + 6, ty + 9 - (!isSelected ? 3 : 0), drawers.getItemDrawer(), drawers.getFluidDrawer());
|
||||
}
|
||||
|
||||
public void drawTooltip(FontRenderer fontRenderer, int mouseX, int mouseY) {
|
||||
if (tabHovering >= 0 && tabHovering < tabs.get().size()) {
|
||||
tabs.get().get(tabHovering).drawTooltip(mouseX, mouseY, gui.getScreenWidth(), gui.getScreenHeight(), fontRenderer);
|
||||
tabs.get().get(tabHovering).drawTooltip(mouseX, mouseY, gui.getXSize(), gui.getYSize(), fontRenderer);
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
@@ -12,8 +12,7 @@ public abstract class SideButton extends Button {
|
||||
protected GuiBase gui;
|
||||
|
||||
public SideButton(GuiBase gui) {
|
||||
super(-1, -1, 18, 18, "", (btn) -> {
|
||||
// TODO: call ActionPerformed
|
||||
super(-1, -1, 18, 18, "", btn -> {
|
||||
});
|
||||
|
||||
this.gui = gui;
|
||||
@@ -27,7 +26,7 @@ public abstract class SideButton extends Button {
|
||||
isHovered = gui.inBounds(x, y, width, height, mouseX, mouseY);
|
||||
|
||||
gui.bindTexture("icons.png");
|
||||
gui.drawTexture(x, y, 238, isHovered ? 35 : 16, 18, 18);
|
||||
gui.blit(x, y, 238, isHovered ? 35 : 16, 18, 18);
|
||||
|
||||
drawButtonIcon(x + 1, y + 1);
|
||||
|
||||
@@ -35,7 +34,7 @@ public abstract class SideButton extends Button {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.color4f(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
gui.drawTexture(x, y, 238, 54, 18, 18);
|
||||
gui.blit(x, y, 238, 54, 18, 18);
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
}
|
||||
@@ -43,6 +42,4 @@ public abstract class SideButton extends Button {
|
||||
protected abstract void drawButtonIcon(int x, int y);
|
||||
|
||||
public abstract String getTooltip();
|
||||
|
||||
public abstract void actionPerformed();
|
||||
}
|
@@ -1,10 +1,11 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import com.raoulvdberge.refinedstorage.util.AccessTypeUtils;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonAccessType extends SideButton {
|
||||
@@ -18,16 +19,16 @@ public class SideButtonAccessType extends SideButton {
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
gui.drawTexture(x, y, 16 * parameter.getValue().getId(), 240, 16, 16);
|
||||
gui.blit(x, y, 16 * parameter.getValue().getId(), 240, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:access_type") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:access_type." + parameter.getValue().getId());
|
||||
return I18n.format("sidebutton.refinedstorage:access_type") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage:access_type." + parameter.getValue().getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
TileDataManager.setParameter(parameter, AccessTypeUtils.getAccessType(parameter.getValue().getId() + 1));
|
||||
}
|
||||
}
|
@@ -1,9 +1,10 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonCompare extends SideButton {
|
||||
@@ -19,12 +20,12 @@ public class SideButtonCompare extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
String tooltip = GuiBase.t("sidebutton.refinedstorage:compare." + mask) + "\n" + TextFormatting.GRAY;
|
||||
String tooltip = I18n.format("sidebutton.refinedstorage:compare." + mask) + "\n" + TextFormatting.GRAY;
|
||||
|
||||
if ((parameter.getValue() & mask) == mask) {
|
||||
tooltip += GuiBase.t("gui.yes");
|
||||
tooltip += I18n.format("gui.yes");
|
||||
} else {
|
||||
tooltip += GuiBase.t("gui.no");
|
||||
tooltip += I18n.format("gui.no");
|
||||
}
|
||||
|
||||
return tooltip;
|
||||
@@ -40,11 +41,11 @@ public class SideButtonCompare extends SideButton {
|
||||
|
||||
int tx = (parameter.getValue() & mask) == mask ? 0 : 16;
|
||||
|
||||
gui.drawTexture(x, y, tx, ty, 16, 16);
|
||||
gui.blit(x, y, tx, ty, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
TileDataManager.setParameter(parameter, parameter.getValue() ^ mask);
|
||||
}
|
||||
}
|
@@ -1,8 +1,9 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileConstructor;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonConstuctorDrop extends SideButton {
|
||||
@@ -12,16 +13,16 @@ public class SideButtonConstuctorDrop extends SideButton {
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
gui.drawTexture(x, y, 64 + (TileConstructor.DROP.getValue() ? 16 : 0), 16, 16, 16);
|
||||
gui.blit(x, y, 64 + (TileConstructor.DROP.getValue() ? 16 : 0), 16, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:constructor.drop") + "\n" + TextFormatting.GRAY + GuiBase.t(TileConstructor.DROP.getValue() ? "gui.yes" : "gui.no");
|
||||
return I18n.format("sidebutton.refinedstorage:constructor.drop") + "\n" + TextFormatting.GRAY + I18n.format(TileConstructor.DROP.getValue() ? "gui.yes" : "gui.no");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
TileDataManager.setParameter(TileConstructor.DROP, !TileConstructor.DROP.getValue());
|
||||
}
|
||||
}
|
@@ -1,10 +1,10 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiCrafterManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileCrafterManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonCrafterManagerSearchBoxMode extends SideButton {
|
||||
@@ -14,18 +14,18 @@ public class SideButtonCrafterManagerSearchBoxMode extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:grid.search_box_mode") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:grid.search_box_mode." + ((GuiCrafterManager) gui).getCrafterManager().getSearchBoxMode());
|
||||
return I18n.format("sidebutton.refinedstorage:grid.search_box_mode") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage:grid.search_box_mode." + ((GuiCrafterManager) gui).getCrafterManager().getSearchBoxMode());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
int mode = ((GuiCrafterManager) gui).getCrafterManager().getSearchBoxMode();
|
||||
|
||||
gui.drawTexture(x, y, mode == IGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED || mode == IGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED ? 16 : 0, 96, 16, 16);
|
||||
gui.blit(x, y, mode == IGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED || mode == IGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED ? 16 : 0, 96, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
int mode = ((GuiCrafterManager) gui).getCrafterManager().getSearchBoxMode();
|
||||
|
||||
if (mode == IGrid.SEARCH_BOX_MODE_NORMAL) {
|
@@ -1,8 +1,9 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileCrafter;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonCrafterMode extends SideButton {
|
||||
@@ -12,16 +13,16 @@ public class SideButtonCrafterMode extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:crafter_mode") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:crafter_mode." + TileCrafter.MODE.getValue());
|
||||
return I18n.format("sidebutton.refinedstorage:crafter_mode") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage:crafter_mode." + TileCrafter.MODE.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
gui.drawTexture(x, y, TileCrafter.MODE.getValue() * 16, 0, 16, 16);
|
||||
gui.blit(x, y, TileCrafter.MODE.getValue() * 16, 0, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
TileDataManager.setParameter(TileCrafter.MODE, TileCrafter.MODE.getValue() + 1);
|
||||
}
|
||||
}
|
@@ -1,8 +1,9 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileDestructor;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonDestructorPickup extends SideButton {
|
||||
@@ -12,16 +13,16 @@ public class SideButtonDestructorPickup extends SideButton {
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
gui.drawTexture(x, y, 64 + (!TileDestructor.PICKUP.getValue() ? 16 : 0), 0, 16, 16);
|
||||
gui.blit(x, y, 64 + (!TileDestructor.PICKUP.getValue() ? 16 : 0), 0, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:destructor.pickup") + "\n" + TextFormatting.GRAY + GuiBase.t(TileDestructor.PICKUP.getValue() ? "gui.yes" : "gui.no");
|
||||
return I18n.format("sidebutton.refinedstorage:destructor.pickup") + "\n" + TextFormatting.GRAY + I18n.format(TileDestructor.PICKUP.getValue() ? "gui.yes" : "gui.no");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
TileDataManager.setParameter(TileDestructor.PICKUP, !TileDestructor.PICKUP.getValue());
|
||||
}
|
||||
}
|
@@ -1,9 +1,10 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDetector;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileDetector;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonDetectorMode extends SideButton {
|
||||
@@ -13,16 +14,16 @@ public class SideButtonDetectorMode extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:detector.mode") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:detector.mode." + TileDetector.MODE.getValue());
|
||||
return I18n.format("sidebutton.refinedstorage:detector.mode") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage:detector.mode." + TileDetector.MODE.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
gui.drawTexture(x, y, TileDetector.MODE.getValue() * 16, 176, 16, 16);
|
||||
gui.blit(x, y, TileDetector.MODE.getValue() * 16, 176, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
int mode = TileDetector.MODE.getValue();
|
||||
|
||||
if (mode == NetworkNodeDetector.MODE_EQUAL) {
|
@@ -1,8 +1,8 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiFilter;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonFilterType extends SideButton {
|
||||
@@ -16,16 +16,16 @@ public class SideButtonFilterType extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:type") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:type." + gui.getType());
|
||||
return I18n.format("sidebutton.refinedstorage:type") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage:type." + gui.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
gui.drawTexture(x, y, 16 * gui.getType(), 128, 16, 16);
|
||||
gui.blit(x, y, 16 * gui.getType(), 128, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
gui.setType(gui.getType() == IType.ITEMS ? IType.FLUIDS : IType.ITEMS);
|
||||
gui.sendUpdate();
|
||||
}
|
@@ -1,8 +1,8 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonGridSearchBoxMode extends SideButton {
|
||||
@@ -12,18 +12,18 @@ public class SideButtonGridSearchBoxMode extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:grid.search_box_mode") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:grid.search_box_mode." + ((GuiGrid) gui).getGrid().getSearchBoxMode());
|
||||
return I18n.format("sidebutton.refinedstorage:grid.search_box_mode") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage:grid.search_box_mode." + ((GuiGrid) gui).getGrid().getSearchBoxMode());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
int mode = ((GuiGrid) gui).getGrid().getSearchBoxMode();
|
||||
|
||||
gui.drawTexture(x, y, mode == IGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED || mode == IGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED ? 16 : 0, 96, 16, 16);
|
||||
gui.blit(x, y, mode == IGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED || mode == IGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED ? 16 : 0, 96, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
int mode = ((GuiGrid) gui).getGrid().getSearchBoxMode();
|
||||
|
||||
if (mode == IGrid.SEARCH_BOX_MODE_NORMAL) {
|
@@ -1,7 +1,8 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
@@ -19,7 +20,7 @@ public class SideButtonGridSize extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:grid.size") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:grid.size." + this.size.get());
|
||||
return I18n.format("sidebutton.refinedstorage:grid.size") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage:grid.size." + this.size.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,11 +39,11 @@ public class SideButtonGridSize extends SideButton {
|
||||
tx = 32;
|
||||
}
|
||||
|
||||
gui.drawTexture(x, y, 64 + tx, 64, 16, 16);
|
||||
gui.blit(x, y, 64 + tx, 64, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
int size = this.size.get();
|
||||
|
||||
if (size == IGrid.SIZE_STRETCH) {
|
@@ -1,7 +1,8 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonGridSortingDirection extends SideButton {
|
||||
@@ -15,16 +16,16 @@ public class SideButtonGridSortingDirection extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:grid.sorting.direction") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:grid.sorting.direction." + grid.getSortingDirection());
|
||||
return I18n.format("sidebutton.refinedstorage:grid.sorting.direction") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage:grid.sorting.direction." + grid.getSortingDirection());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
gui.drawTexture(x, y, grid.getSortingDirection() * 16, 16, 16, 16);
|
||||
gui.blit(x, y, grid.getSortingDirection() * 16, 16, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
int dir = grid.getSortingDirection();
|
||||
|
||||
if (dir == IGrid.SORTING_DIRECTION_ASCENDING) {
|
@@ -1,9 +1,10 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonGridSortingType extends SideButton {
|
||||
@@ -17,20 +18,20 @@ public class SideButtonGridSortingType extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:grid.sorting.type") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:grid.sorting.type." + grid.getSortingType());
|
||||
return I18n.format("sidebutton.refinedstorage:grid.sorting.type") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage:grid.sorting.type." + grid.getSortingType());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
if (grid.getSortingType() == IGrid.SORTING_TYPE_LAST_MODIFIED) {
|
||||
gui.drawTexture(x, y, 48, 48, 16, 16);
|
||||
gui.blit(x, y, 48, 48, 16, 16);
|
||||
} else {
|
||||
gui.drawTexture(x, y, grid.getSortingType() * 16, 32, 16, 16);
|
||||
gui.blit(x, y, grid.getSortingType() * 16, 32, 16, 16);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
int type = grid.getSortingType();
|
||||
|
||||
if (type == IGrid.SORTING_TYPE_QUANTITY) {
|
@@ -1,7 +1,8 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonGridViewType extends SideButton {
|
||||
@@ -15,16 +16,16 @@ public class SideButtonGridViewType extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:grid.view_type") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:grid.view_type." + grid.getViewType());
|
||||
return I18n.format("sidebutton.refinedstorage:grid.view_type") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage:grid.view_type." + grid.getViewType());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
gui.drawTexture(x, y, (grid.getViewType() - (grid.getViewType() >= 3 ? 3 : 0)) * 16, 112, 16, 16);
|
||||
gui.blit(x, y, (grid.getViewType() - (grid.getViewType() >= 3 ? 3 : 0)) * 16, 112, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
int type = grid.getViewType();
|
||||
|
||||
if (type == IGrid.VIEW_TYPE_NORMAL) {
|
@@ -1,9 +1,10 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskmanipulator.NetworkNodeDiskManipulator;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileDiskManipulator;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonIOMode extends SideButton {
|
||||
@@ -13,16 +14,16 @@ public class SideButtonIOMode extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:iomode") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:iomode." + (TileDiskManipulator.IO_MODE.getValue() == NetworkNodeDiskManipulator.IO_MODE_INSERT ? "insert" : "extract"));
|
||||
return I18n.format("sidebutton.refinedstorage:iomode") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage:iomode." + (TileDiskManipulator.IO_MODE.getValue() == NetworkNodeDiskManipulator.IO_MODE_INSERT ? "insert" : "extract"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
gui.drawTexture(x, y, TileDiskManipulator.IO_MODE.getValue() == NetworkNodeDiskManipulator.IO_MODE_EXTRACT ? 0 : 16, 160, 16, 16);
|
||||
gui.blit(x, y, TileDiskManipulator.IO_MODE.getValue() == NetworkNodeDiskManipulator.IO_MODE_EXTRACT ? 0 : 16, 160, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
TileDataManager.setParameter(TileDiskManipulator.IO_MODE, TileDiskManipulator.IO_MODE.getValue() == NetworkNodeDiskManipulator.IO_MODE_INSERT ? NetworkNodeDiskManipulator.IO_MODE_EXTRACT : NetworkNodeDiskManipulator.IO_MODE_INSERT);
|
||||
}
|
||||
}
|
@@ -1,9 +1,10 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonMode extends SideButton {
|
||||
@@ -17,16 +18,16 @@ public class SideButtonMode extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:mode") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:mode." + (parameter.getValue() == IFilterable.WHITELIST ? "whitelist" : "blacklist"));
|
||||
return I18n.format("sidebutton.refinedstorage.mode") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage.mode." + (parameter.getValue() == IFilterable.WHITELIST ? "whitelist" : "blacklist"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
gui.drawTexture(x, y, parameter.getValue() == IFilterable.WHITELIST ? 0 : 16, 64, 16, 16);
|
||||
gui.blit(x, y, parameter.getValue() == IFilterable.WHITELIST ? 0 : 16, 64, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
TileDataManager.setParameter(parameter, parameter.getValue() == IFilterable.WHITELIST ? IFilterable.BLACKLIST : IFilterable.WHITELIST);
|
||||
}
|
||||
}
|
@@ -1,8 +1,9 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonRedstoneMode extends SideButton {
|
||||
@@ -16,16 +17,16 @@ public class SideButtonRedstoneMode extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:redstone_mode") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:redstone_mode." + parameter.getValue());
|
||||
return I18n.format("sidebutton.refinedstorage:redstone_mode") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage:redstone_mode." + parameter.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
gui.drawTexture(x, y, parameter.getValue() * 16, 0, 16, 16);
|
||||
gui.blit(x, y, parameter.getValue() * 16, 0, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
TileDataManager.setParameter(parameter, parameter.getValue() + 1);
|
||||
}
|
||||
}
|
@@ -1,9 +1,10 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
package com.raoulvdberge.refinedstorage.gui.widget.sidebutton;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonType extends SideButton {
|
||||
@@ -17,16 +18,16 @@ public class SideButtonType extends SideButton {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:type") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:type." + type.getValue());
|
||||
return I18n.format("sidebutton.refinedstorage:type") + "\n" + TextFormatting.GRAY + I18n.format("sidebutton.refinedstorage:type." + type.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
gui.drawTexture(x, y, 16 * type.getValue(), 128, 16, 16);
|
||||
gui.blit(x, y, 16 * type.getValue(), 128, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
public void onPress() {
|
||||
TileDataManager.setParameter(type, type.getValue() == IType.ITEMS ? IType.FLUIDS : IType.ITEMS);
|
||||
}
|
||||
}
|
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.inventory.fluid;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -18,6 +19,11 @@ public class FluidInventory {
|
||||
|
||||
public FluidInventory(int size, int maxAmount, @Nullable Consumer<Integer> listener) {
|
||||
this.fluids = new FluidStack[size];
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
fluids[i] = FluidStack.EMPTY;
|
||||
}
|
||||
|
||||
this.maxAmount = maxAmount;
|
||||
this.listener = listener;
|
||||
}
|
||||
@@ -42,13 +48,17 @@ public class FluidInventory {
|
||||
return fluids;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Nonnull
|
||||
public FluidStack getFluid(int slot) {
|
||||
return fluids[slot];
|
||||
}
|
||||
|
||||
public void setFluid(int slot, @Nullable FluidStack stack) {
|
||||
if (stack != null && stack.getAmount() <= 0 && stack.getAmount() > maxAmount) {
|
||||
public void setFluid(int slot, @Nonnull FluidStack stack) {
|
||||
if (stack == null) {
|
||||
throw new IllegalArgumentException("Stack can't be null");
|
||||
}
|
||||
|
||||
if (stack.getAmount() > maxAmount) {
|
||||
throw new IllegalArgumentException("Fluid size is invalid (given: " + stack.getAmount() + ", max size: " + maxAmount + ")");
|
||||
}
|
||||
|
||||
@@ -67,7 +77,7 @@ public class FluidInventory {
|
||||
for (int i = 0; i < getSlots(); ++i) {
|
||||
FluidStack stack = getFluid(i);
|
||||
|
||||
if (stack != null) {
|
||||
if (!stack.isEmpty()) {
|
||||
tag.put(String.format(NBT_SLOT, i), stack.writeToNBT(new CompoundNBT()));
|
||||
}
|
||||
}
|
||||
@@ -91,7 +101,7 @@ public class FluidInventory {
|
||||
this.empty = true;
|
||||
|
||||
for (FluidStack fluid : fluids) {
|
||||
if (fluid != null) {
|
||||
if (!fluid.isEmpty()) {
|
||||
this.empty = false;
|
||||
|
||||
return;
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package com.raoulvdberge.refinedstorage.inventory.fluid;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.item.ItemFilter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class FluidInventoryFilterIcon extends FluidInventory {
|
||||
public FluidInventoryFilterIcon(ItemStack stack) {
|
||||
@@ -12,12 +14,12 @@ public class FluidInventoryFilterIcon extends FluidInventory {
|
||||
stack.setTag(new CompoundNBT());
|
||||
}
|
||||
|
||||
// TODO ItemFilter.setFluidIcon(stack, getFluid(slot));
|
||||
ItemFilter.setFluidIcon(stack, getFluid(slot));
|
||||
};
|
||||
/*
|
||||
|
||||
FluidStack icon = ItemFilter.getFluidIcon(stack);
|
||||
if (icon != null) {
|
||||
setFluid(0, icon);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.raoulvdberge.refinedstorage.inventory.item;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.item.ItemFilter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
@@ -11,13 +12,13 @@ public class ItemHandlerFilterIcon extends ItemStackHandler {
|
||||
|
||||
this.stack = stack;
|
||||
|
||||
//TODO setStackInSlot(0, ItemFilter.getIcon(stack));
|
||||
setStackInSlot(0, ItemFilter.getIcon(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onContentsChanged(int slot) {
|
||||
super.onContentsChanged(slot);
|
||||
|
||||
// TODO ItemFilter.setIcon(stack, getStackInSlot(0));
|
||||
ItemFilter.setIcon(stack, getStackInSlot(0));
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,37 @@
|
||||
package com.raoulvdberge.refinedstorage.item;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.item.info.ItemInfo;
|
||||
import com.raoulvdberge.refinedstorage.RSItems;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerFilter;
|
||||
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventoryFilter;
|
||||
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilterItems;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.Style;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class ItemFilter extends ItemBase {
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemFilter extends Item {
|
||||
private static final String NBT_COMPARE = "Compare";
|
||||
private static final String NBT_MODE = "Mode";
|
||||
private static final String NBT_MOD_FILTER = "ModFilter";
|
||||
@@ -14,43 +42,47 @@ public class ItemFilter extends ItemBase {
|
||||
public static final String NBT_FLUID_FILTERS = "FluidFilters";
|
||||
|
||||
public ItemFilter() {
|
||||
super(new ItemInfo(RS.ID, "filter"));
|
||||
super(new Item.Properties().group(RS.MAIN_GROUP).maxStackSize(1));
|
||||
|
||||
//setMaxStackSize(1);
|
||||
}
|
||||
|
||||
/* TODO
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerModels(IModelRegistration modelRegistration) {
|
||||
modelRegistration.setModel(this, 0, new ModelResourceLocation(info.getId(), "inventory"));
|
||||
this.setRegistryName(RS.ID, "filter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, EnumHand hand) {
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (player.isSneaking()) {
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, new ItemStack(RSItems.FILTER));
|
||||
return new ActionResult<>(ActionResultType.SUCCESS, new ItemStack(RSItems.FILTER));
|
||||
}
|
||||
|
||||
player.openGui(RS.INSTANCE, RSGui.FILTER, world, hand.ordinal(), 0, 0);
|
||||
player.openContainer(new INamedContainerProvider() {
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return new TranslationTextComponent("gui.refinedstorage.filter");
|
||||
}
|
||||
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
||||
@Nullable
|
||||
@Override
|
||||
public Container createMenu(int windowId, PlayerInventory inventory, PlayerEntity player) {
|
||||
return new ContainerFilter(player, inventory.getCurrentItem(), windowId);
|
||||
}
|
||||
});
|
||||
|
||||
return new ActionResult<>(ActionResultType.SUCCESS, stack);
|
||||
}
|
||||
|
||||
return new ActionResult<>(EnumActionResult.PASS, stack);
|
||||
return new ActionResult<>(ActionResultType.PASS, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag) {
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
|
||||
tooltip.add(TextFormatting.YELLOW + I18n.format("sidebutton.refinedstorage:mode." + (getMode(stack) == IFilter.MODE_WHITELIST ? "whitelist" : "blacklist")) + TextFormatting.RESET);
|
||||
tooltip.add(new TranslationTextComponent("sidebutton.refinedstorage.mode." + (getMode(stack) == IFilter.MODE_WHITELIST ? "whitelist" : "blacklist")).setStyle(new Style().setColor(TextFormatting.YELLOW)));
|
||||
|
||||
if (isModFilter(stack)) {
|
||||
tooltip.add(TextFormatting.BLUE + I18n.format("gui.refinedstorage:filter.mod_filter") + TextFormatting.RESET);
|
||||
tooltip.add(new TranslationTextComponent("gui.refinedstorage.filter.mod_filter").setStyle(new Style().setColor(TextFormatting.BLUE)));
|
||||
}
|
||||
|
||||
ItemHandlerFilterItems items = new ItemHandlerFilterItems(stack);
|
||||
@@ -68,92 +100,92 @@ public class ItemFilter extends ItemBase {
|
||||
}
|
||||
|
||||
public static int getCompare(ItemStack stack) {
|
||||
return (stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_COMPARE)) ? stack.getTagCompound().getInteger(NBT_COMPARE) : (IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
|
||||
return (stack.hasTag() && stack.getTag().contains(NBT_COMPARE)) ? stack.getTag().getInt(NBT_COMPARE) : IComparer.COMPARE_NBT;
|
||||
}
|
||||
|
||||
public static void setCompare(ItemStack stack, int compare) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new CompoundNBT());
|
||||
if (!stack.hasTag()) {
|
||||
stack.setTag(new CompoundNBT());
|
||||
}
|
||||
|
||||
stack.getTagCompound().putInt(NBT_COMPARE, compare);
|
||||
stack.getTag().putInt(NBT_COMPARE, compare);
|
||||
}
|
||||
|
||||
public static int getMode(ItemStack stack) {
|
||||
return (stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_MODE)) ? stack.getTagCompound().getInteger(NBT_MODE) : IFilter.MODE_WHITELIST;
|
||||
return (stack.hasTag() && stack.getTag().contains(NBT_MODE)) ? stack.getTag().getInt(NBT_MODE) : IFilter.MODE_WHITELIST;
|
||||
}
|
||||
|
||||
public static void setMode(ItemStack stack, int mode) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new CompoundNBT());
|
||||
if (!stack.hasTag()) {
|
||||
stack.setTag(new CompoundNBT());
|
||||
}
|
||||
|
||||
stack.getTagCompound().putInt(NBT_MODE, mode);
|
||||
stack.getTag().putInt(NBT_MODE, mode);
|
||||
}
|
||||
|
||||
public static boolean isModFilter(ItemStack stack) {
|
||||
return stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_MOD_FILTER) && stack.getTagCompound().getBoolean(NBT_MOD_FILTER);
|
||||
return stack.hasTag() && stack.getTag().contains(NBT_MOD_FILTER) && stack.getTag().getBoolean(NBT_MOD_FILTER);
|
||||
}
|
||||
|
||||
public static void setModFilter(ItemStack stack, boolean modFilter) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new CompoundNBT());
|
||||
if (!stack.hasTag()) {
|
||||
stack.setTag(new CompoundNBT());
|
||||
}
|
||||
|
||||
stack.getTagCompound().putBoolean(NBT_MOD_FILTER, modFilter);
|
||||
stack.getTag().putBoolean(NBT_MOD_FILTER, modFilter);
|
||||
}
|
||||
|
||||
public static String getName(ItemStack stack) {
|
||||
return stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_NAME) ? stack.getTagCompound().getString(NBT_NAME) : "";
|
||||
return stack.hasTag() && stack.getTag().contains(NBT_NAME) ? stack.getTag().getString(NBT_NAME) : "";
|
||||
}
|
||||
|
||||
public static void setName(ItemStack stack, String name) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new CompoundNBT());
|
||||
if (!stack.hasTag()) {
|
||||
stack.setTag(new CompoundNBT());
|
||||
}
|
||||
|
||||
stack.getTagCompound().setString(NBT_NAME, name);
|
||||
stack.getTag().putString(NBT_NAME, name);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static ItemStack getIcon(ItemStack stack) {
|
||||
return stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_ICON) ? new ItemStack(stack.getTagCompound().getCompound(NBT_ICON)) : ItemStack.EMPTY;
|
||||
return stack.hasTag() && stack.getTag().contains(NBT_ICON) ? ItemStack.read(stack.getTag().getCompound(NBT_ICON)) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static void setIcon(ItemStack stack, ItemStack icon) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new CompoundNBT());
|
||||
if (!stack.hasTag()) {
|
||||
stack.setTag(new CompoundNBT());
|
||||
}
|
||||
|
||||
stack.getTagCompound().put(NBT_ICON, icon.serializeNBT());
|
||||
stack.getTag().put(NBT_ICON, icon.serializeNBT());
|
||||
}
|
||||
|
||||
public static void setFluidIcon(ItemStack stack, @Nullable FluidStack icon) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new CompoundNBT());
|
||||
if (!stack.hasTag()) {
|
||||
stack.setTag(new CompoundNBT());
|
||||
}
|
||||
|
||||
if (icon == null) {
|
||||
stack.getTagCompound().removeTag(NBT_FLUID_ICON);
|
||||
stack.getTag().remove(NBT_FLUID_ICON);
|
||||
} else {
|
||||
stack.getTagCompound().put(NBT_FLUID_ICON, icon.writeToNBT(new CompoundNBT()));
|
||||
stack.getTag().put(NBT_FLUID_ICON, icon.writeToNBT(new CompoundNBT()));
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static FluidStack getFluidIcon(ItemStack stack) {
|
||||
return stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_FLUID_ICON) ? FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompound(NBT_FLUID_ICON)) : null;
|
||||
return stack.hasTag() && stack.getTag().contains(NBT_FLUID_ICON) ? FluidStack.loadFluidStackFromNBT(stack.getTag().getCompound(NBT_FLUID_ICON)) : null;
|
||||
}
|
||||
|
||||
public static int getType(ItemStack stack) {
|
||||
return stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_TYPE) ? stack.getTagCompound().getInteger(NBT_TYPE) : IType.ITEMS;
|
||||
return stack.hasTag() && stack.getTag().contains(NBT_TYPE) ? stack.getTag().getInt(NBT_TYPE) : IType.ITEMS;
|
||||
}
|
||||
|
||||
public static void setType(ItemStack stack, int type) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new CompoundNBT());
|
||||
if (!stack.hasTag()) {
|
||||
stack.setTag(new CompoundNBT());
|
||||
}
|
||||
|
||||
stack.getTagCompound().putInt(NBT_TYPE, type);
|
||||
}*/
|
||||
stack.getTag().putInt(NBT_TYPE, type);
|
||||
}
|
||||
}
|
||||
|
@@ -232,7 +232,7 @@ public class ItemPattern extends Item implements ICraftingPatternProvider {
|
||||
pattern.getTag().putBoolean(NBT_OREDICT, oredict);
|
||||
}
|
||||
|
||||
public static void setVersion(ItemStack pattern) {
|
||||
public static void setToCurrentVersion(ItemStack pattern) {
|
||||
if (!pattern.hasTag()) {
|
||||
pattern.setTag(new CompoundNBT());
|
||||
}
|
||||
|
@@ -0,0 +1,58 @@
|
||||
package com.raoulvdberge.refinedstorage.network;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerFilter;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemFilter;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class MessageFilterUpdate {
|
||||
private int compare;
|
||||
private int mode;
|
||||
private boolean modFilter;
|
||||
private String name;
|
||||
private int type;
|
||||
|
||||
public MessageFilterUpdate(int compare, int mode, boolean modFilter, String name, int type) {
|
||||
this.compare = compare;
|
||||
this.mode = mode;
|
||||
this.modFilter = modFilter;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static MessageFilterUpdate decode(PacketBuffer buf) {
|
||||
return new MessageFilterUpdate(
|
||||
buf.readInt(),
|
||||
buf.readInt(),
|
||||
buf.readBoolean(),
|
||||
buf.readString(),
|
||||
buf.readInt()
|
||||
);
|
||||
}
|
||||
|
||||
public static void encode(MessageFilterUpdate message, PacketBuffer buf) {
|
||||
buf.writeInt(message.compare);
|
||||
buf.writeInt(message.mode);
|
||||
buf.writeBoolean(message.modFilter);
|
||||
buf.writeString(message.name);
|
||||
buf.writeInt(message.type);
|
||||
}
|
||||
|
||||
public static void handle(MessageFilterUpdate message, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
PlayerEntity player = ctx.get().getSender();
|
||||
|
||||
if (player != null && player.openContainer instanceof ContainerFilter) {
|
||||
ItemFilter.setCompare(((ContainerFilter) player.openContainer).getStack(), message.compare);
|
||||
ItemFilter.setMode(((ContainerFilter) player.openContainer).getStack(), message.mode);
|
||||
ItemFilter.setModFilter(((ContainerFilter) player.openContainer).getStack(), message.modFilter);
|
||||
ItemFilter.setName(((ContainerFilter) player.openContainer).getStack(), message.name);
|
||||
ItemFilter.setType(((ContainerFilter) player.openContainer).getStack(), message.type);
|
||||
}
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.network;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerFilter;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemFilter;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
public class MessageFilterUpdate extends MessageHandlerPlayerToServer<MessageFilterUpdate> implements IMessage {
|
||||
private int compare;
|
||||
private int mode;
|
||||
private boolean modFilter;
|
||||
private String name;
|
||||
private int type;
|
||||
|
||||
public MessageFilterUpdate() {
|
||||
}
|
||||
|
||||
public MessageFilterUpdate(int compare, int mode, boolean modFilter, String name, int type) {
|
||||
this.compare = compare;
|
||||
this.mode = mode;
|
||||
this.modFilter = modFilter;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
compare = buf.readInt();
|
||||
mode = buf.readInt();
|
||||
modFilter = buf.readBoolean();
|
||||
name = ByteBufUtils.readUTF8String(buf);
|
||||
type = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(compare);
|
||||
buf.writeInt(mode);
|
||||
buf.writeBoolean(modFilter);
|
||||
ByteBufUtils.writeUTF8String(buf, name);
|
||||
buf.writeInt(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(MessageFilterUpdate message, ServerPlayerEntity player) {
|
||||
if (player.openContainer instanceof ContainerFilter) {
|
||||
ItemFilter.setCompare(((ContainerFilter) player.openContainer).getStack(), message.compare);
|
||||
ItemFilter.setMode(((ContainerFilter) player.openContainer).getStack(), message.mode);
|
||||
ItemFilter.setModFilter(((ContainerFilter) player.openContainer).getStack(), message.modFilter);
|
||||
ItemFilter.setName(((ContainerFilter) player.openContainer).getStack(), message.name);
|
||||
ItemFilter.setType(((ContainerFilter) player.openContainer).getStack(), message.type);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.network;
|
||||
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public abstract class MessageHandlerPlayerToServer<T extends IMessage> implements IMessageHandler<T, IMessage> {
|
||||
@Override
|
||||
public IMessage onMessage(final T message, MessageContext context) {
|
||||
final ServerPlayerEntity player = context.getServerHandler().player;
|
||||
|
||||
player.getServerWorld().addScheduledTask(() -> handle(message, player));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected abstract void handle(T message, ServerPlayerEntity player);
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
package com.raoulvdberge.refinedstorage.network;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.SlotFilterFluid;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.network.NetworkEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class MessageSlotFilterFluidUpdate {
|
||||
private int containerSlot;
|
||||
private FluidStack stack;
|
||||
|
||||
public MessageSlotFilterFluidUpdate(int containerSlot, FluidStack stack) {
|
||||
this.containerSlot = containerSlot;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public static void encode(MessageSlotFilterFluidUpdate message, PacketBuffer buf) {
|
||||
buf.writeInt(message.containerSlot);
|
||||
message.stack.writeToPacket(buf);
|
||||
}
|
||||
|
||||
public static MessageSlotFilterFluidUpdate decode(PacketBuffer buf) {
|
||||
return new MessageSlotFilterFluidUpdate(buf.readInt(), FluidStack.readFromPacket(buf));
|
||||
}
|
||||
|
||||
public static void handle(MessageSlotFilterFluidUpdate message, Supplier<NetworkEvent.Context> ctx) {
|
||||
GuiBase.executeLater(gui -> {
|
||||
if (message.containerSlot >= 0 && message.containerSlot < gui.getContainer().inventorySlots.size()) {
|
||||
Slot slot = gui.getContainer().getSlot(message.containerSlot);
|
||||
|
||||
if (slot instanceof SlotFilterFluid) {
|
||||
((SlotFilterFluid) slot).getFluidInventory().setFluid(slot.getSlotIndex(), message.stack);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
@@ -1,62 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.network;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.container.slot.filter.SlotFilterFluid;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class MessageSlotFilterFluidUpdate implements IMessage, IMessageHandler<MessageSlotFilterFluidUpdate, IMessage> {
|
||||
private int containerSlot;
|
||||
private FluidStack stack;
|
||||
|
||||
public MessageSlotFilterFluidUpdate(int containerSlot, FluidStack stack) {
|
||||
this.containerSlot = containerSlot;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public MessageSlotFilterFluidUpdate() {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
containerSlot = buf.readInt();
|
||||
|
||||
if (buf.readBoolean()) {
|
||||
stack = StackUtils.readFluidStack(buf);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
buf.writeInt(containerSlot);
|
||||
|
||||
if (stack == null) {
|
||||
buf.writeBoolean(false);
|
||||
} else {
|
||||
buf.writeBoolean(true);
|
||||
|
||||
StackUtils.writeFluidStack(buf, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(MessageSlotFilterFluidUpdate message, MessageContext ctx) {
|
||||
GuiBase.executeLater(gui -> {
|
||||
if (message.containerSlot >= 0 && message.containerSlot < gui.inventorySlots.inventorySlots.size()) {
|
||||
Slot slot = gui.inventorySlots.getSlot(message.containerSlot);
|
||||
|
||||
if (slot instanceof SlotFilterFluid) {
|
||||
((SlotFilterFluid) slot).getFluidInventory().setFluid(slot.getSlotIndex(), message.stack);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -22,6 +22,8 @@ public class NetworkHandler {
|
||||
|
||||
handler.registerMessage(id++, MessageStorageDiskSizeRequest.class, MessageStorageDiskSizeRequest::encode, MessageStorageDiskSizeRequest::decode, MessageStorageDiskSizeRequest::handle);
|
||||
handler.registerMessage(id++, MessageStorageDiskSizeResponse.class, MessageStorageDiskSizeResponse::encode, MessageStorageDiskSizeResponse::decode, MessageStorageDiskSizeResponse::handle);
|
||||
handler.registerMessage(id++, MessageFilterUpdate.class, MessageFilterUpdate::encode, MessageFilterUpdate::decode, MessageFilterUpdate::handle);
|
||||
handler.registerMessage(id++, MessageSlotFilterFluidUpdate.class, MessageSlotFilterFluidUpdate::encode, MessageSlotFilterFluidUpdate::decode, MessageSlotFilterFluidUpdate::handle);
|
||||
}
|
||||
|
||||
public void sendToServer(Object message) {
|
||||
|
@@ -0,0 +1,139 @@
|
||||
package com.raoulvdberge.refinedstorage.render;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* @link https://github.com/mezz/JustEnoughItems/blob/1.14/src/main/java/mezz/jei/plugins/vanilla/ingredients/fluid/FluidStackRenderer.java
|
||||
*/
|
||||
public class FluidRenderer {
|
||||
public static final FluidRenderer INSTANCE = new FluidRenderer(FluidAttributes.BUCKET_VOLUME, 16, 16);
|
||||
|
||||
private static final int TEX_WIDTH = 16;
|
||||
private static final int TEX_HEIGHT = 16;
|
||||
private static final int MIN_FLUID_HEIGHT = 1;
|
||||
|
||||
private final int capacityMb;
|
||||
private final int width;
|
||||
private final int height;
|
||||
|
||||
public FluidRenderer(int capacityMb, int width, int height) {
|
||||
this.capacityMb = capacityMb;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void render(final int xPosition, final int yPosition, @Nullable FluidStack fluidStack) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.enableAlphaTest();
|
||||
|
||||
drawFluid(xPosition, yPosition, fluidStack);
|
||||
|
||||
GlStateManager.color4f(1, 1, 1, 1);
|
||||
|
||||
GlStateManager.disableAlphaTest();
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
|
||||
private void drawFluid(final int xPosition, final int yPosition, @Nullable FluidStack fluidStack) {
|
||||
if (fluidStack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
if (fluid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TextureAtlasSprite fluidStillSprite = getStillFluidSprite(fluidStack);
|
||||
|
||||
FluidAttributes attributes = fluid.getAttributes();
|
||||
int fluidColor = attributes.getColor(fluidStack);
|
||||
|
||||
int amount = fluidStack.getAmount();
|
||||
int scaledAmount = (amount * height) / capacityMb;
|
||||
if (amount > 0 && scaledAmount < MIN_FLUID_HEIGHT) {
|
||||
scaledAmount = MIN_FLUID_HEIGHT;
|
||||
}
|
||||
if (scaledAmount > height) {
|
||||
scaledAmount = height;
|
||||
}
|
||||
|
||||
drawTiledSprite(xPosition, yPosition, width, height, fluidColor, scaledAmount, fluidStillSprite);
|
||||
}
|
||||
|
||||
private void drawTiledSprite(final int xPosition, final int yPosition, final int tiledWidth, final int tiledHeight, int color, int scaledAmount, TextureAtlasSprite sprite) {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
minecraft.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
|
||||
setGLColorFromInt(color);
|
||||
|
||||
final int xTileCount = tiledWidth / TEX_WIDTH;
|
||||
final int xRemainder = tiledWidth - (xTileCount * TEX_WIDTH);
|
||||
final int yTileCount = scaledAmount / TEX_HEIGHT;
|
||||
final int yRemainder = scaledAmount - (yTileCount * TEX_HEIGHT);
|
||||
|
||||
final int yStart = yPosition + tiledHeight;
|
||||
|
||||
for (int xTile = 0; xTile <= xTileCount; xTile++) {
|
||||
for (int yTile = 0; yTile <= yTileCount; yTile++) {
|
||||
int width = (xTile == xTileCount) ? xRemainder : TEX_WIDTH;
|
||||
int height = (yTile == yTileCount) ? yRemainder : TEX_HEIGHT;
|
||||
int x = xPosition + (xTile * TEX_WIDTH);
|
||||
int y = yStart - ((yTile + 1) * TEX_HEIGHT);
|
||||
if (width > 0 && height > 0) {
|
||||
int maskTop = TEX_HEIGHT - height;
|
||||
int maskRight = TEX_WIDTH - width;
|
||||
|
||||
drawTextureWithMasking(x, y, sprite, maskTop, maskRight, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static TextureAtlasSprite getStillFluidSprite(FluidStack fluidStack) {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
AtlasTexture textureMapBlocks = minecraft.getTextureMap();
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
FluidAttributes attributes = fluid.getAttributes();
|
||||
ResourceLocation fluidStill = attributes.getStill(fluidStack);
|
||||
return textureMapBlocks.getSprite(fluidStill);
|
||||
}
|
||||
|
||||
private static void setGLColorFromInt(int color) {
|
||||
float red = (color >> 16 & 0xFF) / 255.0F;
|
||||
float green = (color >> 8 & 0xFF) / 255.0F;
|
||||
float blue = (color & 0xFF) / 255.0F;
|
||||
float alpha = ((color >> 24) & 0xFF) / 255F;
|
||||
|
||||
GlStateManager.color4f(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
private static void drawTextureWithMasking(double xCoord, double yCoord, TextureAtlasSprite textureSprite, int maskTop, int maskRight, double zLevel) {
|
||||
double uMin = textureSprite.getMinU();
|
||||
double uMax = textureSprite.getMaxU();
|
||||
double vMin = textureSprite.getMinV();
|
||||
double vMax = textureSprite.getMaxV();
|
||||
uMax = uMax - (maskRight / 16.0 * (uMax - uMin));
|
||||
vMax = vMax - (maskTop / 16.0 * (vMax - vMin));
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder bufferBuilder = tessellator.getBuffer();
|
||||
bufferBuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
bufferBuilder.pos(xCoord, yCoord + 16, zLevel).tex(uMin, vMax).endVertex();
|
||||
bufferBuilder.pos(xCoord + 16 - maskRight, yCoord + 16, zLevel).tex(uMax, vMax).endVertex();
|
||||
bufferBuilder.pos(xCoord + 16 - maskRight, yCoord + maskTop, zLevel).tex(uMax, vMin).endVertex();
|
||||
bufferBuilder.pos(xCoord, yCoord + maskTop, zLevel).tex(uMin, vMin).endVertex();
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
@@ -53,7 +53,7 @@ public interface IFilterable {
|
||||
for (int i = 0; i < filters.getSlots(); ++i) {
|
||||
FluidStack slot = filters.getFluid(i);
|
||||
|
||||
if (slot != null && API.instance().getComparer().isEqual(slot, stack, compare)) {
|
||||
if (!slot.isEmpty() && API.instance().getComparer().isEqual(slot, stack, compare)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public interface IFilterable {
|
||||
for (int i = 0; i < filters.getSlots(); ++i) {
|
||||
FluidStack slot = filters.getFluid(i);
|
||||
|
||||
if (slot != null && API.instance().getComparer().isEqual(slot, stack, compare)) {
|
||||
if (!slot.isEmpty() && API.instance().getComparer().isEqual(slot, stack, compare)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -18,13 +18,13 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.Style;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
@@ -139,103 +139,6 @@ public final class RenderUtils {
|
||||
return (int) multiplier;
|
||||
}
|
||||
|
||||
public static class FluidRenderer {
|
||||
private static final int TEX_WIDTH = 16;
|
||||
private static final int TEX_HEIGHT = 16;
|
||||
private static final int MIN_FLUID_HEIGHT = 1;
|
||||
|
||||
private final int capacityMb;
|
||||
private final int width;
|
||||
private final int height;
|
||||
|
||||
public FluidRenderer(int capacityMb, int width, int height) {
|
||||
this.capacityMb = capacityMb;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void draw(Minecraft minecraft, int xPosition, int yPosition, FluidStack fluidStack) {
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.enableAlphaTest();
|
||||
GlStateManager.disableLighting();
|
||||
|
||||
drawFluid(minecraft, xPosition, yPosition, fluidStack);
|
||||
|
||||
GlStateManager.color4f(1, 1, 1, 1);
|
||||
|
||||
GlStateManager.disableAlphaTest();
|
||||
GlStateManager.disableBlend();
|
||||
}
|
||||
|
||||
private void drawFluid(Minecraft minecraft, int xPosition, int yPosition, FluidStack fluidStack) {
|
||||
if (fluidStack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
|
||||
if (fluid == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* TODO
|
||||
TextureMap textureMapBlocks = minecraft.getTextureMapBlocks();
|
||||
ResourceLocation fluidStill = fluid.getStill();
|
||||
TextureAtlasSprite fluidStillSprite = null;
|
||||
|
||||
if (fluidStill != null) {
|
||||
fluidStillSprite = textureMapBlocks.getTextureExtry(fluidStill.toString());
|
||||
}
|
||||
|
||||
if (fluidStillSprite == null) {
|
||||
fluidStillSprite = textureMapBlocks.getMissingSprite();
|
||||
}
|
||||
|
||||
int fluidColor = fluid.getColor(fluidStack);
|
||||
|
||||
int scaledAmount = height;
|
||||
|
||||
if (capacityMb != -1) {
|
||||
scaledAmount = (fluidStack.amount * height) / capacityMb;
|
||||
|
||||
if (fluidStack.amount > 0 && scaledAmount < MIN_FLUID_HEIGHT) {
|
||||
scaledAmount = MIN_FLUID_HEIGHT;
|
||||
}
|
||||
|
||||
if (scaledAmount > height) {
|
||||
scaledAmount = height;
|
||||
}
|
||||
}
|
||||
|
||||
minecraft.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
setGLColorFromInt(fluidColor);
|
||||
|
||||
int xTileCount = width / TEX_WIDTH;
|
||||
int xRemainder = width - (xTileCount * TEX_WIDTH);
|
||||
int yTileCount = scaledAmount / TEX_HEIGHT;
|
||||
int yRemainder = scaledAmount - (yTileCount * TEX_HEIGHT);
|
||||
|
||||
int yStart = yPosition + height;
|
||||
|
||||
for (int xTile = 0; xTile <= xTileCount; xTile++) {
|
||||
for (int yTile = 0; yTile <= yTileCount; yTile++) {
|
||||
int width = (xTile == xTileCount) ? xRemainder : TEX_WIDTH;
|
||||
int height = (yTile == yTileCount) ? yRemainder : TEX_HEIGHT;
|
||||
int x = xPosition + (xTile * TEX_WIDTH);
|
||||
int y = yStart - ((yTile + 1) * TEX_HEIGHT);
|
||||
|
||||
if (width > 0 && height > 0) {
|
||||
int maskTop = TEX_HEIGHT - height;
|
||||
int maskRight = TEX_WIDTH - width;
|
||||
|
||||
drawFluidTexture(x, y, fluidStillSprite, maskTop, maskRight, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
public static void addCombinedItemsToTooltip(List<ITextComponent> tooltip, boolean displayAmount, List<ItemStack> stacks) {
|
||||
Set<Integer> combinedIndices = new HashSet<>();
|
||||
|
||||
@@ -259,7 +162,7 @@ public final class RenderUtils {
|
||||
data = new StringTextComponent(amount + "x ").appendSibling(data);
|
||||
}
|
||||
|
||||
tooltip.add(data);
|
||||
tooltip.add(data.setStyle(new Style().setColor(TextFormatting.GRAY)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -268,7 +171,7 @@ public final class RenderUtils {
|
||||
Set<Integer> combinedIndices = new HashSet<>();
|
||||
|
||||
for (int i = 0; i < stacks.size(); ++i) {
|
||||
if (!combinedIndices.contains(i)) {
|
||||
if (!stacks.get(i).isEmpty() && !combinedIndices.contains(i)) {
|
||||
FluidStack stack = stacks.get(i);
|
||||
|
||||
ITextComponent data = stack.getDisplayName();
|
||||
@@ -287,7 +190,7 @@ public final class RenderUtils {
|
||||
data = new StringTextComponent(API.instance().getQuantityFormatter().formatInBucketForm(amount) + " ").appendSibling(data);
|
||||
}
|
||||
|
||||
tooltip.add(data);
|
||||
tooltip.add(data.setStyle(new Style().setColor(TextFormatting.GRAY)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -214,7 +214,10 @@ public final class StackUtils {
|
||||
}
|
||||
|
||||
public static Pair<ItemStack, FluidStack> getFluid(ItemStack stack, boolean simulate) {
|
||||
// We won't have the capability on stacks with size bigger than 1.
|
||||
if (stack.isEmpty()) {
|
||||
return Pair.of(ItemStack.EMPTY, FluidStack.EMPTY);
|
||||
}
|
||||
|
||||
if (stack.getCount() > 1) {
|
||||
stack = ItemHandlerHelper.copyStackWithSize(stack, 1);
|
||||
}
|
||||
@@ -226,7 +229,7 @@ public final class StackUtils {
|
||||
return Pair.of(handler.getContainer(), result);
|
||||
}
|
||||
|
||||
return Pair.of(null, null);
|
||||
return Pair.of(ItemStack.EMPTY, FluidStack.EMPTY);
|
||||
}
|
||||
|
||||
private static final String NBT_ITEM_TYPE = "Type";
|
||||
|
@@ -43,10 +43,9 @@
|
||||
"gui.refinedstorage:wireless_transmitter": "Wireless Transmitter",
|
||||
"gui.refinedstorage:wireless_transmitter.distance": "%d block(s)",
|
||||
"gui.refinedstorage:crafter": "Crafter",
|
||||
"gui.refinedstorage:filter": "Filter",
|
||||
"gui.refinedstorage:filter.compare_damage": "Damage",
|
||||
"gui.refinedstorage:filter.compare_nbt": "NBT",
|
||||
"gui.refinedstorage:filter.mod_filter": "Mod filter",
|
||||
"gui.refinedstorage.filter": "Filter",
|
||||
"gui.refinedstorage.filter.compare_nbt": "NBT",
|
||||
"gui.refinedstorage.filter.mod_filter": "Mod filter",
|
||||
"gui.refinedstorage:network_transmitter": "Network Transmitter",
|
||||
"gui.refinedstorage:network_transmitter.distance": "%d block(s)",
|
||||
"gui.refinedstorage:network_transmitter.dimension": "Dimension %d",
|
||||
@@ -158,9 +157,9 @@
|
||||
"sidebutton.refinedstorage:grid.size.1": "Small",
|
||||
"sidebutton.refinedstorage:grid.size.2": "Medium",
|
||||
"sidebutton.refinedstorage:grid.size.3": "Large",
|
||||
"sidebutton.refinedstorage:mode": "Mode",
|
||||
"sidebutton.refinedstorage:mode.whitelist": "Whitelist",
|
||||
"sidebutton.refinedstorage:mode.blacklist": "Blacklist",
|
||||
"sidebutton.refinedstorage.mode": "Mode",
|
||||
"sidebutton.refinedstorage.mode.whitelist": "Whitelist",
|
||||
"sidebutton.refinedstorage.mode.blacklist": "Blacklist",
|
||||
"sidebutton.refinedstorage:iomode": "IO mode",
|
||||
"sidebutton.refinedstorage:iomode.insert": "Insert into network",
|
||||
"sidebutton.refinedstorage:iomode.extract": "Extract from network",
|
||||
@@ -266,7 +265,7 @@
|
||||
"item.refinedstorage.fortune_2_upgrade": "Fortune Upgrade",
|
||||
"item.refinedstorage.fortune_3_upgrade": "Fortune Upgrade",
|
||||
"item.refinedstorage.storage_housing": "Storage Housing",
|
||||
"item.refinedstorage:filter": "Filter",
|
||||
"item.refinedstorage.filter": "Filter",
|
||||
"item.refinedstorage.network_card": "Network Card",
|
||||
"item.refinedstorage.wrench": "Wrench",
|
||||
"item.refinedstorage.security_card": "Security Card",
|
||||
|
Reference in New Issue
Block a user