Pattern and wrench
This commit is contained in:
@@ -60,12 +60,9 @@ public final class RS {
|
|||||||
e.getRegistry().register(new ItemQuartzEnrichedIron());
|
e.getRegistry().register(new ItemQuartzEnrichedIron());
|
||||||
e.getRegistry().register(new ItemProcessorBinding());
|
e.getRegistry().register(new ItemProcessorBinding());
|
||||||
|
|
||||||
e.getRegistry().register(new ItemProcessor(ItemProcessor.Type.RAW_BASIC));
|
for (ItemProcessor.Type type : ItemProcessor.Type.values()) {
|
||||||
e.getRegistry().register(new ItemProcessor(ItemProcessor.Type.RAW_IMPROVED));
|
e.getRegistry().register(new ItemProcessor(type));
|
||||||
e.getRegistry().register(new ItemProcessor(ItemProcessor.Type.RAW_ADVANCED));
|
}
|
||||||
e.getRegistry().register(new ItemProcessor(ItemProcessor.Type.BASIC));
|
|
||||||
e.getRegistry().register(new ItemProcessor(ItemProcessor.Type.IMPROVED));
|
|
||||||
e.getRegistry().register(new ItemProcessor(ItemProcessor.Type.ADVANCED));
|
|
||||||
|
|
||||||
e.getRegistry().register(new ItemSilicon());
|
e.getRegistry().register(new ItemSilicon());
|
||||||
|
|
||||||
@@ -94,6 +91,9 @@ public final class RS {
|
|||||||
for (ItemUpgrade.Type type : ItemUpgrade.Type.values()) {
|
for (ItemUpgrade.Type type : ItemUpgrade.Type.values()) {
|
||||||
e.getRegistry().register(new ItemUpgrade(type));
|
e.getRegistry().register(new ItemUpgrade(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e.getRegistry().register(new ItemWrench());
|
||||||
|
e.getRegistry().register(new ItemPattern());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO
|
/* TODO
|
||||||
|
|||||||
@@ -22,6 +22,14 @@ public final class RSItems {
|
|||||||
@ObjectHolder(RS.ID + ":processor_binding")
|
@ObjectHolder(RS.ID + ":processor_binding")
|
||||||
public static final ItemProcessorBinding PROCESSOR_BINDING = null;
|
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")
|
@ObjectHolder(RS.ID + ":raw_basic_processor")
|
||||||
public static final ItemProcessor RAW_BASIC_PROCESSOR = null;
|
public static final ItemProcessor RAW_BASIC_PROCESSOR = null;
|
||||||
@ObjectHolder(RS.ID + ":raw_improved_processor")
|
@ObjectHolder(RS.ID + ":raw_improved_processor")
|
||||||
@@ -56,9 +64,6 @@ public final class RSItems {
|
|||||||
@ObjectHolder(RS.ID + ":creative_storage_disk")
|
@ObjectHolder(RS.ID + ":creative_storage_disk")
|
||||||
public static final ItemStorageDisk CREATIVE_STORAGE_DISK = null;
|
public static final ItemStorageDisk CREATIVE_STORAGE_DISK = null;
|
||||||
|
|
||||||
public static final ItemPattern PATTERN = new ItemPattern();
|
|
||||||
public static final ItemFilter FILTER = new ItemFilter();
|
|
||||||
|
|
||||||
@ObjectHolder(RS.ID + ":upgrade")
|
@ObjectHolder(RS.ID + ":upgrade")
|
||||||
public static final ItemUpgrade UPGRADE = null;
|
public static final ItemUpgrade UPGRADE = null;
|
||||||
@ObjectHolder(RS.ID + ":speed_upgrade")
|
@ObjectHolder(RS.ID + ":speed_upgrade")
|
||||||
@@ -112,5 +117,4 @@ public final class RSItems {
|
|||||||
|
|
||||||
public static final ItemCover COVER = new ItemCover();
|
public static final ItemCover COVER = new ItemCover();
|
||||||
public static final ItemHollowCover HOLLOW_COVER = new ItemHollowCover();
|
public static final ItemHollowCover HOLLOW_COVER = new ItemHollowCover();
|
||||||
public static final ItemWrench WRENCH = new ItemWrench();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class GuiGrid extends GuiBase<ContainerGrid> implements IResizableDisplay
|
|||||||
addSideButton(new SideButtonGridSize(this, () -> grid.getSize(), size -> grid.onSizeChanged(size)));
|
addSideButton(new SideButtonGridSize(this, () -> grid.getSize(), size -> grid.onSizeChanged(size)));
|
||||||
|
|
||||||
if (grid.getGridType() == GridType.PATTERN) {
|
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, t("misc.refinedstorage.processing"), TileGrid.PROCESSING_PATTERN.getValue());
|
||||||
|
|
||||||
boolean showOredict = true;
|
boolean showOredict = true;
|
||||||
if (((NetworkNodeGrid) grid).isProcessingPattern() && ((NetworkNodeGrid) grid).getType() == IType.FLUIDS) {
|
if (((NetworkNodeGrid) grid).isProcessingPattern() && ((NetworkNodeGrid) grid).getType() == IType.FLUIDS) {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import javax.annotation.Nullable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ItemFluidStorageDisk extends ItemBase implements IStorageDiskProvider {
|
public class ItemFluidStorageDisk extends Item implements IStorageDiskProvider {
|
||||||
private static final String NBT_ID = "Id";
|
private static final String NBT_ID = "Id";
|
||||||
|
|
||||||
private final FluidStorageType type;
|
private final FluidStorageType type;
|
||||||
|
|||||||
@@ -1,28 +1,55 @@
|
|||||||
package com.raoulvdberge.refinedstorage.item;
|
package com.raoulvdberge.refinedstorage.item;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
|
import com.raoulvdberge.refinedstorage.RSItems;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContainer;
|
||||||
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternProvider;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
||||||
import com.raoulvdberge.refinedstorage.item.info.ItemInfo;
|
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||||
|
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||||
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
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;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ItemPattern extends ItemBase/* implements ICraftingPatternProvider */ {
|
public class ItemPattern extends Item implements ICraftingPatternProvider {
|
||||||
private static Map<ItemStack, CraftingPattern> PATTERN_CACHE = new HashMap<>();
|
private static Map<ItemStack, CraftingPattern> CACHE = new HashMap<>();
|
||||||
|
|
||||||
private static final String NBT_VERSION = "Version";
|
private static final String NBT_VERSION = "Version";
|
||||||
public static final String NBT_INPUT_SLOT = "Input_%d";
|
private static final String NBT_INPUT_SLOT = "Input_%d";
|
||||||
public static final String NBT_OUTPUT_SLOT = "Output_%d";
|
private static final String NBT_OUTPUT_SLOT = "Output_%d";
|
||||||
private static final String NBT_FLUID_INPUT_SLOT = "FluidInput_%d";
|
private static final String NBT_FLUID_INPUT_SLOT = "FluidInput_%d";
|
||||||
private static final String NBT_FLUID_OUTPUT_SLOT = "FluidOutput_%d";
|
private static final String NBT_FLUID_OUTPUT_SLOT = "FluidOutput_%d";
|
||||||
private static final String NBT_OREDICT = "Oredict";
|
private static final String NBT_OREDICT = "Oredict"; // TODO - Rename since oredict is gone
|
||||||
public static final String NBT_PROCESSING = "Processing";
|
private static final String NBT_PROCESSING = "Processing";
|
||||||
|
|
||||||
|
private static final int VERSION = 1;
|
||||||
|
|
||||||
public ItemPattern() {
|
public ItemPattern() {
|
||||||
super(new ItemInfo(RS.ID, "pattern"));
|
super(new Item.Properties().group(RS.MAIN_GROUP));
|
||||||
|
|
||||||
|
this.setRegistryName(RS.ID, "pattern");
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
|
/* TODO - Pattern rendering
|
||||||
@Override
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void registerModels(IModelRegistration modelRegistration) {
|
public void registerModels(IModelRegistration modelRegistration) {
|
||||||
@@ -31,176 +58,62 @@ public class ItemPattern extends ItemBase/* implements ICraftingPatternProvider
|
|||||||
modelRegistration.addBakedModelOverride(info.getId(), BakedModelPattern::new);
|
modelRegistration.addBakedModelOverride(info.getId(), BakedModelPattern::new);
|
||||||
|
|
||||||
modelRegistration.addItemColor(this, new ItemColorPattern());
|
modelRegistration.addItemColor(this, new ItemColorPattern());
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public static CraftingPattern fromCache(World world, ItemStack stack) {
|
||||||
|
if (!CACHE.containsKey(stack)) {
|
||||||
|
CACHE.put(stack, new CraftingPattern(world, null, stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CraftingPattern getPatternFromCache(World world, ItemStack stack) {
|
return CACHE.get(stack);
|
||||||
if (!PATTERN_CACHE.containsKey(stack)) {
|
|
||||||
PATTERN_CACHE.put(stack, new CraftingPattern(world, null, stack));
|
|
||||||
}
|
|
||||||
|
|
||||||
return PATTERN_CACHE.get(stack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
super.addInformation(stack, world, tooltip, flag);
|
||||||
|
|
||||||
if (!stack.hasTagCompound()) {
|
if (!stack.hasTag()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ICraftingPattern pattern = getPatternFromCache(world, stack);
|
ICraftingPattern pattern = fromCache(world, stack);
|
||||||
|
|
||||||
|
Style yellow = new Style().setColor(TextFormatting.YELLOW);
|
||||||
|
Style blue = new Style().setColor(TextFormatting.BLUE);
|
||||||
|
Style red = new Style().setColor(TextFormatting.RED);
|
||||||
|
|
||||||
if (pattern.isValid()) {
|
if (pattern.isValid()) {
|
||||||
if (GuiScreen.isShiftKeyDown() || isProcessing(stack)) {
|
if (ContainerScreen.hasShiftDown() || isProcessing(stack)) {
|
||||||
tooltip.add(TextFormatting.YELLOW + I18n.format("misc.refinedstorage:pattern.inputs") + TextFormatting.RESET);
|
tooltip.add(new TranslationTextComponent("misc.refinedstorage.pattern.inputs").setStyle(yellow));
|
||||||
|
|
||||||
RenderUtils.addCombinedItemsToTooltip(tooltip, true, pattern.getInputs().stream().map(i -> i.size() > 0 ? i.get(0) : ItemStack.EMPTY).collect(Collectors.toList()));
|
RenderUtils.addCombinedItemsToTooltip(tooltip, true, pattern.getInputs().stream().map(i -> i.size() > 0 ? i.get(0) : ItemStack.EMPTY).collect(Collectors.toList()));
|
||||||
RenderUtils.addCombinedFluidsToTooltip(tooltip, true, pattern.getFluidInputs());
|
RenderUtils.addCombinedFluidsToTooltip(tooltip, true, pattern.getFluidInputs());
|
||||||
|
|
||||||
tooltip.add(TextFormatting.YELLOW + I18n.format("misc.refinedstorage:pattern.outputs") + TextFormatting.RESET);
|
tooltip.add(new TranslationTextComponent("misc.refinedstorage.pattern.outputs").setStyle(yellow));
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderUtils.addCombinedItemsToTooltip(tooltip, true, pattern.getOutputs());
|
RenderUtils.addCombinedItemsToTooltip(tooltip, true, pattern.getOutputs());
|
||||||
RenderUtils.addCombinedFluidsToTooltip(tooltip, true, pattern.getFluidOutputs());
|
RenderUtils.addCombinedFluidsToTooltip(tooltip, true, pattern.getFluidOutputs());
|
||||||
|
|
||||||
if (isOredict(stack)) {
|
if (isOredict(stack)) {
|
||||||
tooltip.add(TextFormatting.BLUE + I18n.format("misc.refinedstorage:pattern.oredict") + TextFormatting.RESET);
|
tooltip.add(new TranslationTextComponent("misc.refinedstorage.pattern.oredict").setStyle(blue));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isProcessing(stack)) {
|
if (isProcessing(stack)) {
|
||||||
tooltip.add(TextFormatting.BLUE + I18n.format("misc.refinedstorage:processing") + TextFormatting.RESET);
|
tooltip.add(new TranslationTextComponent("misc.refinedstorage.processing").setStyle(blue));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tooltip.add(TextFormatting.RED + I18n.format("misc.refinedstorage:pattern.invalid") + TextFormatting.RESET);
|
tooltip.add(new TranslationTextComponent("misc.refinedstorage.pattern.invalid").setStyle(red));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setInputSlot(ItemStack pattern, int slot, ItemStack stack) {
|
|
||||||
if (!pattern.hasTagCompound()) {
|
|
||||||
pattern.setTagCompound(new CompoundNBT());
|
|
||||||
}
|
|
||||||
|
|
||||||
pattern.getTagCompound().put(String.format(NBT_INPUT_SLOT, slot), stack.serializeNBT());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static ItemStack getInputSlot(ItemStack pattern, int slot) {
|
|
||||||
String id = String.format(NBT_INPUT_SLOT, slot);
|
|
||||||
|
|
||||||
if (!pattern.hasTagCompound() || !pattern.getTagCompound().hasKey(id)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack stack = new ItemStack(pattern.getTagCompound().getCompound(id));
|
|
||||||
if (stack.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setOutputSlot(ItemStack pattern, int slot, ItemStack stack) {
|
|
||||||
if (!pattern.hasTagCompound()) {
|
|
||||||
pattern.setTagCompound(new CompoundNBT());
|
|
||||||
}
|
|
||||||
|
|
||||||
pattern.getTagCompound().put(String.format(NBT_OUTPUT_SLOT, slot), stack.serializeNBT());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static ItemStack getOutputSlot(ItemStack pattern, int slot) {
|
|
||||||
String id = String.format(NBT_OUTPUT_SLOT, slot);
|
|
||||||
|
|
||||||
if (!pattern.hasTagCompound() || !pattern.getTagCompound().hasKey(id)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack stack = new ItemStack(pattern.getTagCompound().getCompound(id));
|
|
||||||
if (stack.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setFluidInputSlot(ItemStack pattern, int slot, FluidStack stack) {
|
|
||||||
if (!pattern.hasTagCompound()) {
|
|
||||||
pattern.setTagCompound(new CompoundNBT());
|
|
||||||
}
|
|
||||||
|
|
||||||
pattern.getTagCompound().put(String.format(NBT_FLUID_INPUT_SLOT, slot), stack.writeToNBT(new CompoundNBT()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static FluidStack getFluidInputSlot(ItemStack pattern, int slot) {
|
|
||||||
String id = String.format(NBT_FLUID_INPUT_SLOT, slot);
|
|
||||||
|
|
||||||
if (!pattern.hasTagCompound() || !pattern.getTagCompound().hasKey(id)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FluidStack.loadFluidStackFromNBT(pattern.getTagCompound().getCompound(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setFluidOutputSlot(ItemStack pattern, int slot, FluidStack stack) {
|
|
||||||
if (!pattern.hasTagCompound()) {
|
|
||||||
pattern.setTagCompound(new CompoundNBT());
|
|
||||||
}
|
|
||||||
|
|
||||||
pattern.getTagCompound().put(String.format(NBT_FLUID_OUTPUT_SLOT, slot), stack.writeToNBT(new CompoundNBT()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static FluidStack getFluidOutputSlot(ItemStack pattern, int slot) {
|
|
||||||
String id = String.format(NBT_FLUID_OUTPUT_SLOT, slot);
|
|
||||||
|
|
||||||
if (!pattern.hasTagCompound() || !pattern.getTagCompound().hasKey(id)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FluidStack.loadFluidStackFromNBT(pattern.getTagCompound().getCompound(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isProcessing(ItemStack pattern) {
|
|
||||||
return pattern.hasTagCompound() && pattern.getTagCompound().hasKey(NBT_PROCESSING) && pattern.getTagCompound().getBoolean(NBT_PROCESSING);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setProcessing(ItemStack pattern, boolean processing) {
|
|
||||||
if (!pattern.hasTagCompound()) {
|
|
||||||
pattern.setTagCompound(new CompoundNBT());
|
|
||||||
}
|
|
||||||
|
|
||||||
pattern.getTagCompound().putBoolean(NBT_PROCESSING, processing);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isOredict(ItemStack pattern) {
|
|
||||||
return pattern.hasTagCompound() && pattern.getTagCompound().hasKey(NBT_OREDICT) && pattern.getTagCompound().getBoolean(NBT_OREDICT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setOredict(ItemStack pattern, boolean oredict) {
|
|
||||||
if (!pattern.hasTagCompound()) {
|
|
||||||
pattern.setTagCompound(new CompoundNBT());
|
|
||||||
}
|
|
||||||
|
|
||||||
pattern.getTagCompound().putBoolean(NBT_OREDICT, oredict);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setVersion(ItemStack pattern) {
|
|
||||||
if (!pattern.hasTagCompound()) {
|
|
||||||
pattern.setTagCompound(new CompoundNBT());
|
|
||||||
}
|
|
||||||
|
|
||||||
pattern.getTagCompound().setString(NBT_VERSION, RS.VERSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, EnumHand hand) {
|
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
|
||||||
if (!world.isRemote && player.isSneaking()) {
|
if (!world.isRemote && player.isSneaking()) {
|
||||||
return new ActionResult<>(EnumActionResult.SUCCESS, new ItemStack(RSItems.PATTERN, player.getHeldItem(hand).getCount()));
|
return new ActionResult<>(ActionResultType.SUCCESS, new ItemStack(RSItems.PATTERN, player.getHeldItem(hand).getCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
|
return new ActionResult<>(ActionResultType.PASS, player.getHeldItem(hand));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -209,12 +122,121 @@ public class ItemPattern extends ItemBase/* implements ICraftingPatternProvider
|
|||||||
return new CraftingPattern(world, container, stack);
|
return new CraftingPattern(world, container, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static void setInputSlot(ItemStack pattern, int slot, ItemStack stack) {
|
||||||
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isSelected) {
|
if (!pattern.hasTag()) {
|
||||||
super.onUpdate(stack, world, entity, slot, isSelected);
|
pattern.setTag(new CompoundNBT());
|
||||||
|
}
|
||||||
|
|
||||||
if (!world.isRemote) {
|
pattern.getTag().put(String.format(NBT_INPUT_SLOT, slot), stack.serializeNBT());
|
||||||
API.instance().getOneSixMigrationHelper().migratePattern(stack);
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static ItemStack getInputSlot(ItemStack pattern, int slot) {
|
||||||
|
String id = String.format(NBT_INPUT_SLOT, slot);
|
||||||
|
|
||||||
|
if (!pattern.hasTag() || !pattern.getTag().contains(id)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack stack = ItemStack.read(pattern.getTag().getCompound(id));
|
||||||
|
if (stack.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setOutputSlot(ItemStack pattern, int slot, ItemStack stack) {
|
||||||
|
if (!pattern.hasTag()) {
|
||||||
|
pattern.setTag(new CompoundNBT());
|
||||||
|
}
|
||||||
|
|
||||||
|
pattern.getTag().put(String.format(NBT_OUTPUT_SLOT, slot), stack.serializeNBT());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static ItemStack getOutputSlot(ItemStack pattern, int slot) {
|
||||||
|
String id = String.format(NBT_OUTPUT_SLOT, slot);
|
||||||
|
|
||||||
|
if (!pattern.hasTag() || !pattern.getTag().contains(id)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack stack = ItemStack.read(pattern.getTag().getCompound(id));
|
||||||
|
if (stack.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setFluidInputSlot(ItemStack pattern, int slot, FluidStack stack) {
|
||||||
|
if (!pattern.hasTag()) {
|
||||||
|
pattern.setTag(new CompoundNBT());
|
||||||
|
}
|
||||||
|
|
||||||
|
pattern.getTag().put(String.format(NBT_FLUID_INPUT_SLOT, slot), stack.writeToNBT(new CompoundNBT()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static FluidStack getFluidInputSlot(ItemStack pattern, int slot) {
|
||||||
|
String id = String.format(NBT_FLUID_INPUT_SLOT, slot);
|
||||||
|
|
||||||
|
if (!pattern.hasTag() || !pattern.getTag().contains(id)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FluidStack.loadFluidStackFromNBT(pattern.getTag().getCompound(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setFluidOutputSlot(ItemStack pattern, int slot, FluidStack stack) {
|
||||||
|
if (!pattern.hasTag()) {
|
||||||
|
pattern.setTag(new CompoundNBT());
|
||||||
|
}
|
||||||
|
|
||||||
|
pattern.getTag().put(String.format(NBT_FLUID_OUTPUT_SLOT, slot), stack.writeToNBT(new CompoundNBT()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static FluidStack getFluidOutputSlot(ItemStack pattern, int slot) {
|
||||||
|
String id = String.format(NBT_FLUID_OUTPUT_SLOT, slot);
|
||||||
|
|
||||||
|
if (!pattern.hasTag() || !pattern.getTag().contains(id)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FluidStack.loadFluidStackFromNBT(pattern.getTag().getCompound(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isProcessing(ItemStack pattern) {
|
||||||
|
return pattern.hasTag() && pattern.getTag().contains(NBT_PROCESSING) && pattern.getTag().getBoolean(NBT_PROCESSING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setProcessing(ItemStack pattern, boolean processing) {
|
||||||
|
if (!pattern.hasTag()) {
|
||||||
|
pattern.setTag(new CompoundNBT());
|
||||||
|
}
|
||||||
|
|
||||||
|
pattern.getTag().putBoolean(NBT_PROCESSING, processing);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isOredict(ItemStack pattern) {
|
||||||
|
return pattern.hasTag() && pattern.getTag().contains(NBT_OREDICT) && pattern.getTag().getBoolean(NBT_OREDICT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setOredict(ItemStack pattern, boolean oredict) {
|
||||||
|
if (!pattern.hasTag()) {
|
||||||
|
pattern.setTag(new CompoundNBT());
|
||||||
|
}
|
||||||
|
|
||||||
|
pattern.getTag().putBoolean(NBT_OREDICT, oredict);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setVersion(ItemStack pattern) {
|
||||||
|
if (!pattern.hasTag()) {
|
||||||
|
pattern.setTag(new CompoundNBT());
|
||||||
|
}
|
||||||
|
|
||||||
|
pattern.getTag().putInt(NBT_VERSION, VERSION);
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.raoulvdberge.refinedstorage.RSItems;
|
|||||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.ItemStorageType;
|
import com.raoulvdberge.refinedstorage.apiimpl.storage.ItemStorageType;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
public class ItemStoragePart extends ItemBase {
|
public class ItemStoragePart extends Item {
|
||||||
public ItemStoragePart(ItemStorageType type) {
|
public ItemStoragePart(ItemStorageType type) {
|
||||||
super(new Item.Properties().group(RS.MAIN_GROUP));
|
super(new Item.Properties().group(RS.MAIN_GROUP));
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +1,47 @@
|
|||||||
package com.raoulvdberge.refinedstorage.item;
|
package com.raoulvdberge.refinedstorage.item;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.item.info.ItemInfo;
|
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||||
|
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemUseContext;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
|
import net.minecraft.util.Rotation;
|
||||||
|
|
||||||
public class ItemWrench extends ItemBase {
|
public class ItemWrench extends Item {
|
||||||
public ItemWrench() {
|
public ItemWrench() {
|
||||||
super(new ItemInfo(RS.ID, "wrench"));
|
super(new Item.Properties().group(RS.MAIN_GROUP).maxStackSize(1));
|
||||||
|
|
||||||
//setMaxStackSize(1);
|
this.setRegistryName(RS.ID, "wrench");
|
||||||
}
|
|
||||||
/* TODO
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerModels(IModelRegistration modelRegistration) {
|
|
||||||
modelRegistration.setModel(this, 0, new ModelResourceLocation(info.getId(), "inventory"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
public ActionResultType onItemUse(ItemUseContext ctx) {
|
||||||
if (!player.isSneaking()) {
|
if (!ctx.getPlayer().isSneaking()) {
|
||||||
return EnumActionResult.FAIL;
|
return ActionResultType.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world.isRemote) {
|
if (ctx.getWorld().isRemote) {
|
||||||
return EnumActionResult.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = ctx.getWorld().getTileEntity(ctx.getPos());
|
||||||
|
|
||||||
if (tile instanceof TileNode && ((TileNode) tile).getNode().getNetwork() != null && !((TileNode) tile).getNode().getNetwork().getSecurityManager().hasPermission(Permission.BUILD, player)) {
|
// TODO - Better INetworkNode check
|
||||||
WorldUtils.sendNoPermissionMessage(player);
|
if (tile instanceof TileNode &&
|
||||||
|
((TileNode) tile).getNode().getNetwork() != null &&
|
||||||
|
!((TileNode) tile).getNode().getNetwork().getSecurityManager().hasPermission(Permission.BUILD, ctx.getPlayer())) {
|
||||||
|
WorldUtils.sendNoPermissionMessage(ctx.getPlayer());
|
||||||
|
|
||||||
return EnumActionResult.FAIL;
|
return ActionResultType.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
IBlockState state = world.getBlockState(pos);
|
BlockState state = ctx.getWorld().getBlockState(ctx.getPos());
|
||||||
|
|
||||||
Block block = state.getBlock();
|
|
||||||
|
|
||||||
|
/* TODO - Covers
|
||||||
if (block instanceof BlockCable && tile instanceof TileNode && ((TileNode) tile).getNode() instanceof ICoverable) {
|
if (block instanceof BlockCable && tile instanceof TileNode && ((TileNode) tile).getNode() instanceof ICoverable) {
|
||||||
CoverManager manager = ((ICoverable) ((TileNode) tile).getNode()).getCoverManager();
|
CoverManager manager = ((ICoverable) ((TileNode) tile).getNode()).getCoverManager();
|
||||||
|
|
||||||
@@ -63,13 +67,13 @@ public class ItemWrench extends ItemBase {
|
|||||||
|
|
||||||
InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), cover);
|
InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), cover);
|
||||||
|
|
||||||
return EnumActionResult.SUCCESS;
|
return ActionResultType.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
block.rotateBlock(world, pos, player.getHorizontalFacing().getOpposite());
|
|
||||||
|
|
||||||
return EnumActionResult.SUCCESS;
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
ctx.getWorld().setBlockState(ctx.getPos(), state.rotate(Rotation.CLOCKWISE_90));
|
||||||
|
|
||||||
|
return ActionResultType.SUCCESS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ import net.minecraft.util.BlockRenderLayer;
|
|||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraftforge.client.ForgeHooksClient;
|
import net.minecraftforge.client.ForgeHooksClient;
|
||||||
import net.minecraftforge.client.MinecraftForgeClient;
|
import net.minecraftforge.client.MinecraftForgeClient;
|
||||||
@@ -235,14 +236,14 @@ public final class RenderUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addCombinedItemsToTooltip(List<String> tooltip, boolean displayAmount, List<ItemStack> stacks) {
|
public static void addCombinedItemsToTooltip(List<ITextComponent> tooltip, boolean displayAmount, List<ItemStack> stacks) {
|
||||||
Set<Integer> combinedIndices = new HashSet<>();
|
Set<Integer> combinedIndices = new HashSet<>();
|
||||||
|
|
||||||
for (int i = 0; i < stacks.size(); ++i) {
|
for (int i = 0; i < stacks.size(); ++i) {
|
||||||
if (!stacks.get(i).isEmpty() && !combinedIndices.contains(i)) {
|
if (!stacks.get(i).isEmpty() && !combinedIndices.contains(i)) {
|
||||||
ItemStack stack = stacks.get(i);
|
ItemStack stack = stacks.get(i);
|
||||||
|
|
||||||
String data = stack.getDisplayName().getString(); // TODO does this work
|
ITextComponent data = stack.getDisplayName();
|
||||||
|
|
||||||
int amount = stack.getCount();
|
int amount = stack.getCount();
|
||||||
|
|
||||||
@@ -254,21 +255,23 @@ public final class RenderUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data = (displayAmount ? (String.valueOf(amount) + "x ") : "") + data;
|
if (displayAmount) {
|
||||||
|
data = new StringTextComponent(amount + "x ").appendSibling(data);
|
||||||
|
}
|
||||||
|
|
||||||
tooltip.add(data);
|
tooltip.add(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addCombinedFluidsToTooltip(List<String> tooltip, boolean showMb, NonNullList<FluidStack> stacks) {
|
public static void addCombinedFluidsToTooltip(List<ITextComponent> tooltip, boolean displayMb, NonNullList<FluidStack> stacks) {
|
||||||
Set<Integer> combinedIndices = new HashSet<>();
|
Set<Integer> combinedIndices = new HashSet<>();
|
||||||
|
|
||||||
for (int i = 0; i < stacks.size(); ++i) {
|
for (int i = 0; i < stacks.size(); ++i) {
|
||||||
if (!combinedIndices.contains(i)) {
|
if (!combinedIndices.contains(i)) {
|
||||||
FluidStack stack = stacks.get(i);
|
FluidStack stack = stacks.get(i);
|
||||||
|
|
||||||
String data = stack.getDisplayName().getString(); // TODO does this work
|
ITextComponent data = stack.getDisplayName();
|
||||||
|
|
||||||
int amount = stack.getAmount();
|
int amount = stack.getAmount();
|
||||||
|
|
||||||
@@ -280,7 +283,11 @@ public final class RenderUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tooltip.add((showMb ? (API.instance().getQuantityFormatter().formatInBucketForm(amount) + " ") : "") + data);
|
if (displayMb) {
|
||||||
|
data = new StringTextComponent(API.instance().getQuantityFormatter().formatInBucketForm(amount) + " ").appendSibling(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
tooltip.add(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,10 +97,10 @@
|
|||||||
"misc.refinedstorage:network_item.out_of_range": "There is no Wireless Transmitter in range.",
|
"misc.refinedstorage:network_item.out_of_range": "There is no Wireless Transmitter in range.",
|
||||||
"misc.refinedstorage:network_item.not_found": "Controller not found.",
|
"misc.refinedstorage:network_item.not_found": "Controller not found.",
|
||||||
"misc.refinedstorage.network_card.tooltip": "Linked to %d, %d, %d.",
|
"misc.refinedstorage.network_card.tooltip": "Linked to %d, %d, %d.",
|
||||||
"misc.refinedstorage:pattern.inputs": "Inputs",
|
"misc.refinedstorage.pattern.inputs": "Inputs",
|
||||||
"misc.refinedstorage:pattern.outputs": "Outputs",
|
"misc.refinedstorage.pattern.outputs": "Outputs",
|
||||||
"misc.refinedstorage:pattern.invalid": "Invalid pattern",
|
"misc.refinedstorage.pattern.invalid": "Invalid pattern",
|
||||||
"misc.refinedstorage:pattern.oredict": "Uses ore dictionary",
|
"misc.refinedstorage.pattern.oredict": "Uses ore dictionary",
|
||||||
"misc.refinedstorage:security.no_permission": "You have no permission to perform that action.",
|
"misc.refinedstorage:security.no_permission": "You have no permission to perform that action.",
|
||||||
"misc.refinedstorage:start": "Start",
|
"misc.refinedstorage:start": "Start",
|
||||||
"misc.refinedstorage:clear": "Clear",
|
"misc.refinedstorage:clear": "Clear",
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
"misc.refinedstorage:cancel_all": "Cancel All",
|
"misc.refinedstorage:cancel_all": "Cancel All",
|
||||||
"misc.refinedstorage:priority": "Priority",
|
"misc.refinedstorage:priority": "Priority",
|
||||||
"misc.refinedstorage:oredict": "Oredict",
|
"misc.refinedstorage:oredict": "Oredict",
|
||||||
"misc.refinedstorage:processing": "Processing",
|
"misc.refinedstorage.processing": "Processing",
|
||||||
"misc.refinedstorage:reader_writer.redstone": "Redstone strength: %d",
|
"misc.refinedstorage:reader_writer.redstone": "Redstone strength: %d",
|
||||||
"misc.refinedstorage:total": "%s total",
|
"misc.refinedstorage:total": "%s total",
|
||||||
"misc.refinedstorage:last_modified.just_now": "Last modified just now by %s",
|
"misc.refinedstorage:last_modified.just_now": "Last modified just now by %s",
|
||||||
@@ -255,7 +255,7 @@
|
|||||||
"item.refinedstorage.256k_fluid_storage_part": "256k Fluid Storage Part",
|
"item.refinedstorage.256k_fluid_storage_part": "256k Fluid Storage Part",
|
||||||
"item.refinedstorage.1024k_fluid_storage_part": "1024k Fluid Storage Part",
|
"item.refinedstorage.1024k_fluid_storage_part": "1024k Fluid Storage Part",
|
||||||
"item.refinedstorage.4096k_fluid_storage_part": "4096k Fluid Storage Part",
|
"item.refinedstorage.4096k_fluid_storage_part": "4096k Fluid Storage Part",
|
||||||
"item.refinedstorage:pattern": "Pattern",
|
"item.refinedstorage.pattern": "Pattern",
|
||||||
"item.refinedstorage.upgrade": "Upgrade",
|
"item.refinedstorage.upgrade": "Upgrade",
|
||||||
"item.refinedstorage.range_upgrade": "Range Upgrade",
|
"item.refinedstorage.range_upgrade": "Range Upgrade",
|
||||||
"item.refinedstorage.speed_upgrade": "Speed Upgrade",
|
"item.refinedstorage.speed_upgrade": "Speed Upgrade",
|
||||||
@@ -268,7 +268,7 @@
|
|||||||
"item.refinedstorage.storage_housing": "Storage Housing",
|
"item.refinedstorage.storage_housing": "Storage Housing",
|
||||||
"item.refinedstorage:filter": "Filter",
|
"item.refinedstorage:filter": "Filter",
|
||||||
"item.refinedstorage.network_card": "Network Card",
|
"item.refinedstorage.network_card": "Network Card",
|
||||||
"item.refinedstorage:wrench": "Wrench",
|
"item.refinedstorage.wrench": "Wrench",
|
||||||
"item.refinedstorage.security_card": "Security Card",
|
"item.refinedstorage.security_card": "Security Card",
|
||||||
"item.refinedstorage.security_card.owner": "Bound to: %s",
|
"item.refinedstorage.security_card.owner": "Bound to: %s",
|
||||||
"item.refinedstorage.cutting_tool": "Cutting Tool",
|
"item.refinedstorage.cutting_tool": "Cutting Tool",
|
||||||
|
|||||||
@@ -7,8 +7,7 @@
|
|||||||
],
|
],
|
||||||
"key": {
|
"key": {
|
||||||
"G": {
|
"G": {
|
||||||
"type": "forge:ore_dict",
|
"tag": "forge:glass"
|
||||||
"ore": "blockGlass"
|
|
||||||
},
|
},
|
||||||
"R": {
|
"R": {
|
||||||
"item": "minecraft:redstone"
|
"item": "minecraft:redstone"
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
"item": "refinedstorage:quartz_enriched_iron"
|
"item": "refinedstorage:quartz_enriched_iron"
|
||||||
},
|
},
|
||||||
"P": {
|
"P": {
|
||||||
"item": "#basic_processor"
|
"item": "refinedstorage:basic_processor"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"result": {
|
"result": {
|
||||||
Reference in New Issue
Block a user