use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class CallRunnerClient method onDrawBlockDamageTexture.
public static void onDrawBlockDamageTexture(RenderGlobal renderGlobal, Tessellator tessellatorIn, VertexBuffer worldRendererIn, Entity entityIn, float partialTicks) {
double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double) partialTicks;
double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double) partialTicks;
double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double) partialTicks;
if (!renderGlobal.damagedBlocks.isEmpty()) {
renderGlobal.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
renderGlobal.preRenderDamagedBlocks();
worldRendererIn.begin(7, DefaultVertexFormats.BLOCK);
worldRendererIn.setTranslation(-d0, -d1, -d2);
worldRendererIn.noColor();
Iterator<DestroyBlockProgress> iterator = renderGlobal.damagedBlocks.values().iterator();
while (iterator.hasNext()) {
DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress) iterator.next();
BlockPos blockpos = destroyblockprogress.getPosition();
double d3 = (double) blockpos.getX() - d0;
double d4 = (double) blockpos.getY() - d1;
double d5 = (double) blockpos.getZ() - d2;
Block block = renderGlobal.theWorld.getBlockState(blockpos).getBlock();
TileEntity te = renderGlobal.theWorld.getTileEntity(blockpos);
boolean hasBreak = block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockSign || block instanceof BlockSkull;
if (!hasBreak)
hasBreak = te != null && te.canRenderBreaking();
if (!hasBreak) {
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(renderGlobal.theWorld, blockpos);
if (wrapper == null && (d3 * d3 + d4 * d4 + d5 * d5 > 1024.0D)) {
iterator.remove();
} else {
IBlockState iblockstate = renderGlobal.theWorld.getBlockState(blockpos);
if (wrapper != null) {
wrapper.wrapping.renderer.setupTranslation(partialTicks);
worldRendererIn.setTranslation(-wrapper.wrapping.renderer.offsetPos.getX(), -wrapper.wrapping.renderer.offsetPos.getY(), -wrapper.wrapping.renderer.offsetPos.getZ());
}
if (iblockstate.getMaterial() != Material.AIR) {
int i = destroyblockprogress.getPartialBlockDamage();
TextureAtlasSprite textureatlassprite = renderGlobal.destroyBlockIcons[i];
BlockRendererDispatcher blockrendererdispatcher = renderGlobal.mc.getBlockRendererDispatcher();
try {
blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite, renderGlobal.theWorld);
} catch (Exception e) {
e.printStackTrace();
}
}
worldRendererIn.setTranslation(-d0, -d1, -d2);
// TODO: Reverse the Matrix Transforms here
if (wrapper != null) {
tessellatorIn.draw();
worldRendererIn.begin(7, DefaultVertexFormats.BLOCK);
wrapper.wrapping.renderer.inverseTransform(partialTicks);
}
}
}
}
tessellatorIn.draw();
worldRendererIn.setTranslation(0.0D, 0.0D, 0.0D);
renderGlobal.postRenderDamagedBlocks();
}
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project AgriCraft by AgriCraft.
the class RenderBlockGrate method renderWorldBlockWoodDynamic.
@Override
protected void renderWorldBlockWoodDynamic(ITessellator tess, World world, BlockPos pos, BlockGrate block, TileEntityGrate grate, TextureAtlasSprite sprite) {
// vines
final TextureAtlasSprite vinesIcon = BaseIcons.VINE.getIcon();
int l = this.getMixedBrightness(grate.getWorld(), grate.getPos(), Blocks.VINE.getDefaultState());
float f0 = (float) (l >> 16 & 255) / 255.0F;
float f1 = (float) (l >> 8 & 255) / 255.0F;
float f2 = (float) (l & 255) / 255.0F;
tess.setColorRGB(f0, f1, f2);
if (grate.hasVines(true)) {
tess.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.NORTH, vinesIcon, 0.001f);
}
if (grate.hasVines(false)) {
tess.drawScaledFaceDouble(0, 0, 16, 16, EnumFacing.NORTH, vinesIcon, 1.999f);
}
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project AgriCraft by AgriCraft.
the class RenderTank method renderWorldBlockWoodDynamic.
@Override
protected void renderWorldBlockWoodDynamic(ITessellator tessellator, World world, BlockPos pos, BlockWaterTank block, TileEntityTank tank, TextureAtlasSprite sprite) {
// only render water in one on top.
final int level = tank.getFluidHeight();
if (level > 0) {
// -0.0001F to avoid Z-fighting on maximum filled tanks
final float y = (level * 16 / 1_000f) - A;
// Calculate water brightness.
final int l = RenderUtilBase.getMixedBrightness(tank.getWorld(), tank.getPos(), Blocks.WATER);
tessellator.setBrightness(l);
tessellator.setAlpha(0.39f);
// draw surface
final TextureAtlasSprite waterIcon = BaseIcons.WATER_STILL.getIcon();
tessellator.drawScaledFace(0, 0, 16, 16, EnumFacing.UP, waterIcon, y);
}
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project AgriCraft by AgriCraft.
the class IconHelper method findMatches.
/**
* Pure hack to find icons...
*
* @param name
* @return
*/
public static Deque<String> findMatches(String name) {
name = name.toLowerCase();
if (findCache.containsKey(name)) {
return findCache.get(name);
}
Deque<String> matches = new ArrayDeque<>();
try {
Field f = TextureMap.class.getDeclaredField("mapRegisteredSprites");
f.setAccessible(true);
Map<String, TextureAtlasSprite> textureMap = (Map<String, TextureAtlasSprite>) f.get(Minecraft.getMinecraft().getTextureMapBlocks());
for (String e : textureMap.keySet()) {
if (e.contains(name)) {
matches.add(e);
}
}
if (!findCache.isEmpty()) {
findCache.put(name, matches);
} else {
matches.add("missingno");
}
} catch (NoSuchFieldException | IllegalAccessException e) {
// Shoot
AgriCore.getLogger("agricraft").debug("Something strange is going on with the Minecraft TextureMap!");
} catch (SecurityException e) {
AgriCore.getLogger("agricraft").debug("Locked out of TextureMap...");
}
return matches;
}
use of net.minecraft.client.renderer.texture.TextureAtlasSprite in project BetterWithAddons by DaedalusGame.
the class ModelToolShardInner method bake.
@Override
public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
Optional<TRSRTransformation> transform = state.apply(Optional.empty());
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 = PerspectiveMapWrapper.getTransforms(state);
return new BakedItemModel(builder.build(), particle, map, null);
}
Aggregations