Skip to content

Commit

Permalink
fix item models
Browse files Browse the repository at this point in the history
  • Loading branch information
eerussianguy committed Oct 28, 2022
1 parent 7cf0690 commit 1d6c21d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ jobs:
- todo: document changes
draft: true
prerelease: ${{ steps.version_type.outputs.result != 'release' }}
- name: Publish
id: publish
if: ${{ steps.version_type.outputs.result != 'alpha' && success() }}
if: ${{ success() }}
uses: gradle/gradle-build-action@v2
with:
arguments: curseforge
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/com/eerussianguy/betterfoliage/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import com.google.gson.JsonObject;
import net.minecraft.client.Minecraft;
Expand All @@ -16,6 +15,7 @@
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.BlockModelRotation;
import net.minecraft.client.resources.model.Material;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.client.resources.model.SimpleBakedModel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand All @@ -25,12 +25,14 @@
import net.minecraft.world.level.block.state.BlockState;

import com.eerussianguy.betterfoliage.particle.SpritePicker;
import com.mojang.blaze3d.vertex.PoseStack;

import static com.eerussianguy.betterfoliage.BetterFoliage.MOD_ID;

public class Helpers
{
public static final Direction[] DIRECTIONS = Direction.values();
public static final ModelResourceLocation BACKING_DIRT_MODEL = new ModelResourceLocation("minecraft", "dirt", "inventory");

public static ResourceLocation identifier(String name)
{
Expand Down Expand Up @@ -75,7 +77,7 @@ public static ResourceLocation identifierOrEmpty(JsonObject json, String member)
public static Collection<Material> makeMaterials(ResourceLocation... textures)
{
//noinspection deprecation
return Arrays.stream(textures).map(texture -> new Material(TextureAtlas.LOCATION_BLOCKS, texture)).collect(Collectors.toList());
return Arrays.stream(textures).map(texture -> new Material(TextureAtlas.LOCATION_BLOCKS, texture)).toList();
}

public static BakedQuad makeBakedQuad(BlockElement BlockElement, BlockElementFace partFace, TextureAtlasSprite atlasSprite, Direction dir, BlockModelRotation modelRotation, ResourceLocation modelResLoc)
Expand Down Expand Up @@ -156,4 +158,9 @@ static void addTintedParticle(TextureSheetParticle particle, List<TextureAtlasSp
particle.setColor(r, g, b);
mc.particleEngine.add(particle);
}

public static void applyTransform(ItemTransforms.TransformType cameraTransformType, PoseStack poseStack, boolean lefty)
{
Minecraft.getInstance().getModelManager().getModel(BACKING_DIRT_MODEL).applyTransform(cameraTransformType, poseStack, lefty);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.eerussianguy.betterfoliage.BFConfig;
import com.eerussianguy.betterfoliage.Helpers;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -125,7 +126,7 @@ private BakedModel buildBlock(TextureAtlasSprite tex, boolean tint)
Map<Direction, BlockElementFace> mapFacesIn = Maps.newEnumMap(Direction.class);
for (Direction d : Helpers.DIRECTIONS)
{
mapFacesIn.put(d, tint ? Helpers.makeTintedFace(Helpers.UV_DEFAULT) : Helpers.makeFace(Helpers.UV_DEFAULT));
mapFacesIn.put(d, tint ? Helpers.makeTintedFace(Helpers.UV_DEFAULT, true) : Helpers.makeFace(Helpers.UV_DEFAULT, true));
}
BlockElement part = new BlockElement(new Vector3f(0f, 0f, 0f), new Vector3f(16f, 16f, 16f), mapFacesIn, null, true);
SimpleBakedModel.Builder builder = new SimpleBakedModel.Builder(blockModel, ItemOverrides.EMPTY, false).particle(tex);
Expand Down Expand Up @@ -178,4 +179,10 @@ public TextureAtlasSprite getParticleIcon()
return Objects.requireNonNull(leavesTex);
}

@Override
public BakedModel applyTransform(ItemTransforms.TransformType transformType, PoseStack poseStack, boolean applyLeftHandTransform)
{
Helpers.applyTransform(transformType, poseStack, applyLeftHandTransform);
return this;
}
}

0 comments on commit 1d6c21d

Please sign in to comment.