Java tutorial
/***************************************************************************\ * Copyright 2016 [Lyonlancer5] * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * \***************************************************************************/ package net.lyonlancer5.mcmp.karasu.client.renderer.entity; import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.lyonlancer5.mcmp.karasu.client.renderer.model.ModelRabbit; import net.lyonlancer5.mcmp.karasu.entity.passive.EntityRabbit; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; /** * @author Lyonlancer5 */ @SideOnly(Side.CLIENT) public class RenderRabbit extends RenderLiving { private static final ResourceLocation BROWN = new ResourceLocation("textures/entity/rabbit/brown.png"); private static final ResourceLocation WHITE = new ResourceLocation("textures/entity/rabbit/white.png"); private static final ResourceLocation BLACK = new ResourceLocation("textures/entity/rabbit/black.png"); private static final ResourceLocation GOLD = new ResourceLocation("textures/entity/rabbit/gold.png"); private static final ResourceLocation SALT = new ResourceLocation("textures/entity/rabbit/salt.png"); private static final ResourceLocation WHITE_SPLOTCHED = new ResourceLocation( "textures/entity/rabbit/white_splotched.png"); private static final ResourceLocation TOAST = new ResourceLocation("textures/entity/rabbit/toast.png"); public RenderRabbit() { super(new ModelRabbit(), 0.3F); } @Override protected void preRenderCallback(EntityLivingBase entityliving, float patialTickTime) { GL11.glScalef(0.65F, 0.65F, 0.65F); } @Override protected ResourceLocation getEntityTexture(Entity entity) { EntityRabbit rabbit = (EntityRabbit) entity; String s = EnumChatFormatting.getTextWithoutFormattingCodes(rabbit.getCommandSenderName()); if (s != null && s.equals("Toast")) return TOAST; else switch (rabbit.getRabbitType()) { case 0: default: return BROWN; case 1: return WHITE; case 2: return BLACK; case 3: return WHITE_SPLOTCHED; case 4: return GOLD; case 5: return SALT; } } }