net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType Java Examples

The following examples show how to use net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultiLayerModel.java    From OpenModsLib with MIT License 6 votes vote down vote up
public MultiLayerBakedModel(Map<BlockRenderLayer, IBakedModel> models, IBakedModel base, IBakedModel missing, ImmutableMap<TransformType, TRSRTransformation> cameraTransforms) {
	super(base, cameraTransforms);
	this.models = ImmutableMap.copyOf(models);
	this.missing = missing;

	final List<BakedQuad> quads = Lists.newArrayList();

	for (BlockRenderLayer layer : BlockRenderLayer.values()) {
		final IBakedModel model = models.get(layer);
		if (model != null) {
			buildQuadsForLayer(quads, model);
		}
	}

	this.quads = ImmutableList.copyOf(quads);
}
 
Example #2
Source File: FluidPipeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderItem(ItemStack rawItemStack, TransformType transformType) {
    ItemStack stack = ModCompatibility.getRealItemStack(rawItemStack);
    if (!(stack.getItem() instanceof ItemBlockFluidPipe)) {
        return;
    }
    CCRenderState renderState = CCRenderState.instance();
    GlStateManager.enableBlend();
    renderState.reset();
    renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    BlockFluidPipe blockFluidPipe = (BlockFluidPipe) ((ItemBlockFluidPipe) stack.getItem()).getBlock();
    FluidPipeType pipeType = blockFluidPipe.getItemPipeType(stack);
    Material material = blockFluidPipe.getItemMaterial(stack);
    if (pipeType != null && material != null) {
        renderPipeBlock(material, pipeType, IPipeTile.DEFAULT_INSULATION_COLOR, renderState, new IVertexOperation[0], 0);
    }
    renderState.draw();
    GlStateManager.disableBlend();
}
 
Example #3
Source File: ModelPortableBarrel.java    From BetterChests with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void render(ItemStack stack, float patrtialTicks) {
	GlStateManager.pushMatrix();
	RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
	renderItem.renderItem(stack, parent);
	InventoryBPortableBarrel barrel = BlocksItemsBetterChests.betterportablebarrel.getInventoryFor(stack, null);
	if (barrel != null && barrel.getChestPart().isItemSet()) {
		InventoryPartBarrel part = barrel.getChestPart();
		GlStateManager.pushMatrix();
		GlStateManager.translate(0, 0, -0.05);
		GlStateManager.scale(0.8, 0.8, 0.8);

		renderItem.renderItem(part.getDummy(), TransformType.FIXED);

		GlStateManager.enableBlend();
		GlStateManager.popMatrix();
	}
	GlStateManager.popMatrix();
}
 
Example #4
Source File: CableRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderItem(ItemStack rawItemStack, TransformType transformType) {
    ItemStack stack = ModCompatibility.getRealItemStack(rawItemStack);
    if (!(stack.getItem() instanceof ItemBlockCable)) {
        return;
    }
    GlStateManager.enableBlend();
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    BlockCable blockCable = (BlockCable) ((ItemBlockCable) stack.getItem()).getBlock();
    Insulation insulation = blockCable.getItemPipeType(stack);
    Material material = blockCable.getItemMaterial(stack);
    if (insulation != null && material != null) {
        renderCableBlock(material, insulation, IPipeTile.DEFAULT_INSULATION_COLOR, renderState, new IVertexOperation[0],
            1 << EnumFacing.SOUTH.getIndex() | 1 << EnumFacing.NORTH.getIndex() |
                1 << (6 + EnumFacing.SOUTH.getIndex()) | 1 << (6 + EnumFacing.NORTH.getIndex()));
    }
    renderState.draw();
    GlStateManager.disableBlend();
}
 
Example #5
Source File: FacadeItemModel.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderItem(ItemStack rawStack, TransformType transformType) {
    ItemStack itemStack = ModCompatibility.getRealItemStack(rawStack);
    if (!(itemStack.getItem() instanceof MetaItem<?>)) {
        return;
    }
    ItemStack facadeStack = FacadeItem.getFacadeStack(itemStack);
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    try {
        FacadeRenderer.renderItemCover(renderState, EnumFacing.NORTH.getIndex(), facadeStack, ICoverable.getCoverPlateBox(EnumFacing.NORTH, 2.0 / 16.0));
    } catch (Throwable ignored) {
    }
    renderState.draw();
}
 
