Skip to content

Commit

Permalink
Block collision; worldgen tweak; candle lantern source
Browse files Browse the repository at this point in the history
  • Loading branch information
jaquadro committed Dec 7, 2015
1 parent 4ac045b commit a92cf41
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 8 deletions.
9 changes: 8 additions & 1 deletion resources/assets/gardencore/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ item.gardencore.gardenTrowel.name=Garden Trowel
item.gardencore.soilTestKit.name=Soil Test Kit
item.gardencore.soilTestKitUsed.name=Used Soil Test Kit
item.gardencore.compostPile.name=Compost
item.gardencore.wax.name=Wax

tile.gardencore.smallFire.name=Small Fire
tile.gardencore.gardenSoil.name=Garden Soil
Expand Down Expand Up @@ -93,6 +94,7 @@ item.gardenstuff.ironNugget.name=Iron Nugget
item.gardenstuff.wroughtIronIngot.name=Wrought Iron Ingot
item.gardenstuff.wroughtIronNugget.name=Wrought Iron Nugget
item.gardenstuff.mossPaste.name=Moss Paste
item.gardenstuff.candle.name=Candle

nei.recipe.gardenstuff.bloomeryFurnace=Bloomery Process

Expand Down Expand Up @@ -137,6 +139,7 @@ tile.gardenstuff.mossBrick.cracked_mossy_1.name=Mossy Cracked Stone Bricks
tile.gardenstuff.mossBrick.cracked_mossy_2.name=Mossy Cracked Stone Bricks
tile.gardenstuff.mossBrick.cracked_mossy_3.name=Mossy Cracked Stone Bricks
tile.gardenstuff.mossBrick.cracked_mossy_4.name=Mossy Cracked Stone Bricks
tile.gardenstuff.candelabra.name=Candelabra

gardenstuff.lanternSource=Contents
gardenstuff.lanternSource.none=Empty
Expand All @@ -149,6 +152,9 @@ gardenstuff.lanternSource.thaumcraftCandle=Tallow Candle

# Garden Trees

item.gardentrees.candelillaSeeds.name=Candelilla Seeds
item.gardentrees.candelilla.name=Candelilla

tile.gardentrees.ivy.name=Devil's Ivy
tile.gardentrees.strangePlant.name=Strange Plant
tile.gardentrees.strangePlant.description=What is contained within its strange pods?
Expand All @@ -168,4 +174,5 @@ tile.gardentrees.thinLogFence.spruce.name=Spruce Wood Post Fence
tile.gardentrees.thinLogFence.birch.name=Birch Wood Post Fence
tile.gardentrees.thinLogFence.jungle.name=Jungle Wood Post Fence
tile.gardentrees.thinLogFence.acacia.name=Acacia Wood Post Fence
tile.gardentrees.thinLogFence.big_oak.name=Dark Oak Wood Post Fence
tile.gardentrees.thinLogFence.big_oak.name=Dark Oak Wood Post Fence
tile.gardentrees.candelilla.name=Candelilla
76 changes: 74 additions & 2 deletions src/com/jaquadro/minecraft/gardenstuff/block/BlockCandelabra.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -82,8 +83,79 @@ public boolean shouldSideBeRendered (IBlockAccess world, int x, int y, int z, in
}

