mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 19:29:31 +00:00
Double flowers. WIP.
This commit is contained in:
1 parent
3f44e6318a
commit
96be37448f
41 files changed
+236
-4
No files matched your search
@@ -53,6 +53,7 @@ import vazkii.botania.client.lib.LibRenderIDs;
|
||||
import vazkii.botania.client.render.block.RenderAltar;
|
||||
import vazkii.botania.client.render.block.RenderBrewery;
|
||||
import vazkii.botania.client.render.block.RenderCorporeaIndex;
|
||||
import vazkii.botania.client.render.block.RenderDoubleFlower;
|
||||
import vazkii.botania.client.render.block.RenderFloatingFlower;
|
||||
import vazkii.botania.client.render.block.RenderPool;
|
||||
import vazkii.botania.client.render.block.RenderPump;
|
||||
@@ -172,6 +173,7 @@ public class ClientProxy extends CommonProxy {
|
||||
LibRenderIDs.idBrewery = RenderingRegistry.getNextAvailableRenderId();
|
||||
LibRenderIDs.idCorporeaIndex = RenderingRegistry.getNextAvailableRenderId();
|
||||
LibRenderIDs.idPump = RenderingRegistry.getNextAvailableRenderId();
|
||||
LibRenderIDs.idDoubleFlower = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
RenderingRegistry.registerBlockHandler(new RenderAltar());
|
||||
RenderingRegistry.registerBlockHandler(new RenderSpecialFlower(LibRenderIDs.idSpecialFlower));
|
||||
@@ -184,6 +186,7 @@ public class ClientProxy extends CommonProxy {
|
||||
RenderingRegistry.registerBlockHandler(new RenderBrewery());
|
||||
RenderingRegistry.registerBlockHandler(new RenderCorporeaIndex());
|
||||
RenderingRegistry.registerBlockHandler(new RenderPump());
|
||||
RenderingRegistry.registerBlockHandler(new RenderDoubleFlower());
|
||||
|
||||
RenderTransparentItem renderTransparentItem = new RenderTransparentItem();
|
||||
RenderFloatingFlowerItem renderFloatingFlower = new RenderFloatingFlowerItem();
|
||||
|
||||
@@ -23,5 +23,6 @@ public final class LibRenderIDs {
|
||||
public static int idBrewery = -1;
|
||||
public static int idCorporeaIndex = -1;
|
||||
public static int idPump = -1;
|
||||
public static int idDoubleFlower = -1;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Mar 22, 2015, 9:00:06 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.render.block;
|
||||
|
||||
import vazkii.botania.client.lib.LibRenderIDs;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoublePlant;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class RenderDoubleFlower implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int p_147774_2_, int p_147774_3_, int p_147774_4_, Block block, int modelId, RenderBlocks renderer) {
|
||||
BlockDoublePlant p_147774_1_ = (BlockDoublePlant) block;
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.setBrightness(p_147774_1_.getMixedBrightnessForBlock(world, p_147774_2_, p_147774_3_, p_147774_4_));
|
||||
tessellator.setColorOpaque_F(1F, 1F, 1F);
|
||||
long j1 = (long)(p_147774_2_ * 3129871) ^ (long)p_147774_4_ * 116129781L;
|
||||
j1 = j1 * j1 * 42317861L + j1 * 11L;
|
||||
double d19 = (double)p_147774_2_;
|
||||
double d0 = (double)p_147774_3_;
|
||||
double d1 = (double)p_147774_4_;
|
||||
d19 += ((double)((float)(j1 >> 16 & 15L) / 15.0F) - 0.5D) * 0.3D;
|
||||
d1 += ((double)((float)(j1 >> 24 & 15L) / 15.0F) - 0.5D) * 0.3D;
|
||||
int i1 = world.getBlockMetadata(p_147774_2_, p_147774_3_, p_147774_4_);
|
||||
boolean flag = false;
|
||||
boolean flag1 = BlockDoublePlant.func_149887_c(i1);
|
||||
int k1;
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
if (world.getBlock(p_147774_2_, p_147774_3_ - 1, p_147774_4_) != p_147774_1_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
k1 = BlockDoublePlant.func_149890_d(world.getBlockMetadata(p_147774_2_, p_147774_3_ - 1, p_147774_4_));
|
||||
}
|
||||
else
|
||||
{
|
||||
k1 = BlockDoublePlant.func_149890_d(i1);
|
||||
}
|
||||
|
||||
RenderSpecialFlower.drawCrossedSquares(world, block, p_147774_2_, p_147774_3_, p_147774_4_, p_147774_2_, p_147774_3_, p_147774_4_, 1F, renderer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return LibRenderIDs.idDoubleFlower;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class RenderSpecialFlower implements ISimpleBlockRenderingHandler {
|
||||
}
|
||||
|
||||
// Copied from RenderBlocks
|
||||
public boolean renderCrossedSquares(IBlockAccess blockAccess, Block par1Block, int par2, int par3, int par4, RenderBlocks render) {
|
||||
public static boolean renderCrossedSquares(IBlockAccess blockAccess, Block par1Block, int par2, int par3, int par4, RenderBlocks render) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.setBrightness(par1Block.getMixedBrightnessForBlock(blockAccess, par2, par3, par4));
|
||||
float f = 1.0F;
|
||||
@@ -73,7 +73,7 @@ public class RenderSpecialFlower implements ISimpleBlockRenderingHandler {
|
||||
}
|
||||
|
||||
// Copied from RenderBlocks
|
||||
public void drawCrossedSquares(IBlockAccess blockAccess, Block par1Block, int x, int y, int z, double par3, double par5, double par7, float par9, RenderBlocks render) {
|
||||
public static void drawCrossedSquares(IBlockAccess blockAccess, Block par1Block, int x, int y, int z, double par3, double par5, double par7, float par9, RenderBlocks render) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
// Only change here, to use xyz rather than side/meta
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Mar 22, 2015, 7:46:55 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
import vazkii.botania.client.lib.LibRenderIDs;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.BotaniaCreativeTab;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.item.block.ItemBlockWithMetadataAndName;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lib.LibBlockNames;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoublePlant;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IShearable;
|
||||
|
||||
public class BlockModDoubleFlower extends BlockDoublePlant implements ILexiconable {
|
||||
|
||||
private static final int COUNT = 8;
|
||||
|
||||
IIcon[] doublePlantTopIcons, doublePlantBottomIcons;
|
||||
final int offset;
|
||||
|
||||
public BlockModDoubleFlower(boolean second) {
|
||||
offset = second ? 8 : 0;
|
||||
setBlockName(LibBlockNames.DOUBLE_FLOWER + (second ? 2 : 1));
|
||||
setHardness(0F);
|
||||
setStepSound(soundTypeGrass);
|
||||
setTickRandomly(false);
|
||||
setCreativeTab(BotaniaCreativeTab.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block setBlockName(String par1Str) {
|
||||
if(!par1Str.equals("doublePlant"))
|
||||
GameRegistry.registerBlock(this, ItemBlockWithMetadataAndName.class, par1Str);
|
||||
return super.setBlockName(par1Str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
|
||||
ItemStack stack = new ItemStack(ModBlocks.flower, 1, (metadata & 7) + offset);
|
||||
ArrayList<ItemStack> list = new ArrayList();
|
||||
list.add(stack);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
|
||||
return (func_149887_c(p_149691_2_) ? doublePlantTopIcons : doublePlantBottomIcons)[p_149691_2_ & 7];
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
boolean top = func_149887_c(meta);
|
||||
if(top)
|
||||
meta = world.getBlockMetadata(x, y - 1, z);
|
||||
|
||||
return (top ? doublePlantBottomIcons : doublePlantTopIcons)[meta & 7];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister register) {
|
||||
doublePlantTopIcons = new IIcon[COUNT];
|
||||
doublePlantBottomIcons = new IIcon[COUNT];
|
||||
for(int i = 0; i < COUNT; i++) {
|
||||
int off = offset(i);
|
||||
doublePlantTopIcons[i] = IconHelper.forName(register, "flower" + off + "Tall0");
|
||||
doublePlantBottomIcons[i] = IconHelper.forName(register, "flower" + off + "Tall1");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) {
|
||||
for(int i = 0; i < COUNT; ++i)
|
||||
p_149666_3_.add(new ItemStack(p_149666_1_, 1, i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return LibRenderIDs.idDoubleFlower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
|
||||
int meta = par1World.getBlockMetadata(par2, par3, par4);
|
||||
float[] color = EntitySheep.fleeceColorTable[offset(meta & 7)];
|
||||
|
||||
if(par5Random.nextDouble() < ConfigHandler.flowerParticleFrequency)
|
||||
Botania.proxy.sparkleFX(par1World, par2 + 0.3 + par5Random.nextFloat() * 0.5, par3 + 0.5 + par5Random.nextFloat() * 0.5, par4 + 0.3 + par5Random.nextFloat() * 0.5, color[0], color[1], color[2], par5Random.nextFloat(), 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LexiconEntry getEntry(World world, int x, int y, int z, EntityPlayer player, ItemStack lexicon) {
|
||||
return LexiconData.flowers;
|
||||
}
|
||||
|
||||
int offset(int meta) {
|
||||
return meta + offset;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -208,6 +208,8 @@ public final class ModBlocks {
|
||||
public static Block endStoneBrick;
|
||||
public static Block mushroom;
|
||||
public static Block pump;
|
||||
public static Block doubleFlower1;
|
||||
public static Block doubleFlower2;
|
||||
|
||||
public static void init() {
|
||||
flower = new BlockModFlower();
|
||||
@@ -272,7 +274,9 @@ public final class ModBlocks {
|
||||
endStoneBrick = new BlockEndStoneBrick();
|
||||
mushroom = new BlockModMushroom();
|
||||
pump = new BlockPump();
|
||||
|
||||
doubleFlower1 = new BlockModDoubleFlower(false);
|
||||
doubleFlower2 = new BlockModDoubleFlower(true);
|
||||
|
||||
ModFluffBlocks.init();
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
@@ -387,4 +391,4 @@ public final class ModBlocks {
|
||||
GameRegistry.registerTileEntityWithAlternatives(clazz, LibResources.PREFIX_MOD + key, key);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -225,6 +225,8 @@ public final class BotaniaCreativeTab extends CreativeTabs {
|
||||
|
||||
// FLUFF
|
||||
|
||||
addBlock(ModBlocks.doubleFlower1);
|
||||
addBlock(ModBlocks.doubleFlower2);
|
||||
addBlock(ModBlocks.shinyFlower);
|
||||
addBlock(ModBlocks.floatingFlower);
|
||||
addBlock(ModBlocks.floatingSpecialFlower);
|
||||
|
||||
@@ -77,6 +77,7 @@ public final class LibBlockNames {
|
||||
public static final String END_STONE_BRICK = "endStoneBrick";
|
||||
public static final String MUSHROOM = "mushroom";
|
||||
public static final String PUMP = "pump";
|
||||
public static final String DOUBLE_FLOWER = "doubleFlower";
|
||||
|
||||
public static final String SUBTILE_PUREDAISY = "puredaisy";
|
||||
public static final String SUBTILE_MANASTAR = "manastar";
|
||||
|
||||
Reference in new issue
Block a user