Example #6
Source File: MetaTileEntityRenderer.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void renderItem(ItemStack rawStack, TransformType transformType) {
    ItemStack stack = ModCompatibility.getRealItemStack(rawStack);
    if (!(stack.getItem() instanceof MachineItemBlock)) {
        return;
    }
    MetaTileEntity metaTileEntity = MachineItemBlock.getMetaTileEntity(stack);
    if (metaTileEntity == null) {
        return;
    }
    GlStateManager.enableBlend();
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    metaTileEntity.setRenderContextStack(stack);
    metaTileEntity.renderMetaTileEntity(renderState, new Matrix4(), new IVertexOperation[0]);
    if(metaTileEntity instanceof IFastRenderMetaTileEntity) {
        ((IFastRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityFast(renderState, new Matrix4(), 0.0f);
    }
    metaTileEntity.setRenderContextStack(null);
    renderState.draw();
    if(metaTileEntity instanceof IRenderMetaTileEntity) {
        ((IRenderMetaTileEntity) metaTileEntity).renderMetaTileEntityDynamic(0.0, 0.0, 0.0, 0.0f);
    }
    GlStateManager.disableBlend();
}
 
Example #7
Source File: PerspectiveAwareModel.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public IBakedModel bake(final IModelState state, final VertexFormat format, final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
	final Map<TransformType, IBakedModel> bakedModels = Maps.transformValues(models, location -> bakeModel(location, state, format, bakedTextureGetter));

	IModel missing = ModelLoaderRegistry.getMissingModel();
	IBakedModel bakedMissing = missing.bake(missing.getDefaultState(), format, bakedTextureGetter);

	final IBakedModel bakedBase;
	if (base.isPresent()) {
		bakedBase = bakeModel(base.get(), state, format, bakedTextureGetter);
	} else {
		bakedBase = bakedMissing;
	}

	return new PerspectiveAwareBakedModel(
			bakedModels,
			bakedBase,
			PerspectiveMapWrapper.getTransforms(state));
}
 
Example #8
Source File: PerspectiveAwareModel.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	IBakedModel model = models.get(cameraTransformType);
	if (model == null) model = base;

	return model.handlePerspective(cameraTransformType);
}
 
Example #9
Source File: ModelEnderTools.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public BakedEnderTool(ModelEnderTools parent, ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, VertexFormat format,
        ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms, Map<String, IBakedModel> cache)
{
    this.quads = quads;
    this.particle = particle;
    this.format = format;
    this.parent = parent;
    this.transforms = transforms;
    this.cache = cache;
}
 
Example #10
Source File: ModelEnderBucket.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public BakedEnderBucket(ModelEnderBucket parent, ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, VertexFormat format,
        ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms, Map<String, IBakedModel> cache)
{
    this.quads = quads;
    this.particle = particle;
    this.format = format;
    this.parent = parent;
    this.transforms = transforms;
    this.cache = cache;
}
 
Example #11
Source File: PerspectiveAwareModel.java    From OpenModsLib with MIT License 5 votes vote down vote up
@Override
public PerspectiveAwareModel process(ImmutableMap<String, String> customData) {
	final ModelUpdater updater = new ModelUpdater(customData);

	final Optional<ResourceLocation> base = updater.get("base", ModelUpdater.MODEL_LOCATION, this.base);

	final Map<TransformType, ResourceLocation> models = Maps.newHashMap();
	for (TransformType layer : TransformType.values()) {
		final ResourceLocation result = updater.get(layer.toString(), ModelUpdater.MODEL_LOCATION, this.models.get(layer));
		if (result != null) models.put(layer, result);
	}

	return updater.hasChanged()? new PerspectiveAwareModel(base, models) : this;

}
 
Example #12
Source File: InvPipeRenderer.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderItem(ItemStack rawItemStack, TransformType transformType) {
    GlStateManager.enableBlend();
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
    renderPipe(renderState, new IVertexOperation[0], IPipeTile.DEFAULT_INSULATION_COLOR, 12);
    renderState.draw();
    GlStateManager.disableBlend();
}
 
Example #13
Source File: TexturedItemModel.java    From OpenModsLib with MIT License 4 votes vote down vote up
public BakedModel(IBakedModel base, ImmutableMap<TransformType, TRSRTransformation> cameraTransforms, ItemOverrideList itemOverrideList) {
	super(base, cameraTransforms);
	this.overrideList = itemOverrideList;
}
 
Example #14
Source File: PerspectiveAwareModel.java    From OpenModsLib with MIT License 4 votes vote down vote up
public PerspectiveAwareModel(Optional<ResourceLocation> base, Map<TransformType, ResourceLocation> models) {
	this.base = base;
	this.models = ImmutableMap.copyOf(models);
}
 
Example #15
Source File: ItemStateOverrideList.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	return original.handlePerspective(cameraTransformType);
}
 
