@Override public String apply(ItemStack itemStack) { String meta = itemStack.getItemDamage() + ":"; Item part = Pattern.getPartFromTag(itemStack); if(part == null) { return meta; } return meta + part.getRegistryName(); }
public static class PatternMeshDefinition implements ItemMeshDefinition { private final ResourceLocation baseLocation; public PatternMeshDefinition(ResourceLocation baseLocation) { this.baseLocation = baseLocation; } @Nonnull @Override public ModelResourceLocation getModelLocation(@Nonnull ItemStack stack) { Item item = Pattern.getPartFromTag(stack); String suffix = ""; if(item != null) { suffix = Pattern.getTextureIdentifier(item); } return new ModelResourceLocation(new ResourceLocation(baseLocation.getResourceDomain(), baseLocation.getResourcePath() + suffix), "inventory"); } }
public class SlotStencil extends Slot { private boolean requireBlank; public SlotStencil(IInventory inventoryIn, int index, int xPosition, int yPosition, boolean requireBlank) { super(inventoryIn, index, xPosition, yPosition); this.requireBlank = requireBlank; } @Override public boolean isItemValid(ItemStack stack) { if(stack == null || !(stack.getItem() instanceof IPattern)) { return false; } return !requireBlank || !(stack.getItem() instanceof Pattern) || ((Pattern) stack.getItem()).isBlankPattern(stack); } }
subItems.add(new ItemStack(this)); for(Item toolpart : getSubItemToolparts()) { ItemStack stack = new ItemStack(this); setTagForPart(stack, toolpart); if(isValidSubitem(toolpart)) { subItems.add(stack); @Override public String getItemStackDisplayName(@Nonnull ItemStack stack) { Item part = getPartFromTag(stack); String unloc = this.getUnlocalizedNameInefficiently(stack); if(part == null) { Item part = getPartFromTag(stack); if(part != null && part instanceof IToolPart) { float cost = ((IToolPart) part).getCost() / (float) Material.VALUE_Ingot;
@Override @SubscribeEvent public void registerItems(Register<Item> event) { IForgeRegistry<Item> registry = event.getRegistry(); // register items pattern = registerItem(registry, new Pattern(), "pattern"); shard = registerItem(registry, new Shard(), "shard"); sharpeningKit = (SharpeningKit) registerToolPart(registry, new SharpeningKit(), "sharpening_kit"); sharpeningKit.setCreativeTab(TinkerRegistry.tabParts); TinkerRegistry.registerToolPart(sharpeningKit); TinkerRegistry.registerToolPart(shard); super.registerItems(event); // register blocks toolTables = registerItemBlockProp(registry, new ItemBlockTable(toolTables), BlockToolTable.TABLES); toolForge = registerItemBlock(registry, new ItemBlockTable(toolForge)); // set shard TinkerRegistry.setShardItem(shard); TinkerRegistry.registerStencilTableCrafting(Pattern.setTagForPart(new ItemStack(pattern), sharpeningKit)); TinkerRegistry.registerStencilTableCrafting(Pattern.setTagForPart(new ItemStack(pattern), shard)); }
public static void replacePatternModel(ResourceLocation locPattern, ResourceLocation modelLocation, ModelBakeEvent event, String baseString, Iterable<Item> items, int color) { try { IModel model = ModelLoaderRegistry.getModel(modelLocation); if(model instanceof IModel) { for(Item item : items) { String suffix = Pattern.getTextureIdentifier(item); // get texture String partPatternLocation = locPattern.toString() + suffix; String partPatternTexture = baseString + suffix; IModel partPatternModel = model.retexture(ImmutableMap.of("layer0", partPatternTexture)); IBakedModel baked = partPatternModel.bake(partPatternModel.getDefaultState(), DefaultVertexFormats.ITEM, textureGetter); if(color > -1) { ImmutableList.Builder<BakedQuad> quads = ImmutableList.builder(); // ItemLayerModel.BakedModel only uses general quads for(BakedQuad quad : baked.getQuads(null, null, 0)) { quads.add(ModelHelper.colorQuad(color, quad)); } baked = new BakedSimple.Wrapper(quads.build(), (baked)); } event.getModelRegistry().putObject(new ModelResourceLocation(partPatternLocation, "inventory"), baked); } } } catch(Exception e) { e.printStackTrace(); } }
protected boolean isValidSubitem(Item toolpart) { if(toolpart instanceof IToolPart) { for(Material material : TinkerRegistry.getAllMaterials()) { if(isValidSubitemMaterial(material) && ((IToolPart) toolpart).canUseMaterial(material)) { return true; } } return false; } return true; }
private void registerStencil(Item pattern, ToolPart toolPart) { for(ToolCore toolCore : TinkerRegistry.getTools()) { for(PartMaterialType partMaterialType : toolCore.getRequiredComponents()) { if(partMaterialType.getPossibleParts().contains(toolPart)) { ItemStack stencil = new ItemStack(pattern); Pattern.setTagForPart(stencil, toolPart); TinkerRegistry.registerStencilTableCrafting(stencil); return; } } } }
try { String identifier = Pattern.getTextureIdentifier(item); String partPatternLocation = baseTextureString + identifier; TextureAtlasSprite partPatternTexture;
return false; Item part = Pattern.getPartFromTag(itemstack); boolean hasContents = false; for(int i = 0; i < getSizeInventory(); i++) { Item slotPart = Pattern.getPartFromTag(getStackInSlot(i));
buttonCount = 0; for(ItemStack stencil : patterns) { Item part = Pattern.getPartFromTag(stencil); if(part == null || !(part instanceof MaterialItem)) { continue;
@Override public void updatePosition(int parentX, int parentY, int parentSizeX, int parentSizeY) { super.updatePosition(parentX, parentY, parentSizeX, parentSizeY); int index = 0; buttonList.clear(); buttonCount = 0; for(ItemStack stencil : TinkerRegistry.getStencilTableCrafting()) { Item part = Pattern.getPartFromTag(stencil); if(part == null || !(part instanceof MaterialItem)) { continue; } ItemStack icon = ((MaterialItem) part).getItemstackWithMaterial(CustomTextureCreator.guiMaterial); GuiButtonItem<ItemStack> button = new GuiButtonItem<>(index++, -1, -1, icon, stencil); shiftButton(button, 0, 18); addSideButton(button); if(index - 1 == selected) { button.pressed = true; } } super.updatePosition(parentX, parentY, parentSizeX, parentSizeY); }
Item itemPart = Pattern.getPartFromTag(pattern); if(itemPart == null || !(itemPart instanceof MaterialItem) || !(itemPart instanceof IToolPart)) { String error = I18n.translateToLocalFormatted("gui.error.invalid_pattern");
amount = Util.df.format(matchAmount / (float) Material.VALUE_Ingot); Item part = Pattern.getPartFromTag(container.getSlot(2).getStack()); if(part instanceof IToolPart && matchAmount < ((IToolPart) part).getCost()) { amount = TextFormatting.DARK_RED + amount + TextFormatting.RESET;