Skip to content

Commit

Permalink
Support for Tridents
Browse files Browse the repository at this point in the history
  • Loading branch information
dorianpb committed Dec 22, 2021
1 parent 83b5950 commit 3e81638
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 6 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,28 @@ assets/dorianpb/cem/za/waurdo/creeper.jem", etc.
* Cows
* Chicken
* Creepers
* Ender Dragon (must be ender_dragon.jem, not dragon.jem)
* Endermen
* Ender Dragon (must be ender_dragon.jem, not dragon.jem)
* Fish (just salmon for now)
* Foxes
* Ghasts
* Illagers (Evokers, Illusioners, Pillagers, and Vindicators)
* Guardians and Elder Guardians
* Horses and their undead variants
* Illagers (Evokers, Illusioners, Pillagers, and Vindicators)
* Iron Golems
* Magma Cubes
* Minecarts (all variants)
* Mooshrooms
* Ocelots
* Phantoms
* Pigs
* Piglins (including Piglin Brutes and Zombified Piglins)
* Rabbits
* Sheep
* Skeletons and their variants (Wither Skeletons and Strays)
* Slimes
* Spiders (and Cave Spiders
* Phantoms
* Pigs
* Piglins (including Piglin Brutes and Zombified Piglins)
* Tridents
* Villagers (and Zombie Villagers)
* Wandering Traders
* Witches
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@ public void onInit(){
register(EntityType.PHANTOM, CemPhantomRenderer::new);
register(EntityType.GHAST, CemGhastRenderer::new);
register(EntityType.SALMON, CemSalmonRenderer::new);
register(EntityType.TRIDENT, CemTridentRenderer::new);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package net.dorianpb.cem.external.models;

import net.dorianpb.cem.internal.api.CemModel;
import net.dorianpb.cem.internal.models.CemModelRegistry;
import net.dorianpb.cem.internal.models.CemModelRegistry.CemPrepRootPartParamsBuilder;
import net.minecraft.client.render.entity.model.TridentEntityModel;

import java.util.HashMap;
import java.util.Map;

public class CemTridentModel extends TridentEntityModel implements CemModel{
private static final Map<String, String> partNames = new HashMap<>();
private final CemModelRegistry registry;

static{
partNames.put("body", "pole");
}

public CemTridentModel(CemModelRegistry registry){
super(registry.prepRootPart((new CemPrepRootPartParamsBuilder()).setPartNameMap(partNames)
.setVanillaReferenceModelFactory(() -> getTexturedModelData().createModel())
.create()));
this.registry = registry;
}

// @Override
// public void setAngles(TridentEntity entity, float limbAngle, float limbDistance, float animationProgress, float headYaw, float headPitch){
// super.setAngles(entity, limbAngle, limbDistance, animationProgress, headYaw, headPitch);
// this.registry.applyAnimations(limbAngle, limbDistance, animationProgress, headYaw, headPitch, entity);
// }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package net.dorianpb.cem.external.renderers;

import net.dorianpb.cem.external.models.CemTridentModel;
import net.dorianpb.cem.internal.api.CemRenderer;
import net.dorianpb.cem.internal.models.CemModelRegistry;
import net.dorianpb.cem.internal.util.CemRegistryManager;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.TridentEntityRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.projectile.TridentEntity;
import net.minecraft.util.Identifier;

public class CemTridentRenderer extends TridentEntityRenderer implements CemRenderer{
private final CemModelRegistry registry;

public CemTridentRenderer(EntityRendererFactory.Context context){
super(context);
this.registry = CemRegistryManager.getRegistry(getType());
try{
this.model = new CemTridentModel(registry);
if(registry.hasShadowRadius()){
this.shadowRadius = registry.getShadowRadius();
}
} catch(Exception e){
modelError(e);
}
}

private static EntityType<? extends Entity> getType(){
return EntityType.TRIDENT;
}

@Override
public String getId(){
return getType().toString();
}

@Override
public Identifier getTexture(TridentEntity entity){
if(this.registry != null && this.registry.hasTexture()){
return this.registry.getTexture();
}
return super.getTexture(entity);
}
}
6 changes: 5 additions & 1 deletion src/main/resources/cem.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@ extendable class net/minecraft/client/render/entity/HorseEntityRenderer

#Horse Armor
mutable field net/minecraft/client/render/entity/feature/HorseArmorFeatureRenderer model Lnet/minecraft/client/render/entity/model/HorseEntityModel;
accessible field net/minecraft/client/render/entity/feature/HorseArmorFeatureRenderer model Lnet/minecraft/client/render/entity/model/HorseEntityModel;
accessible field net/minecraft/client/render/entity/feature/HorseArmorFeatureRenderer model Lnet/minecraft/client/render/entity/model/HorseEntityModel;

#Trident
mutable field net/minecraft/client/render/entity/TridentEntityRenderer model Lnet/minecraft/client/render/entity/model/TridentEntityModel;
accessible field net/minecraft/client/render/entity/TridentEntityRenderer model Lnet/minecraft/client/render/entity/model/TridentEntityModel;

0 comments on commit 3e81638

Please sign in to comment.