@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { if (baseSpellPageModel instanceof IPerspectiveAwareModel) { Matrix4f matrix4f = ((IPerspectiveAwareModel) baseSpellPageModel).handlePerspective(cameraTransformType) .getRight(); return Pair.of(this, matrix4f); } ItemCameraTransforms itemCameraTransforms = baseSpellPageModel.getItemCameraTransforms(); ItemTransformVec3f itemTransformVec3f = itemCameraTransforms.getTransform(cameraTransformType); TRSRTransformation tr = new TRSRTransformation(itemTransformVec3f); Matrix4f mat = null; if (tr != null) { mat = tr.getMatrix(); } return Pair.of(this, mat); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { if (baseKnowledgeBookModel instanceof IPerspectiveAwareModel) { Matrix4f matrix4f = ((IPerspectiveAwareModel) baseKnowledgeBookModel).handlePerspective(cameraTransformType) .getRight(); return Pair.of(this, matrix4f); } ItemCameraTransforms itemCameraTransforms = baseKnowledgeBookModel.getItemCameraTransforms(); ItemTransformVec3f itemTransformVec3f = itemCameraTransforms.getTransform(cameraTransformType); TRSRTransformation tr = new TRSRTransformation(itemTransformVec3f); Matrix4f mat = null; if (tr != null) { mat = tr.getMatrix(); } return Pair.of(this, mat); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { if (parentModel instanceof IPerspectiveAwareModel) { Matrix4f matrix4f = ((IPerspectiveAwareModel) parentModel).handlePerspective(cameraTransformType) .getRight(); return Pair.of(this, matrix4f); } ItemCameraTransforms itemCameraTransforms = parentModel.getItemCameraTransforms(); ItemTransformVec3f itemTransformVec3f = itemCameraTransforms.getTransform(cameraTransformType); TRSRTransformation tr = new TRSRTransformation(itemTransformVec3f); Matrix4f mat = null; if (tr != null) { mat = tr.getMatrix(); } return Pair.of(this, mat); }
@Override public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) { ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); Optional<TRSRTransformation> transform = state.apply(Optional.<IModelPart>absent()); for(int i = 0; i < textures.size(); i++) { ResourceLocation tex = textures.get(i); if(tex.toString().equals("minecraft:missingno")) continue; TextureAtlasSprite sprite = bakedTextureGetter.apply(tex); String breakLocation = new ResourceLocation(Reference.MOD_ID,"items/breakmask").toString(); TextureAtlasSprite breakTemplate = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(breakLocation); builder.addAll(getQuadsForSprite(i, breakTemplate, sprite, format, transform)); //builder.addAll(ItemTextureQuadConverter.convertTexture(format, transform, breakTemplate, sprite, NORTH_Z + Z_OFFSET * i, EnumFacing.NORTH, 0xffffffff)); // builder.addAll(ItemTextureQuadConverter.convertTexture(format, transform, breakTemplate, sprite, SOUTH_Z - Z_OFFSET * i, EnumFacing.SOUTH, 0xffffffff)); } TextureAtlasSprite particle = bakedTextureGetter.apply(textures.isEmpty() ? new ResourceLocation("missingno") : textures.get(0)); ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> map = IPerspectiveAwareModel.MapWrapper.getTransforms(state); return new BakedItemModel(builder.build(), particle, map, null); }
@SuppressWarnings("deprecation") public static IBakedModel handleCameraTransforms(IBakedModel model, ItemCameraTransforms.TransformType cameraTransformType, boolean leftHandHackery) { if(model instanceof IPerspectiveAwareModel) { Pair<? extends IBakedModel, Matrix4f> pair = ((IPerspectiveAwareModel)model).handlePerspective(cameraTransformType); if(pair.getRight() != null) { Matrix4f matrix = new Matrix4f(pair.getRight()); if(leftHandHackery) { matrix.mul(flipX, matrix); matrix.mul(matrix, flipX); } multiplyCurrentGlMatrix(matrix); } return pair.getLeft(); } else { //if(leftHandHackery) GlStateManager.scale(-1, 1, 1); ItemCameraTransforms.applyTransformSide(model.getItemCameraTransforms().getTransform(cameraTransformType), leftHandHackery); //if(leftHandHackery) GlStateManager.scale(-1, 1, 1); } return model; }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType type) { Pair<? extends IBakedModel, Matrix4f> pair = IPerspectiveAwareModel.MapWrapper.handlePerspective(this, transforms, type); if(type == TransformType.GUI && !isCulled && pair.getRight() == null) { return Pair.of(otherModel, null); } else if(type != TransformType.GUI && isCulled) { return Pair.of(otherModel, pair.getRight()); } return pair; }
/** * Creates the basic TRSRTransformations for a perspective aware model. * * @param model The model to get the transforms for. * @return An immutable map of all the transforms. */ public static ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> getBasicTransforms (IPerspectiveAwareModel model) { final ImmutableMap.Builder<ItemCameraTransforms.TransformType, TRSRTransformation> builder = ImmutableMap.builder(); for (final ItemCameraTransforms.TransformType type : ItemCameraTransforms.TransformType.values()) { final TRSRTransformation transformation = new TRSRTransformation(model.handlePerspective(type).getRight()); if (!transformation.equals(TRSRTransformation.identity())) builder.put(type, TRSRTransformation.blockCenterToCorner(transformation)); } return builder.build(); }
public static ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> getTransforms(IPerspectiveAwareModel model) { ImmutableMap.Builder<ItemCameraTransforms.TransformType, TRSRTransformation> builder = ImmutableMap.builder(); for(ItemCameraTransforms.TransformType type : ItemCameraTransforms.TransformType.values()) { TRSRTransformation transformation = new TRSRTransformation(model.handlePerspective(type).getRight()); if(!transformation.equals(TRSRTransformation.identity())) { builder.put(type, TRSRTransformation.blockCenterToCorner(transformation)); } } return builder.build(); }
public static void replaceAnvilModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) { try { IModel model = ModelLoaderRegistry.getModel(modelLocation); IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation); if(standard instanceof IPerspectiveAwareModel) { IBakedModel finalModel = new BakedAnvilModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK); event.getModelRegistry().putObject(modelVariantLocation, finalModel); } } catch(Exception e) { e.printStackTrace(); } }
public static void replacePitKilnModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) { try { IModel model = ModelLoaderRegistry.getModel(modelLocation); IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation); if(standard instanceof IPerspectiveAwareModel) { IBakedModel finalModel = new BakedPitKilnModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK); event.getModelRegistry().putObject(modelVariantLocation, finalModel); } } catch(Exception e) { e.printStackTrace(); } }
public static void replaceSmallVesselModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) { try { IModel model = ModelLoaderRegistry.getModel(modelLocation); IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation); if(standard instanceof IPerspectiveAwareModel) { IBakedModel finalModel = new BakedSmallVesselModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK); event.getModelRegistry().putObject(modelVariantLocation, finalModel); } } catch(Exception e) { e.printStackTrace(); } }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { if (parent instanceof IPerspectiveAwareModel) { Pair<? extends IBakedModel, Matrix4f> perspective = ((IPerspectiveAwareModel) parent).handlePerspective(cameraTransformType); return Pair.of(this, perspective.getRight()); } return Pair.of(this, null); }
@Override public @Nonnull IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity) { if (originalModel != RotatingSmartItemModel.this) { return originalModel; } IBakedModel newBase = parent.getOverrides().handleItemState(parent, stack, world, entity); if (parent != newBase && newBase instanceof IPerspectiveAwareModel) { return new RotatingSmartItemModel((IPerspectiveAwareModel) newBase, speed); } return RotatingSmartItemModel.this; }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { if (getDefaults() instanceof IPerspectiveAwareModel) { Pair<? extends IBakedModel, Matrix4f> perspective = ((IPerspectiveAwareModel) getDefaults()).handlePerspective(cameraTransformType); return Pair.of(this, perspective.getRight()); } return Pair.of(this, null); }
public static void registerRotating(@Nonnull String resource, final int speed) { register(resource, new Registry() { @Override public @Nonnull IBakedModel wrap(@Nonnull IBakedModel model) { return new RotatingSmartItemModel((IPerspectiveAwareModel) model, speed); } }); }
public static void registerFacade(@Nonnull ModelResourceLocation resource) { register(resource, new Registry() { @Override public @Nonnull IBakedModel wrap(@Nonnull IBakedModel model) { return new FacadeSmartItemModel((IPerspectiveAwareModel) model); } }); }
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, state, cameraTransformType); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, transforms, cameraTransformType); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, DynamicBaseModel.DEFAULT_PERSPECTIVE_TRANSFORMS, cameraTransformType); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, getBlockTransforms(), cameraTransformType); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, transforms, cameraTransformType); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(ItemCameraTransforms.TransformType cameraTransformType) { return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, DEFAULT_PERSPECTIVE_TRANSFORMS, cameraTransformType); }
public BakedSmallVesselModel(IPerspectiveAwareModel standard,VertexFormat format) { this.standard = standard; this.format = format; this.transforms = getTransforms(standard); }
public BakedPitKilnModel(IPerspectiveAwareModel standard,VertexFormat format) { this.standard = standard; this.format = format; this.transforms = getTransforms(standard); }
public BakedAnvilModel(IPerspectiveAwareModel standard,VertexFormat format) { this.standard = standard; this.format = format; this.transforms = getTransforms(standard); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, this.state, cameraTransformType); }
@Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { // Use forge default block transform return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, defaultBlockTransform, cameraTransformType); }