Начинающий
- Статус
- Оффлайн
- Регистрация
- 21 Дек 2024
- Сообщения
- 53
- Реакции
- 0
- Выберите загрузчик игры
- Vanilla
- Forge
- Fabric
- NeoForge
- OptiFine
- ForgeOptiFine
- Прочие моды
elytrapig.java:
public class ElytraPigModule extends Module {
private final BooleanSetting onlySelf = new BooleanSetting("Только я").setValue(true);
private PigEntity pig;
public ElytraPigModule() {
super("Elytra Pig", "Показывает свинью вместо элитры при полёте", "Show a pig instead of elytra while flying", ModuleCategory.Render);
registerComponent(onlySelf);
}
private boolean shouldRenderPigForPlayer(net.minecraft.entity.player.PlayerEntity p) {
if (onlySelf.getValue() && p != mc.player) return false;
if (!p.isElytraFlying()) return false;
return p.getItemStackFromSlot(net.minecraft.inventory.EquipmentSlotType.CHEST).getItem() == Items.ELYTRA;
}
@EventHandler
public void onWorldRender(WorldRenderEvent e) {
if (mc.world == null || mc.player == null) return;
if (!shouldRenderPigForPlayer(mc.player)) return;
if (pig == null || pig.world != mc.world) {
pig = new PigEntity(EntityType.PIG, mc.world);
pig.setInvisible(false);
pig.setNoAI(true);
}
MatrixStack stack = e.getStack();
Vector3d cam = mc.gameRenderer.getActiveRenderInfo().getProjectedView();
Vector3d pos = mc.player.getPositionVec();
double partial = e.getTicks();
double x = pos.x - cam.x;
double y = pos.y - cam.y - 0.8; // ниже игрока
double z = pos.z - cam.z;
float yaw = mc.player.rotationYaw;
float pitch = mc.player.rotationPitch;
// без смещения назад — рендерим прямо под игроком
pig.rotationYaw = yaw;
pig.rotationPitch = pitch * 0.3f;
pig.prevRotationYaw = pig.rotationYaw;
pig.prevRotationPitch = pig.rotationPitch;
IRenderTypeBuffer.Impl bufferSource = mc.getRenderTypeBuffers().getBufferSource();
IRenderTypeBuffer buffer = (IRenderTypeBuffer) bufferSource;
int light = 15728880; // full bright to keep it visible
stack.push();
// лёгкое масштабирование для соответствия элитрам
float scale = 0.8f;
stack.translate(x, y, z);
stack.scale(scale, scale, scale);
mc.getRenderManager().renderEntityStatic(pig, 0.0, 0.0, 0.0, 0.0f, (float) partial, stack, buffer, light);
stack.pop();
bufferSource.finish();
}
}
ElytraLayer.java:
public class ElytraLayer<T extends LivingEntity, M extends EntityModel<T>> extends LayerRenderer<T, M>
{
private static final ResourceLocation TEXTURE_ELYTRA = new ResourceLocation("textures/entity/elytra.png");
private final ElytraModel<T> modelElytra = new ElytraModel<>();
public ElytraLayer(IEntityRenderer<T, M> rendererIn)
{
super(rendererIn);
}
public void render(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, T entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch)
{
ItemStack itemstack = entitylivingbaseIn.getItemStackFromSlot(EquipmentSlotType.CHEST);
if (this.shouldRender(itemstack, entitylivingbaseIn))
{
ResourceLocation resourcelocation;
if (entitylivingbaseIn instanceof AbstractClientPlayerEntity)
{
AbstractClientPlayerEntity abstractclientplayerentity = (AbstractClientPlayerEntity)entitylivingbaseIn;
if (abstractclientplayerentity.isPlayerInfoSet() && abstractclientplayerentity.getLocationElytra() != null)
{
resourcelocation = abstractclientplayerentity.getLocationElytra();
}
else if (abstractclientplayerentity.hasElytraCape() && abstractclientplayerentity.hasPlayerInfo() && abstractclientplayerentity.getLocationCape() != null && abstractclientplayerentity.isWearing(PlayerModelPart.CAPE))
{
resourcelocation = abstractclientplayerentity.getLocationCape();
}
else
{
resourcelocation = this.getElytraTexture(itemstack, entitylivingbaseIn);
if (Config.isCustomItems())
{
resourcelocation = CustomItems.getCustomElytraTexture(itemstack, resourcelocation);
}
}
}
else
{
resourcelocation = this.getElytraTexture(itemstack, entitylivingbaseIn);
if (Config.isCustomItems())
{
resourcelocation = CustomItems.getCustomElytraTexture(itemstack, resourcelocation);
}
}
matrixStackIn.push();
matrixStackIn.translate(0.0D, 0.0D, 0.125D);
this.getEntityModel().copyModelAttributesTo(this.modelElytra);
this.modelElytra.setRotationAngles(entitylivingbaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
IVertexBuilder ivertexbuilder = ItemRenderer.getArmorVertexBuilder(bufferIn, RenderType.getArmorCutoutNoCull(resourcelocation), false, itemstack.hasEffect());
this.modelElytra.render(matrixStackIn, ivertexbuilder, packedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
matrixStackIn.pop();
}
}
public boolean shouldRender(ItemStack p_shouldRender_1_, T p_shouldRender_2_)
{
if (Client.instance.moduleManager != null && Client.instance.moduleManager.elytraPigModule != null && Client.instance.moduleManager.elytraPigModule.isEnabled()) {
return false;
}
return p_shouldRender_1_.getItem() == Items.ELYTRA;
}
public ResourceLocation getElytraTexture(ItemStack p_getElytraTexture_1_, T p_getElytraTexture_2_)
{
return TEXTURE_ELYTRA;
}
}
пошел пенить мету