Example #16
Source File: BakedModelAdapter.java    From OpenModsLib with MIT License 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	return PerspectiveMapWrapper.handlePerspective(this, cameraTransforms, cameraTransformType);
}
 
Example #17
Source File: PerspectiveAwareModel.java    From OpenModsLib with MIT License 4 votes vote down vote up
public PerspectiveAwareBakedModel(Map<TransformType, IBakedModel> models, IBakedModel base, ImmutableMap<TransformType, TRSRTransformation> cameraTransforms) {
	super(base, cameraTransforms);
	this.models = ImmutableMap.copyOf(models);
}
 
Example #18
Source File: BakedModelAdapter.java    From OpenModsLib with MIT License 4 votes vote down vote up
public BakedModelAdapter(IBakedModel base, ImmutableMap<TransformType, TRSRTransformation> cameraTransforms) {
	this.base = base;
	this.cameraTransforms = cameraTransforms;
}
 
Example #19
Source File: ModelNullifierBaked.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
{
    return PerspectiveMapWrapper.handlePerspective(this, this.transformMap, cameraTransformType);
}
 
Example #20
Source File: VariantModel.java    From OpenModsLib with MIT License 4 votes vote down vote up
public BakedModel(IBakedModel base, VariantModelData modelData, Map<ResourceLocation, IBakedModel> bakedSubModels, ImmutableMap<TransformType, TRSRTransformation> cameraTransforms) {
	super(base, cameraTransforms);
	this.modelData = modelData;
	this.bakedSubModels = bakedSubModels;
}
 
Example #21
Source File: ModelPortableBarrel.java    From BetterChests with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
		Pair<? extends IBakedModel, Matrix4f> p = parent.handlePerspective(cameraTransformType);
	return ImmutablePair.of(this, p.getRight());

}
 
Example #22
Source File: TESRBBarrel.java    From BetterChests with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void render(TileEntityBBarrel te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {

	if (te.getChestPart().isItemSet()) {
		GlStateManager.pushMatrix();
		GlStateManager.translate((float) x, (float) y, (float) z);
		GlStateManager.translate(0.5F, 0.5F, 0.5F);

		ItemStack stack = te.getChestPart().getDummy();

		EnumFacing side = EnumFacing.HORIZONTALS[te.getBlockMetadata()];

		float angle = side.getHorizontalAngle();
		switch (side) {
		case SOUTH:
			//south
			angle = 180;
			break;
		case WEST:
			//west
			angle = 90;
			break;
		case NORTH:
			//north
			angle = 0;
			break;
		case EAST:
			//east
			angle = -90;
			break;
		}
		GlStateManager.rotate(angle, 0, 1, 0);

		{
			GlStateManager.pushMatrix();

			GlStateManager.translate(0, 0.1, -0.5);
			GlStateManager.scale(0.8, 0.8, 0.8);

			int skyBrightness = te.getWorld().getCombinedLight(te.getPosition().offset(side), 0);
			int skyBrightness1 = skyBrightness % 65536;
			int skyBrightness2 = skyBrightness / 65536;
			OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, skyBrightness1,
					skyBrightness2);

			Minecraft.getMinecraft().getRenderItem().renderItem(stack, TransformType.FIXED);

			GlStateManager.popMatrix();
		}

		{
			GlStateManager.pushMatrix();

			GlStateManager.translate(0, -0.25, -0.51);
			GlStateManager.scale(0.015, 0.015, 0.015);
			GlStateManager.rotate(180, 0, 0, 1);

			String text = te.getChestPart().getAmountDescr();
			int textlen = Minecraft.getMinecraft().fontRenderer.getStringWidth(text);
			Minecraft.getMinecraft().fontRenderer.drawString(text, -textlen / 2, 0, 0xFFFFFFFF);

			GlStateManager.popMatrix();
		}

		GlStateManager.popMatrix();
	}

}
 
Example #23
Source File: ModelEnderTools.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
{
    return PerspectiveMapWrapper.handlePerspective(this, this.transforms, cameraTransformType);
}
 
Example #24
Source File: ModelEnderBucket.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType)
{
    return PerspectiveMapWrapper.handlePerspective(this, this.transforms, cameraTransformType);
}
 
Example #25
Source File: TileCraftingPlateRenderer.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void render(float partialTicks, int destroyStage, float alpha) {
	ArrayList<BlockPos> errors = new ArrayList<>(((IStructure) tile.getBlockType()).testStructure(tile.getWorld(), tile.getPos()));
	errors.sort(Vec3i::compareTo);

	ItemStack input = tile.getInput();
	if (input.isEmpty()) {
		input = tile.getOutput();
		if (input.isEmpty()) {
			input = ItemStack.EMPTY;
		}
	}

	ICraftingPlateRecipe recipeForItem = CraftingPlateRecipeManager.getRecipe(tile.getWorld(), tile.getPos(), input);
	if (recipeForItem != null) recipeForItem.renderInput(tile.getWorld(), tile.getPos(), input, partialTicks);

	if (!errors.isEmpty() && tile.revealStructure && tile.getBlockType() instanceof IStructure) {
		ModStructures.structureManager.draw(ModStructures.CRAFTING_PLATE, (float) (Math.sin(ClientTickHandler.getTicks() / 10.0) + 1) / 10.0f + 0.3f);
	}

	if (!errors.isEmpty()) {
		for (BlockPos error : errors) {
			StructureErrorRenderer.addError(error);
		}
		return;
	} else if (tile.getWorld().isAirBlock(tile.getPos().offset(EnumFacing.UP)) && !CraftingPlateRecipeManager.doesRecipeExist(tile.getWorld(), tile.getPos(), input) && RandUtil.nextInt(4) == 0) {
		LibParticles.CRAFTING_ALTAR_IDLE(tile.getWorld(), new Vec3d(tile.getPos()).add(0.5, 0.7, 0.5));
	}

	// render each item at its current position
	final int mapSize = hoveringStacks.size();
	for (HoveringStack hoveringStack : hoveringStacks.values()) {

		if (!hoveringStack.stack.isEmpty()) {

			{
				GlStateManager.pushMatrix();
				GlStateManager.translate(0.5 + hoveringStack.location.x, 1 + hoveringStack.location.y, 0.5 + hoveringStack.location.z);
				GlStateManager.scale(0.3, 0.3, 0.3);
				GlStateManager.rotate((hoveringStack.randX + ClientTickHandler.getTicks()), 0, 1, 0);
				GlStateManager.rotate((hoveringStack.randY + ClientTickHandler.getTicks()), 1, 0, 0);
				GlStateManager.rotate((hoveringStack.randZ + ClientTickHandler.getTicks()), 0, 0, 1);

				GlStateManager.enableLighting();
				RenderHelper.disableStandardItemLighting();
				Minecraft.getMinecraft().getRenderItem().renderItem(hoveringStack.stack, TransformType.NONE);
				RenderHelper.enableStandardItemLighting();
				GlStateManager.popMatrix();
			}

			if (tile.suckingCooldown <= 0) {
				if (RandUtil.nextInt(mapSize / 2) == 0) {
					LibParticles.CLUSTER_DRAPE(
							tile.getWorld(),
							hoveringStack.location.add(new Vec3d(tile.getPos())).add(0.5, 0.5, 0.5));
				}
			} else {
				if (RandUtil.nextInt(mapSize) == 0) {
					LibParticles.CRAFTING_ALTAR_CLUSTER_SUCTION(
							tile.getWorld(),
							new Vec3d(tile.getPos()).add(0.5, 0.75, 0.5),
							new InterpBezier3D(hoveringStack.location, new Vec3d(0, 0, 0)));
				}
			}
		}
	}
}
 
Example #26
Source File: GTModelBlock.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	return Pair.of(this, PerspectiveMapWrapper.handlePerspective(this, this.getCamera(), cameraTransformType).getRight());
}
 
Example #27
Source File: GTModelOre.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	return Pair.of(this, PerspectiveMapWrapper.handlePerspective(this, this.getCamera(), cameraTransformType).getRight());
}
 
Example #28
Source File: GTModelWire.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	return PerspectiveMapWrapper.handlePerspective(this, this.getCamera(), cameraTransformType);
}
 
Example #29
Source File: GTModelMortar.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
	return PerspectiveMapWrapper.handlePerspective(this, this.getCamera(), cameraTransformType);
}
 
Example #30
Source File: BakedModelHandler.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
    CCRenderItem.notifyTransform(cameraTransformType);
    return PerspectiveMapWrapper.handlePerspective(this, TransformUtils.DEFAULT_BLOCK, cameraTransformType);
}