mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-23 11:49:23 +01:00
Cloud fully works now! Awesome!
This commit is contained in:
parent
b25cbb7c85
commit
9c06ade0d9
6 changed files with 96 additions and 41 deletions
|
@ -10,6 +10,7 @@ import ellpeck.actuallyadditions.inventory.GuiHandler;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntitySmileyCloud;
|
import ellpeck.actuallyadditions.tile.TileEntitySmileyCloud;
|
||||||
import ellpeck.actuallyadditions.util.BlockUtil;
|
import ellpeck.actuallyadditions.util.BlockUtil;
|
||||||
import ellpeck.actuallyadditions.util.INameableItem;
|
import ellpeck.actuallyadditions.util.INameableItem;
|
||||||
|
import ellpeck.actuallyadditions.util.StringUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
|
@ -22,10 +23,10 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.IIcon;
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class BlockSmileyCloud extends BlockContainerBase implements INameableItem{
|
public class BlockSmileyCloud extends BlockContainerBase implements INameableItem{
|
||||||
|
|
||||||
|
@ -36,6 +37,25 @@ public class BlockSmileyCloud extends BlockContainerBase implements INameableIte
|
||||||
this.setStepSound(soundTypeWood);
|
this.setStepSound(soundTypeWood);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
|
||||||
|
int meta = world.getBlockMetadata(x, y, z);
|
||||||
|
float f = 0.0625F;
|
||||||
|
|
||||||
|
if(meta == 0){
|
||||||
|
this.setBlockBounds(0F, 0F, 0F, 1F, 1F-f*4F, 1F-f*3F);
|
||||||
|
}
|
||||||
|
if(meta == 1){
|
||||||
|
this.setBlockBounds(0F, 0F, 0F, 1F-f*3F, 1F-f*4F, 1F);
|
||||||
|
}
|
||||||
|
if(meta == 2){
|
||||||
|
this.setBlockBounds(0F, 0F, f*3F, 1F, 1F-f*4F, 1F);
|
||||||
|
}
|
||||||
|
if(meta == 3){
|
||||||
|
this.setBlockBounds(f*3F, 0F, 0F, 1F, 1F-f*4F, 1F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int f6, float f7, float f8, float f9){
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int f6, float f7, float f8, float f9){
|
||||||
TileEntity tile = world.getTileEntity(x, y, z);
|
TileEntity tile = world.getTileEntity(x, y, z);
|
||||||
|
@ -50,7 +70,8 @@ public class BlockSmileyCloud extends BlockContainerBase implements INameableIte
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
for(ISmileyCloudEasterEgg egg : SmileyCloudEasterEggs.cloudStuff){
|
for(ISmileyCloudEasterEgg egg : SmileyCloudEasterEggs.cloudStuff){
|
||||||
if(Objects.equals(egg.getTriggerName(), cloud.name)){
|
for(String triggerName : egg.getTriggerNames()){
|
||||||
|
if(StringUtil.equalsToLowerCase(triggerName, cloud.name)){
|
||||||
if(egg.hasSpecialRightClick()){
|
if(egg.hasSpecialRightClick()){
|
||||||
egg.specialRightClick(world, x, y, z, world.getBlock(x, y, z), world.getBlockMetadata(x, y, z));
|
egg.specialRightClick(world, x, y, z, world.getBlock(x, y, z), world.getBlockMetadata(x, y, z));
|
||||||
return true;
|
return true;
|
||||||
|
@ -59,6 +80,7 @@ public class BlockSmileyCloud extends BlockContainerBase implements INameableIte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,11 @@ package ellpeck.actuallyadditions.blocks.render;
|
||||||
import ellpeck.actuallyadditions.gadget.cloud.ISmileyCloudEasterEgg;
|
import ellpeck.actuallyadditions.gadget.cloud.ISmileyCloudEasterEgg;
|
||||||
import ellpeck.actuallyadditions.gadget.cloud.SmileyCloudEasterEggs;
|
import ellpeck.actuallyadditions.gadget.cloud.SmileyCloudEasterEggs;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntitySmileyCloud;
|
import ellpeck.actuallyadditions.tile.TileEntitySmileyCloud;
|
||||||
|
import ellpeck.actuallyadditions.util.StringUtil;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class RenderSmileyCloud extends RenderTileEntity{
|
public class RenderSmileyCloud extends RenderTileEntity{
|
||||||
|
|
||||||
public RenderSmileyCloud(ModelBaseAA model){
|
public RenderSmileyCloud(ModelBaseAA model){
|
||||||
|
@ -36,21 +36,27 @@ public class RenderSmileyCloud extends RenderTileEntity{
|
||||||
TileEntitySmileyCloud theCloud = (TileEntitySmileyCloud)tile;
|
TileEntitySmileyCloud theCloud = (TileEntitySmileyCloud)tile;
|
||||||
if(theCloud.name != null && !theCloud.name.isEmpty()){
|
if(theCloud.name != null && !theCloud.name.isEmpty()){
|
||||||
for(ISmileyCloudEasterEgg cloud : SmileyCloudEasterEggs.cloudStuff){
|
for(ISmileyCloudEasterEgg cloud : SmileyCloudEasterEggs.cloudStuff){
|
||||||
if(Objects.equals(cloud.getTriggerName(), theCloud.name)){
|
for(String triggerName : cloud.getTriggerNames()){
|
||||||
|
if(StringUtil.equalsToLowerCase(triggerName, theCloud.name)){
|
||||||
|
|
||||||
if(cloud.shouldRenderOriginal()){
|
if(cloud.shouldRenderOriginal()){
|
||||||
theModel.render(0.0625F);
|
theModel.render(0.0625F);
|
||||||
}
|
}
|
||||||
|
|
||||||
//this.bindTexture(cloud.getResLoc());
|
ResourceLocation resLoc = cloud.getResLoc();
|
||||||
|
if(resLoc != null){
|
||||||
|
this.bindTexture(resLoc);
|
||||||
|
}
|
||||||
|
|
||||||
cloud.renderExtra(0.0625F);
|
cloud.renderExtra(0.0625F);
|
||||||
|
|
||||||
hasRendered = true;
|
hasRendered = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(hasRendered) break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!hasRendered) theModel.render(0.0625F);
|
if(!hasRendered) theModel.render(0.0625F);
|
||||||
}
|
}
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
|
@ -42,7 +42,7 @@ public interface ISmileyCloudEasterEgg{
|
||||||
/**
|
/**
|
||||||
* The name the cloud has to have for this effect to occur
|
* The name the cloud has to have for this effect to occur
|
||||||
*/
|
*/
|
||||||
String getTriggerName();
|
String[] getTriggerNames();
|
||||||
|
|
||||||
ResourceLocation getResLoc();
|
ResourceLocation getResLoc();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package ellpeck.actuallyadditions.gadget.cloud;
|
package ellpeck.actuallyadditions.gadget.cloud;
|
||||||
|
|
||||||
import ellpeck.actuallyadditions.blocks.render.ModelBaseAA;
|
import ellpeck.actuallyadditions.util.AssetUtil;
|
||||||
import net.minecraft.client.model.ModelRenderer;
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -12,31 +14,18 @@ public class SmileyCloudEasterEggs{
|
||||||
static{
|
static{
|
||||||
//Glenthor
|
//Glenthor
|
||||||
register(new SmileyCloudEasterEgg(){
|
register(new SmileyCloudEasterEgg(){
|
||||||
|
|
||||||
public ModelRenderer s9;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTriggerName(){
|
public String[] getTriggerNames(){
|
||||||
return "Glenthor";
|
return new String[]{"glenthor"};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderExtra(float f){
|
public void renderExtra(float f){
|
||||||
s9.render(f);
|
GL11.glTranslatef(f*8F, f*24F, f*-4F);
|
||||||
}
|
GL11.glRotatef(180F, 0F, 0F, 1F);
|
||||||
|
GL11.glRotatef(85F, 0F, 1F, 0F);
|
||||||
@Override
|
GL11.glRotatef(70F, 0F, 0F, 1F);
|
||||||
public boolean shouldRenderOriginal(){
|
GL11.glScalef(0.75F, 0.75F, 0.75F);
|
||||||
return false;
|
AssetUtil.renderItem(new ItemStack(Items.dye, 1, 2), 0);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerExtraRendering(ModelBaseAA model){
|
|
||||||
s9 = new ModelRenderer(model, 0, 31);
|
|
||||||
s9.addBox(0F, 0F, 0F, 1, 6, 6);
|
|
||||||
s9.setRotationPoint(7F, 16F, -2F);
|
|
||||||
s9.setTextureSize(64, 64);
|
|
||||||
s9.mirror = true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
package ellpeck.actuallyadditions.util;
|
package ellpeck.actuallyadditions.util;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import net.minecraft.client.renderer.ItemRenderer;
|
||||||
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureMap;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.IIcon;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
public class AssetUtil{
|
public class AssetUtil{
|
||||||
|
@ -15,4 +25,21 @@ public class AssetUtil{
|
||||||
String localMachineName = StringUtil.localize(machineName+".name");
|
String localMachineName = StringUtil.localize(machineName+".name");
|
||||||
font.drawString(localMachineName, xSize/2 - font.getStringWidth(localMachineName)/2, yPositionOfMachineText, StringUtil.DECIMAL_COLOR_WHITE);
|
font.drawString(localMachineName, xSize/2 - font.getStringWidth(localMachineName)/2, yPositionOfMachineText, StringUtil.DECIMAL_COLOR_WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public static void renderItem(ItemStack stack, int renderPass){
|
||||||
|
IIcon icon = stack.getItem().getIcon(stack, renderPass);
|
||||||
|
float f = icon.getMinU();
|
||||||
|
float f1 = icon.getMaxU();
|
||||||
|
float f2 = icon.getMinV();
|
||||||
|
float f3 = icon.getMaxV();
|
||||||
|
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
|
||||||
|
ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F/16F);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public static void renderBlock(Block block, int meta){
|
||||||
|
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||||
|
RenderBlocks.getInstance().renderBlockAsItem(block, meta, 1F);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package ellpeck.actuallyadditions.util;
|
||||||
|
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class StringUtil{
|
public class StringUtil{
|
||||||
|
|
||||||
public static final String BLACK = (char)167 + "0";
|
public static final String BLACK = (char)167 + "0";
|
||||||
|
@ -42,4 +44,13 @@ public class StringUtil{
|
||||||
public static String localizeFormatted(String text, Object ... replace){
|
public static String localizeFormatted(String text, Object ... replace){
|
||||||
return StatCollector.translateToLocalFormatted(text, replace);
|
return StatCollector.translateToLocalFormatted(text, replace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String toLowerCase(String string){
|
||||||
|
if(string == null) return null;
|
||||||
|
else return string.toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean equalsToLowerCase(String one, String two){
|
||||||
|
return Objects.equals(toLowerCase(one), toLowerCase(two));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue