Added the ability to see the output of a Pattern by shift clicking
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
- Added support for ore dictionary substitutions in Crafting Patterns (raoulvdberge)
|
- Added support for ore dictionary substitutions in Crafting Patterns (raoulvdberge)
|
||||||
- Added Disk Manipulator (way2muchnoise)
|
- Added Disk Manipulator (way2muchnoise)
|
||||||
- Added ingame config (way2muchnoise)
|
- Added ingame config (way2muchnoise)
|
||||||
|
- Added the ability to see the output of a Pattern by shift clicking (raoulvdberge)
|
||||||
- When a machine is in use by a crafting pattern, inserting of items from other patterns will be avoided (raoulvdberge)
|
- When a machine is in use by a crafting pattern, inserting of items from other patterns will be avoided (raoulvdberge)
|
||||||
- Exporter in fluid mode no longer duplicates fluids that are less than 1 bucket (raoulvdberge)
|
- Exporter in fluid mode no longer duplicates fluids that are less than 1 bucket (raoulvdberge)
|
||||||
- Updated Dutch translation (raoulvdberge)
|
- Updated Dutch translation (raoulvdberge)
|
||||||
|
|||||||
@@ -21,12 +21,15 @@ import refinedstorage.api.storage.CompareUtils;
|
|||||||
import refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
import refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ItemPattern extends ItemBase implements ICraftingPatternProvider {
|
public class ItemPattern extends ItemBase implements ICraftingPatternProvider {
|
||||||
|
/**
|
||||||
|
* A cache that maps a stack to a crafting pattern.
|
||||||
|
* Only used client side for rendering and tooltips, to avoid crafting pattern allocations and crafting pattern output calculation (which is expensive).
|
||||||
|
*/
|
||||||
|
private static Map<ItemStack, CraftingPattern> PATTERN_CACHE = new HashMap<>();
|
||||||
|
|
||||||
private static final String NBT_SLOT = "Slot_%d";
|
private static final String NBT_SLOT = "Slot_%d";
|
||||||
private static final String NBT_OUTPUTS = "Outputs";
|
private static final String NBT_OUTPUTS = "Outputs";
|
||||||
private static final String NBT_OREDICTED = "Oredicted";
|
private static final String NBT_OREDICTED = "Oredicted";
|
||||||
@@ -35,13 +38,21 @@ public class ItemPattern extends ItemBase implements ICraftingPatternProvider {
|
|||||||
super("pattern");
|
super("pattern");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CraftingPattern getPatternFromCache(World world, ItemStack 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, EntityPlayer player, List<String> tooltip, boolean advanced) {
|
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
|
||||||
if (!stack.hasTagCompound()) {
|
if (!stack.hasTagCompound()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ICraftingPattern pattern = create(player.worldObj, stack, null);
|
ICraftingPattern pattern = getPatternFromCache(player.worldObj, stack);
|
||||||
|
|
||||||
if (pattern.isValid()) {
|
if (pattern.isValid()) {
|
||||||
if (GuiScreen.isShiftKeyDown() || isProcessing(stack)) {
|
if (GuiScreen.isShiftKeyDown() || isProcessing(stack)) {
|
||||||
|
|||||||
75
src/main/java/refinedstorage/item/PatternBakedModel.java
Executable file
75
src/main/java/refinedstorage/item/PatternBakedModel.java
Executable file
@@ -0,0 +1,75 @@
|
|||||||
|
package refinedstorage.item;
|
||||||
|
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||||
|
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||||
|
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||||
|
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import refinedstorage.apiimpl.autocrafting.CraftingPattern;
|
||||||
|
import refinedstorage.gui.GuiBase;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PatternBakedModel implements IBakedModel {
|
||||||
|
private IBakedModel patternModel;
|
||||||
|
|
||||||
|
public PatternBakedModel(IBakedModel patternModel) {
|
||||||
|
this.patternModel = patternModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
|
||||||
|
return patternModel.getQuads(state, side, rand);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAmbientOcclusion() {
|
||||||
|
return patternModel.isAmbientOcclusion();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isGui3d() {
|
||||||
|
return patternModel.isGui3d();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBuiltInRenderer() {
|
||||||
|
return patternModel.isBuiltInRenderer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TextureAtlasSprite getParticleTexture() {
|
||||||
|
return patternModel.getParticleTexture();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public ItemCameraTransforms getItemCameraTransforms() {
|
||||||
|
return patternModel.getItemCameraTransforms();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemOverrideList getOverrides() {
|
||||||
|
return new ItemOverrideList(patternModel.getOverrides().getOverrides()) {
|
||||||
|
@Override
|
||||||
|
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
|
||||||
|
CraftingPattern pattern = ItemPattern.getPatternFromCache(world, stack);
|
||||||
|
|
||||||
|
if (GuiBase.isShiftKeyDown() && pattern.isValid() && pattern.getOutputs().size() == 1) {
|
||||||
|
ItemStack output = pattern.getOutputs().get(0);
|
||||||
|
|
||||||
|
return Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(output, world, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.handleItemState(originalModel, stack, world, entity);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,6 +42,10 @@ public class ClientProxy extends CommonProxy {
|
|||||||
e.getModelRegistry().putObject(model, ModelMultipartContainer.fromBlock(e.getModelRegistry().getObject(model), cable));
|
e.getModelRegistry().putObject(model, ModelMultipartContainer.fromBlock(e.getModelRegistry().getObject(model), cable));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (model.getResourceDomain().equals(RefinedStorage.ID) && model.getResourcePath().equals("pattern")) {
|
||||||
|
e.getModelRegistry().putObject(model, new PatternBakedModel(e.getModelRegistry().getObject(model)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user