@SuppressWarnings("rawtypes") @SideOnly(Side.CLIENT) @Override public void onRenderLiving(RenderLivingEvent.Pre event, RenderLivingBase renderer, int amplifier) { GlStateManager.pushMatrix(); EnumDyeColor dye = EnumDyeColor.byDyeDamage(Math.min(amplifier, EnumDyeColor.values().length - 1)); int rgb = dye.getColorValue(); float r = (rgb >>> 16 & 0xFF) / 256.0F; float g = (rgb >>> 8 & 0xFF) / 256.0F; float b = (rgb & 0xFF) / 256.0F; GlStateManager.color(r, g, b); GlStateManager.popMatrix(); }
/** * Setup renderer * * This method is responsible for setting up any client side stuff like * the renderer, texture of the entity and the "hands" */ @SideOnly(Side.CLIENT) protected void setupRenderer() { this.renderer = Minecraft.getMinecraft().getRenderManager().getEntityRenderObject(this.entity); if (this.renderer instanceof RenderLivingBase<?>) { ModelBase model = ((RenderLivingBase<?>) renderer).getMainModel(); if (this.customSettings && model instanceof ModelBiped || model instanceof ModelQuadruped) { this.settings.hands = true; } } }
private static void replaceEntriesInRenderPlayer(RenderPlayer renderer, ModelPlayer newModel) { if(renderer == null) { return; } //replace relevant fields in RenderPlayer for(Field field : RenderLivingBase.class.getDeclaredFields()) { if(field.getType() == ModelBase.class) { field.setAccessible(true); try { field.set(renderer, newModel); } catch (IllegalAccessException e) { InfinityLib.instance.getLogger().printStackTrace(e); } break; } } }
private static void replaceCapeLayer(@Nonnull RenderPlayer renderLivingBase) { try { List<LayerRenderer<AbstractClientPlayer>> value = ReflectionHelper.getPrivateValue(RenderLivingBase.class, renderLivingBase, "layerRenderers", "field_177097_h"); if (value != null) { LayerRenderer<AbstractClientPlayer> capeLayer = null; for (LayerRenderer<AbstractClientPlayer> layerRenderer : value) { if (layerRenderer instanceof LayerCape && !(layerRenderer instanceof CapeFilterLayer)) { capeLayer = layerRenderer; break; } } if (capeLayer != null) { renderLivingBase.addLayer(new CapeFilterLayer(capeLayer)); value.remove(capeLayer); } } } catch (UnableToAccessFieldException e) { Log.warn("Unable to access RenderLivingBase.layerRenderers, reason: " + e); } }
public void preChildEntHeadRenderCalls(E living, RenderLivingBase render) { if(living.isChild()) //I don't like this if statement any more than you do. { float modelScale = 0.0625F; ModelBase model = render.getMainModel(); if(model instanceof ModelBiped) { GlStateManager.scale(0.75F, 0.75F, 0.75F); GlStateManager.translate(0.0F, 16.0F * modelScale, 0.0F); } else if(model instanceof ModelQuadruped) { if(model instanceof ModelPolarBear) { GlStateManager.scale(0.6666667F, 0.6666667F, 0.6666667F); } GlStateManager.translate(0.0F, ((ModelQuadruped)model).childYOffset * modelScale, ((ModelQuadruped)model).childZOffset * modelScale); } else if(model instanceof ModelChicken) { GlStateManager.translate(0.0F, 5.0F * modelScale, 2.0F * modelScale); } } }
@Override public void preChildEntHeadRenderCalls(AbstractHorse living, RenderLivingBase render) { if(living.isChild()) //I don't like this if statement any more than you do. { float modelScale = 0.0625F; if(iChunUtil.config.horseEasterEgg == 1) { GlStateManager.scale(0.625F, 0.45454544F, 0.45454544F); GlStateManager.translate(0.0F, 33.0F * modelScale, 0.0F); } else { GlStateManager.scale(0.71428573F, 0.64935064F, 0.7936508F); GlStateManager.translate(0.0F, 21.0F * modelScale, 0.22F); } } }
@Inject(method = "renderEnchantedGlint", at = @At("HEAD"), cancellable = true) private static void renderEnchantedGlint(RenderLivingBase<?> p_188364_0_, EntityLivingBase p_188364_1_, ModelBase model, float p_188364_3_, float p_188364_4_, float p_188364_5_, float p_188364_6_, float p_188364_7_, float p_188364_8_, float p_188364_9_, CallbackInfo ci) { GlintEffectEvent event = new GlintEffectEvent(GlintEffectEvent.GlintTarget.ARMOR); ClientAPI.EVENT_BUS.post(event); if (event.isCancelled()) ci.cancel(); }
public LayerWearables(RenderLivingBase<?> render, ModelBiped model) { this.renderer = render; this.head = model.bipedHead; this.body = model.bipedBody; this.modelBig = new ModelBiped(1.15F); this.modelMedium = new ModelBiped(0.75F); this.modelSmall = new ModelBiped(0.25F); }
public RenderLivingEvent(EntityLivingBase entity, RenderLivingBase<T> renderer, double x, double y, double z) { this.entity = entity; this.renderer = renderer; this.x = x; this.y = y; this.z = z; }
public static void renderEnchantedGlint(RenderLivingBase<?> p_188364_0_, EntityLivingBase p_188364_1_, ModelBase model, float p_188364_3_, float p_188364_4_, float p_188364_5_, float p_188364_6_, float p_188364_7_, float p_188364_8_, float p_188364_9_) { float f = (float)p_188364_1_.ticksExisted + p_188364_5_; p_188364_0_.bindTexture(ENCHANTED_ITEM_GLINT_RES); GlStateManager.enableBlend(); GlStateManager.depthFunc(514); GlStateManager.depthMask(false); float f1 = 0.5F; GlStateManager.color(0.5F, 0.5F, 0.5F, 1.0F); for (int i = 0; i < 2; ++i) { GlStateManager.disableLighting(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE); float f2 = 0.76F; GlStateManager.color(0.38F, 0.19F, 0.608F, 1.0F); GlStateManager.matrixMode(5890); GlStateManager.loadIdentity(); float f3 = 0.33333334F; GlStateManager.scale(0.33333334F, 0.33333334F, 0.33333334F); GlStateManager.rotate(30.0F - (float)i * 60.0F, 0.0F, 0.0F, 1.0F); GlStateManager.translate(0.0F, f * (0.001F + (float)i * 0.003F) * 20.0F, 0.0F); GlStateManager.matrixMode(5888); model.render(p_188364_1_, p_188364_3_, p_188364_4_, p_188364_6_, p_188364_7_, p_188364_8_, p_188364_9_); } GlStateManager.matrixMode(5890); GlStateManager.loadIdentity(); GlStateManager.matrixMode(5888); GlStateManager.enableLighting(); GlStateManager.depthMask(true); GlStateManager.depthFunc(515); GlStateManager.disableBlend(); }
/** * Render player */ public void renderPlayer(EntityPlayer player, int x, int y, int scale) { EntityPlayerSP entity = (EntityPlayerSP) player; RenderLivingBase<EntityPlayerSP> render = (RenderLivingBase<EntityPlayerSP>) this.mc.getRenderManager().getEntityRenderObject(entity); ModelBase model = render.getMainModel(); model.isChild = false; model.swingProgress = 0; this.mc.renderEngine.bindTexture(entity.getLocationSkin()); GuiUtils.drawModel(model, player, x, y, scale); }
public static void replaceOldModel() { RenderPlayer renderer = getOldRenderer("default"); if(renderer == null) { InfinityLib.instance.getLogger().debug("Failed overriding left arm swing behaviour"); return; } ModelPlayer oldModel = renderer.getMainModel(); ModelPlayer newModel = null; for(Field field : RenderLivingBase.class.getDeclaredFields()) { if(field.getType() == ModelBase.class) { try { field.setAccessible(true); Object obj = field.get(renderer); if (obj == oldModel) { newModel = MODEL_MAIN; field.set(renderer, newModel); break; } } catch (Exception e) { InfinityLib.instance.getLogger().printStackTrace(e); } } } if(newModel != null) { //replace relevant fields in RenderPlayer replaceEntriesInRenderPlayer(renderer, newModel); replaceEntriesInRenderPlayer(getOldRenderer("slim"), MODEL_SLIM); } }
@Override public void init (FMLInitializationEvent event) { super.init(event); registerRenders(); registerKeyBindings(); RenderLivingBase renderPlayer = Minecraft.getMinecraft().getRenderManager().getSkinMap().get("default"); renderPlayer.addLayer(new LayerRendererDrive(renderPlayer)); renderPlayer = Minecraft.getMinecraft().getRenderManager().getSkinMap().get("slim"); renderPlayer.addLayer(new LayerRendererDrive(renderPlayer)); MinecraftForge.EVENT_BUS.register(new ClientEventHandler()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPedestal.class, new TESRPedestal()); }
public WindowNewAction(IWorkspace parent, int x, int y, int w, int h, int minW, int minH) { super(parent, x, y, w, h, minW, minH, "window.newAction.title", true); elements.add(new ElementTextInput(this, 10, 30, width - 20, 12, 1, "window.newAction.name")); elements.add(new ElementTextInput(this, 10, 135, width - 20, 12, 2, "window.newAction.playerName")); ElementSelector selector = new ElementSelector(this, 10, 65, width - 20, 12, -2, "window.newAction.entityType", "EntityPlayer"); for(Object o : EntityList.NAME_TO_CLASS.values()) { Class<? extends Entity> clz = (Class)o; if(EntityLivingBase.class.isAssignableFrom(clz) && Minecraft.getMinecraft().getRenderManager().getEntityClassRenderObject(clz) instanceof RenderLivingBase) { selector.choices.put(clz.getSimpleName(), clz); } } selector.choices.put(EntityPlayer.class.getSimpleName(), EntityPlayer.class); selector.selected = EntityPlayer.class.getSimpleName(); elements.add(selector); elements.add(new ElementCheckBox(this, 11, 89, -1, false, 0, 0, "window.newAction.preCreate", false)); elements.add(new ElementCheckBox(this, 11, 109, -2, false, 0, 0, "window.newAction.persist", false)); elements.add(new ElementButton(this, width - 140, height - 30, 60, 16, 100, false, 1, 1, "element.button.ok")); elements.add(new ElementButton(this, width - 70, height - 30, 60, 16, 0, false, 1, 1, "element.button.cancel")); }
/** Ensures that the specified entity class' renderer has a backpack layer - if possible. */ public static void ensureHasBackpackLayer(Class<? extends EntityLivingBase> entityClass) { if (!_hasLayerChecked.add(entityClass)) return; RenderManager manager = Minecraft.getMinecraft().getRenderManager(); Render<?> render = manager.getEntityClassRenderObject(entityClass); if (!(render instanceof RenderLivingBase)) return; ((RenderLivingBase<?>)render).addLayer(new RendererBackpack.Layer()); }
@Override public void doRender(EntityShattered shattered, double x, double y, double z, float entityYaw, float partialTicks) { if(shattered.model == null) { shattered.model = new ModelShattered(shattered); } ResourceLocation rl = getEntityTexture(shattered); if(shattered.model.entRenderer instanceof RenderLivingBase && rl != null) { GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); GlStateManager.rotate(180F, 0F, 1F, 0F); GlStateManager.scale(-1.0F, -1.0F, 1.0F); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); bindTexture(rl); GlStateManager.alphaFunc(GL11.GL_GREATER, 0.003921569F); ObfHelper.invokePreRenderCallback((RenderLivingBase)shattered.model.entRenderer, shattered.model.entRenderer.getClass(), shattered.acquired, partialTicks); GlStateManager.translate(0F, -1F, 0F); shattered.model.render(shattered, 0F, 0F, 0F, 0F, 0F, 0.0625F); GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F); GlStateManager.disableBlend(); GlStateManager.popMatrix(); } }
@Override public void preChildEntHeadRenderCalls(EntityOcelot living, RenderLivingBase render) { if(living.isChild()) //I don't like this if statement any more than you do. { float modelScale = 0.0625F; GlStateManager.scale(0.75F, 0.75F, 0.75F); GlStateManager.translate(0.0F, 10.0F * modelScale, 4.0F * modelScale); } }
@Override public void preChildEntHeadRenderCalls(AbstractHorse living, RenderLivingBase render) { if(living.isChild()) //I don't like this if statement any more than you do. { float f1 = living.getHorseSize(); if(iChunUtil.config.horseEasterEgg == 1) { GlStateManager.scale(f1, f1, f1); GlStateManager.translate(0.0F, 1.35F * (1.0F - f1), 0.0F); } else { float f = living.getGrassEatingAmount(0.0F); float f2 = 0.5F + f1 * f1 * 0.5F; GlStateManager.scale(f2, f2, f2); if (f <= 0.0F) { GlStateManager.translate(0.0F, 1.35F * (1.0F - f1), 0.0F); } else { GlStateManager.translate(0.0F, 0.9F * (1.0F - f1) * f + 1.35F * (1.0F - f1) * (1.0F - f), 0.15F * (1.0F - f1) * f); } } } }
@Override public void preChildEntHeadRenderCalls(EntityWolf living, RenderLivingBase render) { if(living.isChild()) //I don't like this if statement any more than you do. { float modelScale = 0.0625F; GlStateManager.translate(0.0F, 5.0F * modelScale, 2.0F * modelScale); } }
@SuppressWarnings("rawtypes") @SideOnly(Side.CLIENT) void onRenderLiving(RenderLivingEvent.Pre event, RenderLivingBase renderer, int amplifier);
public LayerToolBelt(RenderLivingBase<?> livingEntityRendererIn) { this.livingEntityRenderer = livingEntityRendererIn; }
public LayerSkullEyes(RenderLivingBase<EntityLivingBase> renderer) { livingRenderer = renderer; }
public LayerVillagerArmor(RenderLivingBase<?> rendererIn) { super(rendererIn); }
public LayerStrayClothing(RenderLivingBase<?> p_i47183_1_) { this.renderer = p_i47183_1_; }
public LayerArrow(RenderLivingBase<?> rendererIn) { this.renderer = rendererIn; }
public LayerElytra(RenderLivingBase<?> p_i47185_1_) { this.renderPlayer = p_i47185_1_; }
public LayerBipedArmor(RenderLivingBase<?> rendererIn) { super(rendererIn); }
public LayerHeldItem(RenderLivingBase<?> livingEntityRendererIn) { this.livingEntityRenderer = livingEntityRendererIn; }
public LayerArmorBase(RenderLivingBase<?> rendererIn) { this.renderer = rendererIn; this.initArmor(); }
public static void renderEnchantedGlint(RenderLivingBase<?> p_188364_0_, EntityLivingBase p_188364_1_, ModelBase model, float p_188364_3_, float p_188364_4_, float p_188364_5_, float p_188364_6_, float p_188364_7_, float p_188364_8_, float p_188364_9_) { if (!Config.isShaders() || !Shaders.isShadowPass) { float f = (float)p_188364_1_.ticksExisted + p_188364_5_; p_188364_0_.bindTexture(ENCHANTED_ITEM_GLINT_RES); if (Config.isShaders()) { ShadersRender.renderEnchantedGlintBegin(); } Minecraft.getMinecraft().entityRenderer.func_191514_d(true); GlStateManager.enableBlend(); GlStateManager.depthFunc(514); GlStateManager.depthMask(false); float f1 = 0.5F; GlStateManager.color(0.5F, 0.5F, 0.5F, 1.0F); for (int i = 0; i < 2; ++i) { GlStateManager.disableLighting(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE); float f2 = 0.76F; GlStateManager.color(0.38F, 0.19F, 0.608F, 1.0F); GlStateManager.matrixMode(5890); GlStateManager.loadIdentity(); float f3 = 0.33333334F; GlStateManager.scale(0.33333334F, 0.33333334F, 0.33333334F); GlStateManager.rotate(30.0F - (float)i * 60.0F, 0.0F, 0.0F, 1.0F); GlStateManager.translate(0.0F, f * (0.001F + (float)i * 0.003F) * 20.0F, 0.0F); GlStateManager.matrixMode(5888); model.render(p_188364_1_, p_188364_3_, p_188364_4_, p_188364_6_, p_188364_7_, p_188364_8_, p_188364_9_); GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); } GlStateManager.matrixMode(5890); GlStateManager.loadIdentity(); GlStateManager.matrixMode(5888); GlStateManager.enableLighting(); GlStateManager.depthMask(true); GlStateManager.depthFunc(515); GlStateManager.disableBlend(); Minecraft.getMinecraft().entityRenderer.func_191514_d(false); if (Config.isShaders()) { ShadersRender.renderEnchantedGlintEnd(); } } }
public LayerSkeletonType(RenderLivingBase<?> p_i47131_1_) { this.renderer = p_i47131_1_; this.layerModel = new ModelSkeleton(0.25F, true); }
public LayerSkinsuit(RenderLivingBase<?> renderer, ModelBiped model) { this.renderer = renderer; this.model = model; }
public LayerBabyHeldItem(RenderLivingBase<?> livingEntityRendererIn) { this.livingEntityRenderer = livingEntityRendererIn; }
@SubscribeEvent public void onRender(final RenderPlayerEvent.Pre event){ if(event.getEntityPlayer() ==null)return; try{ @SuppressWarnings("unchecked") List<LayerRenderer<EntityLivingBase>> layers = (List<LayerRenderer<EntityLivingBase>>) ReflectionUtils.getPrivateValue(event.getRenderer(), RenderLivingBase.class, ObfuscatedNames.RenderLivingBase_layerRenderers); for(LayerRenderer<EntityLivingBase> layer : layers){ if(layer instanceof LayerBipedArmor){ LayerBipedArmor armor = (LayerBipedArmor)layer; ItemStack helmet = event.getEntityPlayer().getItemStackFromSlot(EntityEquipmentSlot.HEAD); ModelBiped modelHelmet = armor.getModelFromSlot(EntityEquipmentSlot.HEAD); ItemStack chest = event.getEntityPlayer().getItemStackFromSlot(EntityEquipmentSlot.CHEST); ModelBiped modelChest = armor.getModelFromSlot(EntityEquipmentSlot.CHEST); ItemStack legs = event.getEntityPlayer().getItemStackFromSlot(EntityEquipmentSlot.LEGS); ModelBiped modelLegs = armor.getModelFromSlot(EntityEquipmentSlot.LEGS); ItemStack boots = event.getEntityPlayer().getItemStackFromSlot(EntityEquipmentSlot.FEET); ModelBiped modelBoots = armor.getModelFromSlot(EntityEquipmentSlot.FEET); if(modelHelmet !=null){ if(ItemStackTools.isValid(helmet) && ModEnhancements.INVIS_ARMOR.isApplied(helmet)){ modelHelmet.bipedHead.isHidden = true; modelHelmet.bipedHeadwear.isHidden = true; } } if(modelChest !=null){ if(ItemStackTools.isValid(chest) && ModEnhancements.INVIS_ARMOR.isApplied(chest)){ modelChest.bipedBody.isHidden = true; modelChest.bipedRightArm.isHidden = true; modelChest.bipedLeftArm.isHidden = true; } } if(modelLegs !=null){ if(ItemStackTools.isValid(legs) && ModEnhancements.INVIS_ARMOR.isApplied(legs)){ modelLegs.bipedBody.isHidden = true; modelLegs.bipedLeftLeg.isHidden = true; modelLegs.bipedRightLeg.isHidden = true; } } if(modelBoots !=null){ if(ItemStackTools.isValid(boots) && ModEnhancements.INVIS_ARMOR.isApplied(boots)){ modelBoots.bipedLeftLeg.isHidden = true; modelBoots.bipedRightLeg.isHidden = true; } } } } }catch(Exception e){ e.printStackTrace(); } }