forked from YoungSoulluoS/cem_Fork
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
89 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/net/dorianpb/cem/external/models/CemTridentModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
// } | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/net/dorianpb/cem/external/renderers/CemTridentRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters