Skip to content

Commit

Permalink
Fix variants not rendering for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Waterpicker committed Nov 29, 2023
1 parent 284a8d8 commit 87eb893
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
import generations.gg.generations.core.generationscore.client.render.rarecandy.LightingSettings;
import generations.gg.generations.core.generationscore.client.render.rarecandy.PixelmonInstance;
import generations.gg.generations.core.generationscore.world.entity.StatueEntity;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;

import java.util.Set;

public class StatueEntityClient extends PoseableEntityState<PokemonEntity> implements PixelmonInstanceProvider {
private PixelmonInstance pixelmonInstance;

Expand All @@ -34,6 +37,16 @@ public void setInstance(PixelmonInstance instance) {
pixelmonInstance = instance;
}

@Override
public ResourceLocation species() {
return null;
}

@Override
public Set<String> aspects() {
return null;
}

@Nullable
@Override
public PokemonEntity getEntity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,17 @@ public void render(RenderContext context, PoseStack stack, VertexConsumer buffer

if(model.renderObject.isReady()) {
instance.setLight(packedLight);
var id = context.request(RenderContext.Companion.getTEXTURE());



var id = getTexture(context.request(RenderContext.Companion.getENTITY()));
System.out.println("Rendering: " + id);

if(id != null && id.getNamespace().equals("pk")) instance.setVariant(id.getPath());
if (id != null) {
if (id.getNamespace().equals("pk")) {
instance.setVariant(id.getPath());
}
}

stack.pushPose();

Expand All @@ -84,6 +91,11 @@ public void render(RenderContext context, PoseStack stack, VertexConsumer buffer
}
}

private ResourceLocation getTexture(Entity entity) {
if(entity instanceof PixelmonInstanceProvider provider) return provider.getVariant();
else return null;
}

@Override
public void transform(PoseStack poseStack) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
package generations.gg.generations.core.generationscore.client.render;

import com.cobblemon.mod.common.client.render.models.blockbench.repository.PokemonModelRepository;
import generations.gg.generations.core.generationscore.client.render.rarecandy.PixelmonInstance;
import net.minecraft.resources.ResourceLocation;

import java.util.Set;

public interface PixelmonInstanceProvider {
public PixelmonInstance getInstance();
void setInstance(PixelmonInstance instance);

public ResourceLocation species();

public Set<String> aspects();

default ResourceLocation getVariant() {
return PokemonModelRepository.INSTANCE.getVariations().get(species()).getTexture(aspects(), 0.0f);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import generations.gg.generations.core.generationscore.client.render.PixelmonInstanceProvider;
import generations.gg.generations.core.generationscore.client.render.rarecandy.LightingSettings;
import generations.gg.generations.core.generationscore.client.render.rarecandy.PixelmonInstance;
import net.minecraft.resources.ResourceLocation;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Mixin;

import java.util.Set;

@Mixin(PokemonEntity.class)
public class PokemonEntityMixin implements PixelmonInstanceProvider {
public abstract class PokemonEntityMixin implements PixelmonInstanceProvider {
private PixelmonInstance instance;

public PixelmonInstance getInstance() {
Expand All @@ -18,8 +21,22 @@ public PixelmonInstance getInstance() {
return instance;
}

private PokemonEntity self() {
return (PokemonEntity) (Object) this;
}

@Override
public void setInstance(PixelmonInstance instance) {
this.instance = instance;
}

@Override
public Set<String> aspects() {
return self().getPokemon().getAspects();
}

@Override
public ResourceLocation species() {
return self().getPokemon().getSpecies().getResourceIdentifier();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.Set;

import static dev.architectury.utils.Env.CLIENT;

Expand Down Expand Up @@ -204,6 +205,16 @@ public void setInstance(PixelmonInstance instance) {
}
}

@Override
public ResourceLocation species() {
return getStatueData().asRenderablePokemon().getSpecies().getResourceIdentifier();
}

@Override
public Set<String> aspects() {
return getStatueData().asRenderablePokemon().getAspects();
}

@Override
public float getScale() {
return getStatueData().getScale();
Expand Down

0 comments on commit 87eb893

Please sign in to comment.