@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z) {
return null;
public void setBlockBoundsBasedOnState (IBlockAccess world, int x, int y, int z) {
TileEntityCandelabra tile = getTileEntity(world, x, y, z);

float yMin = 0;
float yMax = 1;
float xMin = 0;
float xMax = 1;
float zMin = 0;
float zMax = 1;

float depth = (tile.getLevel() == 2) ? .5f : .390625f;
float hwidth = (tile.getLevel() == 0) ? .125f : .390625f;

if (tile.isSconce()) {
yMin = .0625f;
yMax = .875f;
switch (tile.getDirection()) {
case 2:
zMax = depth;
xMin = .5f - hwidth;
xMax = .5f + hwidth;
break;
case 3:
zMin = 1 - depth;
xMin = .5f - hwidth;
xMax = .5f + hwidth;
break;
case 4:
xMax = depth;
zMin = .5f - hwidth;
zMax = .5f + hwidth;
break;
case 5:
xMin = 1 - depth;
zMin = .5f - hwidth;
zMax = .5f + hwidth;
break;
}
}
else {
yMax = .0625f * 15f;
xMin = zMin = .0625f * 5.75f;
xMax = zMax = .0625f * 10.25f;

switch (tile.getLevel()) {
case 0:
yMax = .0625f * 15f;
break;
case 1:
if (tile.getDirection() == 2 || tile.getDirection() == 3) {
xMin = .0625f * .5f;
xMax = .0625f * 15.5f;
}
else {
zMin = .0625f * .5f;
zMax = .0625f * 15.5f;
}
break;
case 2:
xMin = zMin = .0625f * .5f;
xMax = zMax = .0625f * 15.5f;
break;
}
}

setBlockBounds(xMin, yMin, zMin, xMax, yMax, zMax);
}

@Override
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) {
setBlockBoundsBasedOnState(world, x, y, z);
setBlockBounds((float)minX, (float)minY, (float)minZ, (float)maxX, (float)maxY - (.0625f * 1.5f), (float)maxZ);
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.jaquadro.minecraft.gardenapi.api.GardenAPI;
import com.jaquadro.minecraft.gardenapi.api.component.ILanternSourceRegistry;
import com.jaquadro.minecraft.gardenstuff.integration.lantern.CandleLanternSource;
import com.jaquadro.minecraft.gardenstuff.integration.lantern.VanillaLanternSource;

public class VanillaIntegration
Expand All @@ -12,5 +13,7 @@ public static void init () {
registry.registerLanternSource(new VanillaLanternSource.TorchLanternSource());
registry.registerLanternSource(new VanillaLanternSource.RedstoneTorchSource());
registry.registerLanternSource(new VanillaLanternSource.GlowstoneSource());

registry.registerLanternSource(new CandleLanternSource());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.jaquadro.minecraft.gardenstuff.integration.lantern;

import com.jaquadro.minecraft.gardenapi.api.component.StandardLanternSource;
import com.jaquadro.minecraft.gardencore.client.renderer.support.ModularBoxRenderer;
import com.jaquadro.minecraft.gardencore.util.RenderHelper;
import com.jaquadro.minecraft.gardenstuff.block.BlockCandelabra;
import com.jaquadro.minecraft.gardenstuff.core.ModBlocks;
import com.jaquadro.minecraft.gardenstuff.core.ModItems;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer;

import java.util.Random;

public class CandleLanternSource extends StandardLanternSource
{
private ModularBoxRenderer boxrender = new ModularBoxRenderer();

public CandleLanternSource () {
super(new LanternSourceInfo("candle", ModItems.candle, 14));
}

@Override
@SideOnly(Side.CLIENT)
public void render (RenderBlocks renderer, int x, int y, int z, int meta, int pass) {
float unit = 0.0625f;
BlockCandelabra block = ModBlocks.candelabra;

RenderHelper.instance.state.setRenderOffset(0, -.375f, 0);
RenderHelper.instance.state.setColorMult(1, .9f, .8f, .5f);

boxrender.setUnit(0);
boxrender.setColor(ModularBoxRenderer.COLOR_WHITE);
boxrender.setIcon(block.getIconCandleTop(), 1);
for (int i = 2; i < 6; i++)
boxrender.setIcon(block.getIconCandleSide(), i);

// Candle
boxrender.renderExterior(renderer.blockAccess, block, x, y, z, unit * 6.5f, unit * 7, unit * 6.5f, unit * 9.5f, unit * 13, unit * 9.5f, 0, ModularBoxRenderer.CUT_YNEG);

RenderHelper.instance.state.resetColorMult();

RenderHelper.instance.setRenderBounds(0, 0, 0, 1, 1, 1);
RenderHelper.instance.renderCrossedSquares(renderer.blockAccess, block, x, y, z, block.getIconCandleSide());

RenderHelper.instance.state.clearRenderOffset();
}

@Override
@SideOnly(Side.CLIENT)
public void renderItem (RenderBlocks renderer, IItemRenderer.ItemRenderType renderType, int meta) {
float unit = 0.0625f;
BlockCandelabra block = ModBlocks.candelabra;

RenderHelper.instance.state.setRenderOffset(0, -.375f, 0);
RenderHelper.instance.state.setColorMult(1, .9f, .8f, .5f);

boxrender.setUnit(0);
boxrender.setColor(ModularBoxRenderer.COLOR_WHITE);
boxrender.setIcon(block.getIconCandleTop(), 1);
for (int i = 2; i < 6; i++)
boxrender.setIcon(block.getIconCandleSide(), i);

int x = 0;
int y = 0;
int z = 0;

// Candle
boxrender.renderExterior(null, block, x, y, z, unit * 6.5f, unit * 7, unit * 6.5f, unit * 9.5f, unit * 13, unit * 9.5f, 0, ModularBoxRenderer.CUT_YNEG);

RenderHelper.instance.state.resetColorMult();

RenderHelper.instance.setRenderBounds(0, 0, 0, 1, 1, 1);
RenderHelper.instance.renderCrossedSquares(block, meta, block.getIconCandleSide());

RenderHelper.instance.state.clearRenderOffset();
}

@Override
@SideOnly(Side.CLIENT)
public void renderParticle (World world, int x, int y, int z, Random rand, int meta) {
double px = x + 0.5F;
double py = y + 0.625F;
double pz = z + 0.5F;

world.spawnParticle("flame", px, py, pz, 0.0D, 0.0D, 0.0D);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public boolean generate (World world, Random rand, int x, int y, int z) {
int x1 = x + rand.nextInt(range) - rand.nextInt(range);
int y1 = y + rand.nextInt(4) - rand.nextInt(4);
int z1 = z + rand.nextInt(range) - rand.nextInt(range);
int level = 1 + rand.nextInt(6);
int level = 1 + rand.nextInt(7);

if (world.isAirBlock(x1, y1, z1) && (!world.provider.hasNoSky || y1 < 255) && plantBlock.canBlockStay(world, x1, y1, z1))
world.setBlock(x1, y1, z1, plantBlock, level, 2);
Expand All @@ -47,12 +47,14 @@ public void generate (Random random, int chunkX, int chunkZ, World world, IChunk
int z = chunkZ * 16;

BiomeGenBase biome = world.getWorldChunkManager().getBiomeGenAt(x, z);
if (BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.COLD))
if (BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.COLD)
|| BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.NETHER)
|| BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.WET)
|| BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.WASTELAND)
|| BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.SNOWY))
return;

if (!BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.SAVANNA)
&& !BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.DRY)
&& !BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.SANDY))
if (!BiomeDictionary.isBiomeOfType(biome, BiomeDictionary.Type.SANDY))
return;

if (random.nextInt(10) > 0)
Expand Down

0 comments on commit a92cf41

Please sign in to comment.