/**
* {@link Block#addHitEffects}
* Provided the model bound is an instance of IModelParticleProvider, you will have landing particles just handled for you.
* Use the default PerspectiveModel implementations inside CCL, Destroy effects will just be handled for you.
*
* @param world The world.
* @param pos The position of the block.
* @param manager The ParticleManager.
* @return True if particles were added, basically just return the result of this method inside {@link Block#addHitEffects}
*/
@SideOnly (Side.CLIENT)
public static boolean handleDestroyEffects(World world, BlockPos pos, ParticleManager manager) {
IBlockState state = world.getBlockState(pos);
BlockModelShapes modelProvider = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
try {
state = state.getActualState(world, pos);
} catch (Throwable ignored) {
}
IBakedModel model = modelProvider.getModelForState(state);
state = state.getBlock().getExtendedState(state, world, pos);
if (model instanceof IModelParticleProvider) {
Cuboid6 bounds = new Cuboid6(state.getBoundingBox(world, pos));
Set<TextureAtlasSprite> destroySprites = ((IModelParticleProvider) model).getDestroyEffects(state, world, pos);
List<TextureAtlasSprite> sprites = destroySprites.stream().filter(sprite -> !ignoredParticleSprites.contains(sprite)).collect(Collectors.toList());
addBlockDestroyEffects(world, bounds.add(pos), sprites, manager);
return true;
}
return false;
}
java类net.minecraft.client.renderer.BlockModelShapes的实例源码
CustomParticleHandler.java 文件源码
项目:CodeChickenLib
阅读 22
收藏 0
点赞 0
评论 0
EnchanterModelRenderer.java 文件源码
项目:EnderIO
阅读 23
收藏 0
点赞 0
评论 0
private void renderBase() {
BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockModelShapes modelShapes = blockrendererdispatcher.getBlockModelShapes();
IBakedModel bakedModel = modelShapes
.getModelForState(MachineObject.block_enchanter.getBlockNN().getDefaultState().withProperty(EnumRenderMode.RENDER, EnumRenderMode.FRONT));
RenderUtil.bindBlockTexture();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableRescaleNormal();
GlStateManager.pushMatrix();
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexbuffer = tessellator.getBuffer();
vertexbuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
for (EnumFacing enumfacing : EnumFacing.values()) {
this.renderQuads(vertexbuffer, bakedModel.getQuads((IBlockState) null, enumfacing, 0L));
}
this.renderQuads(vertexbuffer, bakedModel.getQuads((IBlockState) null, (EnumFacing) null, 0L));
tessellator.draw();
GlStateManager.popMatrix();
GlStateManager.disableRescaleNormal();
}
SoulBinderTESR.java 文件源码
项目:EnderIO
阅读 26
收藏 0
点赞 0
评论 0
@SuppressWarnings("null")
public static void renderBlockModel(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, boolean translateToOrigin, boolean relight) {
VertexBuffer wr = Tessellator.getInstance().getBuffer();
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
if (translateToOrigin) {
wr.setTranslation(-pos.getX(), -pos.getY(), -pos.getZ());
}
BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockModelShapes modelShapes = blockrendererdispatcher.getBlockModelShapes();
IBakedModel ibakedmodel = modelShapes.getModelForState(state);
final IBlockAccess worldWrapper = relight ? new WorldWrapper(world, pos) : world;
for (BlockRenderLayer layer : BlockRenderLayer.values()) {
if (state.getBlock().canRenderInLayer(state, layer)) {
ForgeHooksClient.setRenderLayer(layer);
blockrendererdispatcher.getBlockModelRenderer().renderModel(worldWrapper, ibakedmodel, state, pos, wr, false);
}
}
ForgeHooksClient.setRenderLayer(null);
if (translateToOrigin) {
wr.setTranslation(0, 0, 0);
}
Tessellator.getInstance().draw();
}
QuadCollector.java 文件源码
项目:EnderIO
阅读 19
收藏 0
点赞 0
评论 0
/**
* Adds the baked model(s) of the given block states to the quad lists for the given block layer. The models are expected to behave. The block layer will be
* NOT set when the models are asked for their quads.
*/
public void addFriendlyBlockStates(BlockRenderLayer pass, List<IBlockState> states) {
if (states == null || states.isEmpty()) {
return;
}
BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
for (IBlockState state : states) {
if (state != null) {
IBakedModel model = modelShapes.getModelForState(state);
List<BakedQuad> generalQuads = model.getQuads(state, null, 0);
if (!generalQuads.isEmpty()) {
addQuads(null, pass, generalQuads);
}
for (EnumFacing face : EnumFacing.values()) {
List<BakedQuad> faceQuads = model.getQuads(state, face, 0);
if (!faceQuads.isEmpty()) {
addQuads(face, pass, faceQuads);
}
}
}
}
}
ItemQuadCollector.java 文件源码
项目:EnderIO
阅读 17
收藏 0
点赞 0
评论 0
public void addBlockStates(List<Pair<IBlockState, ItemStack>> states, @Nonnull ItemStack parent, Block parentBlock) {
if (states == null || states.isEmpty()) {
return;
}
BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
for (Pair<IBlockState, ItemStack> pair : states) {
IBlockState state = pair.getLeft();
if (state != null) {
ItemStack stack = pair.getRight();
if (stack == null || Prep.isInvalid(stack)) {
if (state.getBlock() == parentBlock) {
stack = parent;
} else {
stack = new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state));
}
}
IBakedModel model = modelShapes.getModelForState(state);
addBakedModel(model, NullHelper.notnullJ(stack, "If you see this, the world will be ending yesterday half past yellow!"));
}
}
}
CamoModel.java 文件源码
项目:pnc-repressurized
阅读 26
收藏 0
点赞 0
评论 0
private IBakedModel handleBlockState(IBlockState state) {
if (state instanceof IExtendedBlockState) {
IExtendedBlockState ext = (IExtendedBlockState) state;
IBlockState camoState = ext.getValue(BlockPneumaticCraftCamo.CAMO_STATE);
if (camoState != null && !(camoState.getBlock() instanceof BlockPneumaticCraftCamo)) {
BlockModelShapes blockModelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
return blockModelShapes.getModelForState(camoState);
}
}
return originalModel;
}
ModelLoader.java 文件源码
项目:CustomWorldGen
阅读 71
收藏 0
点赞 0
评论 0
public ModelLoader(IResourceManager manager, TextureMap map, BlockModelShapes shapes)
{
super(manager, map, shapes);
VanillaLoader.INSTANCE.setLoader(this);
VariantLoader.INSTANCE.setLoader(this);
ModelLoaderRegistry.clearModelCache(manager);
}
ModelLoader.java 文件源码
项目:CustomWorldGen
阅读 27
收藏 0
点赞 0
评论 0
/**
* Internal, do not use.
*/
public static void onRegisterAllBlocks(BlockModelShapes shapes)
{
for (Entry<RegistryDelegate<Block>, IStateMapper> e : customStateMappers.entrySet())
{
shapes.registerBlockWithStateMapper(e.getKey().get(), e.getValue());
}
}
CustomParticleHandler.java 文件源码
项目:CodeChickenLib
阅读 22
收藏 0
点赞 0
评论 0
@SideOnly (Side.CLIENT)
public static void addLandingEffects(World world, BlockPos pos, IBlockState state, Vector3 entityPos, int numParticles) {
//Speshal raytrace, from feet to, down.
Vector3 start = entityPos.copy();
Vector3 end = start.copy().add(Vector3.down.copy().multiply(4));
RayTraceResult traceResult = world.rayTraceBlocks(start.vec3(), end.vec3(), true, false, true);
if (traceResult != null && traceResult.typeOfHit == Type.BLOCK) {
ParticleManager manager = Minecraft.getMinecraft().effectRenderer;
Random randy = new Random();
BlockModelShapes modelProvider = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
try {
state = state.getActualState(world, pos);
} catch (Throwable ignored) {
}
IBakedModel model = modelProvider.getModelForState(state);
state = state.getBlock().getExtendedState(state, world, pos);
if (model instanceof IModelParticleProvider) {
Set<TextureAtlasSprite> hitSprites = ((IModelParticleProvider) model).getHitEffects(traceResult, state, world, pos);
List<TextureAtlasSprite> sprites = hitSprites.stream().filter(sprite -> !ignoredParticleSprites.contains(sprite)).collect(Collectors.toList());
double speed = 0.15000000596046448D;
if (numParticles != 0) {
for (int i = 0; i < numParticles; i++) {
double mX = randy.nextGaussian() * speed;
double mY = randy.nextGaussian() * speed;
double mZ = randy.nextGaussian() * speed;
manager.addEffect(DigIconParticle.newLandingParticle(world, entityPos.x, entityPos.y, entityPos.z, mX, mY, mZ, sprites.get(randy.nextInt(sprites.size()))));
}
}
}
}
}
TomsModUtils.java 文件源码
项目:Toms-Mod
阅读 19
收藏 0
点赞 0
评论 0
@SideOnly(Side.CLIENT)
public static IBakedModel getBakedModelFromBlockState(IBlockState state, IBakedModel defaultModel) {
if (state != null) {
Minecraft mc = Minecraft.getMinecraft();
BlockRendererDispatcher blockRendererDispatcher = mc.getBlockRendererDispatcher();
BlockModelShapes blockModelShapes = blockRendererDispatcher.getBlockModelShapes();
IBakedModel blockModel = blockModelShapes.getModelForState(state);
if (blockModel != null && blockModel != blockModelShapes.getModelManager().getMissingModel()) { return blockModel; }
}
return defaultModel;
}
ItemQuadCollector.java 文件源码
项目:EnderIO
阅读 19
收藏 0
点赞 0
评论 0
public void addBlockState(IBlockState state, @Nonnull ItemStack stack, boolean allFacesToGeneral) {
if (state != null) {
if (Prep.isInvalid(stack)) {
stack = new ItemStack(state.getBlock(), 1, state.getBlock().damageDropped(state));
}
BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
IBakedModel model = modelShapes.getModelForState(state);
addBakedModel(model, stack, allFacesToGeneral);
}
}
ModelManager.java 文件源码
项目:DecompiledMinecraft
阅读 27
收藏 0
点赞 0
评论 0
public ModelManager(TextureMap textures)
{
this.texMap = textures;
this.modelProvider = new BlockModelShapes(this);
}
ModelManager.java 文件源码
项目:DecompiledMinecraft
阅读 23
收藏 0
点赞 0
评论 0
public BlockModelShapes getBlockModelShapes()
{
return this.modelProvider;
}
ModelBakery.java 文件源码
项目:DecompiledMinecraft
阅读 21
收藏 0
点赞 0
评论 0
public ModelBakery(IResourceManager p_i46085_1_, TextureMap p_i46085_2_, BlockModelShapes p_i46085_3_)
{
this.resourceManager = p_i46085_1_;
this.textureMap = p_i46085_2_;
this.blockModelShapes = p_i46085_3_;
}
ModelManager.java 文件源码
项目:BaseClient
阅读 25
收藏 0
点赞 0
评论 0
public ModelManager(TextureMap textures)
{
this.texMap = textures;
this.modelProvider = new BlockModelShapes(this);
}
ModelManager.java 文件源码
项目:BaseClient
阅读 24
收藏 0
点赞 0
评论 0
public BlockModelShapes getBlockModelShapes()
{
return this.modelProvider;
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 19
收藏 0
点赞 0
评论 0
public ModelBakery(IResourceManager p_i46085_1_, TextureMap p_i46085_2_, BlockModelShapes p_i46085_3_)
{
this.resourceManager = p_i46085_1_;
this.textureMap = p_i46085_2_;
this.blockModelShapes = p_i46085_3_;
}
ModelManager.java 文件源码
项目:BaseClient
阅读 25
收藏 0
点赞 0
评论 0
public ModelManager(TextureMap textures)
{
this.texMap = textures;
this.modelProvider = new BlockModelShapes(this);
}
ModelManager.java 文件源码
项目:BaseClient
阅读 32
收藏 0
点赞 0
评论 0
public BlockModelShapes getBlockModelShapes()
{
return this.modelProvider;
}
ModelBakery.java 文件源码
项目:BaseClient
阅读 24
收藏 0
点赞 0
评论 0
public ModelBakery(IResourceManager p_i46085_1_, TextureMap p_i46085_2_, BlockModelShapes p_i46085_3_)
{
this.resourceManager = p_i46085_1_;
this.textureMap = p_i46085_2_;
this.blockModelShapes = p_i46085_3_;
}
ModelManager.java 文件源码
项目:Backmemed
阅读 25
收藏 0
点赞 0
评论 0
public ModelManager(TextureMap textures)
{
this.texMap = textures;
this.modelProvider = new BlockModelShapes(this);
}
ModelManager.java 文件源码
项目:Backmemed
阅读 24
收藏 0
点赞 0
评论 0
public BlockModelShapes getBlockModelShapes()
{
return this.modelProvider;
}
ModelBakery.java 文件源码
项目:Backmemed
阅读 22
收藏 0
点赞 0
评论 0
public ModelBakery(IResourceManager resourceManagerIn, TextureMap textureMapIn, BlockModelShapes blockModelShapesIn)
{
this.resourceManager = resourceManagerIn;
this.textureMap = textureMapIn;
this.blockModelShapes = blockModelShapesIn;
}
ModelManager.java 文件源码
项目:CustomWorldGen
阅读 23
收藏 0
点赞 0
评论 0
public ModelManager(TextureMap textures)
{
this.texMap = textures;
this.modelProvider = new BlockModelShapes(this);
}
ModelManager.java 文件源码
项目:CustomWorldGen
阅读 25
收藏 0
点赞 0
评论 0
public BlockModelShapes getBlockModelShapes()
{
return this.modelProvider;
}
ModelBakery.java 文件源码
项目:CustomWorldGen
阅读 19
收藏 0
点赞 0
评论 0
public ModelBakery(IResourceManager resourceManagerIn, TextureMap textureMapIn, BlockModelShapes blockModelShapesIn)
{
this.resourceManager = resourceManagerIn;
this.textureMap = textureMapIn;
this.blockModelShapes = blockModelShapesIn;
}
CCBlockRendererDispatcher.java 文件源码
项目:CodeChickenLib
阅读 20
收藏 0
点赞 0
评论 0
@Override
public BlockModelShapes getBlockModelShapes() {
return parentDispatcher.getBlockModelShapes();
}
Minimap.java 文件源码
项目:HeroMod
阅读 22
收藏 0
点赞 0
评论 0
public static void initColors() {
final Minecraft mc = Minecraft.getMinecraft();
TextureManager mgr = mc.getTextureManager();
mgr.bindTexture(TextureMap.locationBlocksTexture);
final int w = GL11.glGetTexLevelParameteri(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH);
final int h = GL11.glGetTexLevelParameteri(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT);
final IntBuffer buf = BufferUtils.createIntBuffer(w * h);
GL11.glGetTexImage(GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, buf);
Thread th = new Thread() {
public void run() {
Map<Block, int[]> colmap = new HashMap<Block, int[]>();
List<ResourceLocation> blocks = new ArrayList<ResourceLocation>();
blocks.addAll(Block.blockRegistry.getKeys());
BlockModelShapes blkShapes = mc.getBlockRendererDispatcher().getBlockModelShapes();
for (ResourceLocation b_loc : blocks) {
Block b = (Block) Block.blockRegistry.getObject(b_loc);
int[] colors = new int[16];
for (int d = 0; d < 16; d++) {
try {
IBlockState state = b.getStateFromMeta(d);
TextureAtlasSprite spt = blkShapes.getTexture(state);
// IIcon ico = b.func_149735_b(1, d);
// IResource res = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation("minecraft", "textures/blocks/" + ico.getIconName() + ".png"));
// InputStream in = res.getInputStream();
// Bitmap img = Bitmap.load(in);
// in.close();
long rt = 0;
long gt = 0;
long bt = 0;
long div = 0;
int x = spt.getOriginX();
int y = spt.getOriginY();
int sw = spt.getIconWidth();
int sh = spt.getIconHeight();
for (int yy = 0; yy < sh; yy++) {
for (int xx = 0; xx < sw; xx++) {
int color = buf.get((xx + x) + (yy + y) * w);
int a = color >>> 24;
if (a != 0) {
rt += (color >> 16) & 0xFF;
gt += (color >> 8) & 0xFF;
bt += color & 0xFF;
div++;
}
}
}
rt /= div;
gt /= div;
bt /= div;
colors[d] = 0xFF000000 | ((int)rt & 0xFF) << 16 | ((int)gt & 0xFF) << 8 | ((int)bt & 0xFF);
} catch (Exception e) {
colors[d] = 0xFF000000;
}
}
colmap.put(b, colors);
}
colorMap = colmap;
}
};
th.start();
}
ClientProxy.java 文件源码
项目:vintagecraft
阅读 19
收藏 0
点赞 0
评论 0
public void ignoreProperties(Block block, IProperty[] properties) {
BlockModelShapes bms = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
bms.registerBlockWithStateMapper(block, (new StateMap.Builder()).addPropertiesToIgnore(properties).build());
}
ModelManager.java 文件源码
项目:ExpandedRailsMod
阅读 23
收藏 0
点赞 0
评论 0
public ModelManager(TextureMap textures)
{
this.texMap = textures;
this.modelProvider = new BlockModelShapes(this);
}