mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-18 11:29:23 +00:00
Update Soil and add Soil Models
This commit is contained in:
1 parent
0caaa095a2
commit
2ed7e79478
126 files changed
+900
-224
No files matched your search
@@ -1,14 +1,30 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
public enum EnumAcidity implements IStringSerializable {
|
||||
Acid,
|
||||
Acid(TextFormatting.RED),
|
||||
Neutral,
|
||||
Alkaline;
|
||||
Alkaline(TextFormatting.AQUA);
|
||||
|
||||
final TextFormatting color;
|
||||
|
||||
EnumAcidity() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
EnumAcidity(TextFormatting color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
|
||||
public String getTranslated(boolean withColor){
|
||||
return (withColor && color != null ? color : "") + I18n.translateToLocal("botany.ph." + getName());
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,30 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
|
||||
public enum EnumMoisture implements IStringSerializable {
|
||||
Dry,
|
||||
Dry(TextFormatting.YELLOW),
|
||||
Normal,
|
||||
Damp;
|
||||
Damp(TextFormatting.DARK_BLUE);
|
||||
|
||||
final TextFormatting color;
|
||||
|
||||
EnumMoisture() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
EnumMoisture(TextFormatting color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
public String getTranslated(boolean withColor){
|
||||
return (withColor && color != null ? color : "") + I18n.translateToLocal("botany.moisture." + getName());
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,16 @@
|
||||
package binnie.botany.api;
|
||||
|
||||
public enum EnumSoilType {
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum EnumSoilType implements IStringSerializable {
|
||||
SOIL,
|
||||
LOAM,
|
||||
FLOWERBED;
|
||||
|
||||
public String getID() {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public class ModuleCore implements IInitializable {
|
||||
Binnie.Language.addObjectName(pH2, Binnie.Language.unlocalised(Botany.instance, "moisture." + pH2.getName()));
|
||||
}
|
||||
for (final EnumSoilType pH3 : EnumSoilType.values()) {
|
||||
Binnie.Language.addObjectName(pH3, Binnie.Language.unlocalised(Botany.instance, "soil." + pH3.getID()));
|
||||
Binnie.Language.addObjectName(pH3, Binnie.Language.unlocalised(Botany.instance, "soil." + pH3.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockFlower extends BlockContainer implements /*IItemModelRegister, */IColoredBlock {
|
||||
|
||||
public static final AxisAlignedBB FLOWER_BLOCK_AABB = new AxisAlignedBB(0.3F, 0.0F, 0.3, 0.7F, 0.6F, 0.7F);
|
||||
public static final AxisAlignedBB FLOWER_BLOCK_AABB = new AxisAlignedBB(0.3D, 0.0D, 0.3D, 0.7D, 0.6D, 0.7D);
|
||||
|
||||
public BlockFlower() {
|
||||
super(Material.PLANTS);
|
||||
|
||||
@@ -23,11 +23,6 @@ import java.util.Random;
|
||||
public class BlockPlant extends BlockBush {
|
||||
public static final PropertyEnum<Type> PLANT_TYPE = PropertyEnum.create("plant_type", Type.class);
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public void registerBlockIcons(final IIconRegister p_149651_1_) {
|
||||
@@ -41,6 +36,11 @@ public class BlockPlant extends BlockBush {
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setTickRandomly(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package binnie.botany.gardening;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.Botany;
|
||||
import binnie.botany.CreativeTabBotany;
|
||||
import binnie.botany.api.EnumAcidity;
|
||||
import binnie.botany.api.EnumMoisture;
|
||||
import binnie.botany.api.EnumSoilType;
|
||||
import binnie.botany.api.gardening.IBlockSoil;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -17,23 +20,53 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockSoil extends Block implements IBlockSoil {
|
||||
boolean weedKilled;
|
||||
// IIcon[] iconsTop;
|
||||
// IIcon[] iconsSide;
|
||||
// IIcon[] iconsNoWeed;
|
||||
EnumSoilType type;
|
||||
public class BlockSoil extends Block implements IBlockSoil, IItemModelRegister {
|
||||
|
||||
private final boolean weedKilled;
|
||||
private final EnumSoilType type;
|
||||
|
||||
public static final PropertyEnum<EnumMoisture> MOISTURE = PropertyEnum.create("moisture", EnumMoisture.class);
|
||||
public static final PropertyEnum<EnumAcidity> ACIDITY = PropertyEnum.create("acidity", EnumAcidity.class);
|
||||
public static final AxisAlignedBB SOIL_BLOCK_AABB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.9375D, 1.0D);
|
||||
|
||||
public BlockSoil(EnumSoilType type, String blockName, boolean weedKilled) {
|
||||
super(Material.GROUND);
|
||||
this.weedKilled = weedKilled;
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setRegistryName(blockName);
|
||||
this.setTickRandomly(true);
|
||||
this.setLightOpacity(255);
|
||||
this.setHardness(0.5f);
|
||||
this.setSoundType(SoundType.GROUND);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return SOIL_BLOCK_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
return SOIL_BLOCK_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World worldIn, BlockPos pos) {
|
||||
return SOIL_BLOCK_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List) {
|
||||
@@ -41,6 +74,32 @@ public class BlockSoil extends Block implements IBlockSoil {
|
||||
par3List.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
int index = 0;
|
||||
for(EnumMoisture moisture : EnumMoisture.values()){
|
||||
for(EnumAcidity acidity : EnumAcidity.values()){
|
||||
String modelName = "";
|
||||
if(acidity != EnumAcidity.Neutral){
|
||||
modelName +=acidity.getName();
|
||||
}
|
||||
if(moisture != EnumMoisture.Normal){
|
||||
if(!modelName.isEmpty()){
|
||||
modelName += "_";
|
||||
}
|
||||
modelName +=moisture.getName();
|
||||
}
|
||||
if(modelName.isEmpty()){
|
||||
modelName = "normal";
|
||||
}
|
||||
manager.registerItemModel(item, index, type.getName() + (weedKilled ? "NoWeed" : "") + "/" + modelName);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
@@ -59,103 +118,49 @@ public class BlockSoil extends Block implements IBlockSoil {
|
||||
return getDefaultState().withProperty(MOISTURE, moisture).withProperty(ACIDITY, acidity);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public IIcon getIcon(final IBlockAccess world, final int x, final int y, final int z, final int side) {
|
||||
// return this.getIcon(side, world.getBlockMetadata(x, y, z));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public IIcon getIcon(final int side, int meta) {
|
||||
// meta = ((meta >= 9) ? 8 : meta);
|
||||
// final EnumMoisture moisture = EnumMoisture.values()[meta % 3];
|
||||
// final EnumAcidity acidity = EnumAcidity.values()[meta / 3];
|
||||
// return (side == 1) ? (this.weedKilled ? this.iconsNoWeed[meta] : this.iconsTop[meta]) : ((side == 0) ? Blocks.dirt.getIcon(side, 0) : this.iconsSide[meta]);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public void registerBlockIcons(final IIconRegister register) {
|
||||
// for (final EnumMoisture moisture : EnumMoisture.values()) {
|
||||
// for (final EnumAcidity pH : EnumAcidity.values()) {
|
||||
// this.iconsTop[moisture.ordinal() + pH.ordinal() * 3] = Botany.proxy.getIcon(register, "soil/" + this.getType().getID() + "." + pH.getID() + "." + moisture.getID() + ".0");
|
||||
// this.iconsSide[moisture.ordinal() + pH.ordinal() * 3] = Botany.proxy.getIcon(register, "soil/" + this.getType().getID() + "." + pH.getID() + "." + moisture.getID() + ".1");
|
||||
// this.iconsNoWeed[moisture.ordinal() + pH.ordinal() * 3] = Botany.proxy.getIcon(register, "soil/" + this.getType().getID() + "." + pH.getID() + "." + moisture.getID() + ".2");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public EnumSoilType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public BlockSoil(final EnumSoilType type, final String blockName, final boolean weedKilled) {
|
||||
super(Material.GROUND);
|
||||
this.weedKilled = false;
|
||||
// this.iconsTop = new IIcon[9];
|
||||
// this.iconsSide = new IIcon[9];
|
||||
// this.iconsNoWeed = new IIcon[9];
|
||||
this.weedKilled = weedKilled;
|
||||
this.setCreativeTab(CreativeTabBotany.instance);
|
||||
this.setRegistryName(blockName);
|
||||
this.setTickRandomly(true);
|
||||
//this.setBlockBounds(0.0f, 0.0f, 0.0f, 1.0f, 0.9375f, 1.0f);
|
||||
this.setLightOpacity(255);
|
||||
this.setHardness(0.5f);
|
||||
this.setSoundType(SoundType.GROUND);
|
||||
this.type = type;
|
||||
|
||||
@Override
|
||||
public int damageDropped(IBlockState state) {
|
||||
return getMetaFromState(state);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public int damageDropped(final int p_149692_1_) {
|
||||
// return p_149692_1_;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void updateTick(final World world, final int x, final int y, final int z, final Random random) {
|
||||
// final int meta = world.getBlockMetadata(x, y, z);
|
||||
// EnumMoisture moisture = EnumMoisture.values()[meta % 3];
|
||||
// final EnumAcidity acidity = EnumAcidity.values()[meta / 3];
|
||||
// final EnumMoisture desiredMoisture = Gardening.getNaturalMoisture(world, x, y, z);
|
||||
// if (desiredMoisture.ordinal() > moisture.ordinal()) {
|
||||
// moisture = ((moisture == EnumMoisture.Dry) ? EnumMoisture.Normal : EnumMoisture.Damp);
|
||||
// }
|
||||
// if (desiredMoisture.ordinal() < moisture.ordinal()) {
|
||||
// moisture = ((moisture == EnumMoisture.Damp) ? EnumMoisture.Normal : EnumMoisture.Dry);
|
||||
// }
|
||||
// final int meta2 = getMeta(acidity, moisture);
|
||||
// if (meta != meta2) {
|
||||
// world.setBlockMetadataWithNotify(x, y, z, meta2, 2);
|
||||
// }
|
||||
// if (!this.weedKilled && random.nextInt(5 - this.getType(world, x, y, z).ordinal()) == 0 && world.getBlock(x, y + 1, z) == Blocks.air) {
|
||||
// world.setBlock(x, y + 1, z, Botany.plant, BlockPlant.Type.Weeds.ordinal(), 2);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public AxisAlignedBB getCollisionBoundingBoxFromPool(final World p_149668_1_, final int p_149668_2_, final int p_149668_3_, final int p_149668_4_) {
|
||||
// return AxisAlignedBB.getBoundingBox(p_149668_2_ + 0, p_149668_3_ + 0, p_149668_4_ + 0, p_149668_2_ + 1, p_149668_3_ + 1, p_149668_4_ + 1);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isOpaqueCube() {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean renderAsNormalBlock() {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
|
||||
int meta = getMetaFromState(state);
|
||||
EnumMoisture moisture = EnumMoisture.values()[meta % 3];
|
||||
EnumAcidity acidity = EnumAcidity.values()[meta / 3];
|
||||
EnumMoisture desiredMoisture = Gardening.getNaturalMoisture(world, pos);
|
||||
if (desiredMoisture.ordinal() > moisture.ordinal()) {
|
||||
moisture = ((moisture == EnumMoisture.Dry) ? EnumMoisture.Normal : EnumMoisture.Damp);
|
||||
}
|
||||
if (desiredMoisture.ordinal() < moisture.ordinal()) {
|
||||
moisture = ((moisture == EnumMoisture.Damp) ? EnumMoisture.Normal : EnumMoisture.Dry);
|
||||
}
|
||||
int meta2 = getMeta(acidity, moisture);
|
||||
if (meta != meta2) {
|
||||
world.setBlockState(pos, getStateFromMeta(meta2), 2);
|
||||
}
|
||||
if (!this.weedKilled && rand.nextInt(5 - getType(world, pos).ordinal()) == 0 && world.getBlockState(pos.up()).getBlock() == Blocks.AIR) {
|
||||
world.setBlockState(pos.up(), Botany.plant.getStateFromMeta(BlockPlant.Type.Weeds.ordinal()), 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAcidity getPH(final World world, final BlockPos pos) {
|
||||
return world.getBlockState(pos).getValue(ACIDITY); //EnumAcidity.values()[world.getBlockMetadata(x, y, z) / 3];
|
||||
return world.getBlockState(pos).getValue(ACIDITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumMoisture getMoisture(final World world, final BlockPos pos) {
|
||||
return world.getBlockState(pos).getValue(MOISTURE); //EnumMoisture.values()[world.getBlockMetadata(x, y, z) % 3];
|
||||
return world.getBlockState(pos).getValue(MOISTURE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -185,14 +190,14 @@ public class BlockSoil extends Block implements IBlockSoil {
|
||||
|
||||
@Override
|
||||
public boolean setPH(final World world, final BlockPos pos, final EnumAcidity pH) {
|
||||
//final int meta = getMeta(pH, this.getMoisture(world, pos));
|
||||
return world.setBlockState(pos, world.getBlockState(pos).withProperty(ACIDITY, pH));//world.setBlockMetadataWithNotify(x, y, z, meta, 2);
|
||||
final int meta = getMeta(pH, this.getMoisture(world, pos));
|
||||
return world.setBlockState(pos, world.getBlockState(pos).withProperty(ACIDITY, pH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setMoisture(final World world, final BlockPos pos, final EnumMoisture moisture) {
|
||||
//final int meta = getMeta(this.getPH(world, x, y, z), moisture);
|
||||
return world.setBlockState(pos, world.getBlockState(pos).withProperty(MOISTURE, moisture));//return world.setBlockMetadataWithNotify(x, y, z, meta, 2);
|
||||
final int meta = getMeta(this.getPH(world, pos), moisture);
|
||||
return world.setBlockState(pos, world.getBlockState(pos).withProperty(MOISTURE, moisture));
|
||||
}
|
||||
|
||||
public static int getMeta(final EnumAcidity acid, final EnumMoisture moisture) {
|
||||
@@ -207,28 +212,32 @@ public class BlockSoil extends Block implements IBlockSoil {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPH(final ItemStack stack) {
|
||||
return Binnie.Language.localise(EnumAcidity.values()[stack.getItemDamage() / 3]);
|
||||
public static String getPH(ItemStack stack, boolean withColor) {
|
||||
return EnumAcidity.values()[stack.getItemDamage() / 3].getTranslated(withColor);
|
||||
}
|
||||
|
||||
public static String getMoisture(final ItemStack stack) {
|
||||
return Binnie.Language.localise(EnumMoisture.values()[stack.getItemDamage() % 3]);
|
||||
public static String getMoisture(ItemStack stack, boolean withColor) {
|
||||
return EnumMoisture.values()[stack.getItemDamage() % 3].getTranslated(withColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) {
|
||||
IBlockState plant = plantable.getPlant(world, pos.up());
|
||||
if (plant.getBlock() == Botany.flower) {
|
||||
return true;
|
||||
}
|
||||
if (plant.getBlock() == Botany.plant) {
|
||||
return !this.weedKilled || !BlockPlant.isWeed(world, pos);
|
||||
}
|
||||
return world instanceof World && Blocks.DIRT.canSustainPlant(state, world, pos, direction, plantable);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean canSustainPlant(final IBlockAccess world, final BlockPos pos, final EnumFacing direction, final IPlantable plantable) {
|
||||
// final Block plant = plantable.getPlant(world, x, y + 1, z);
|
||||
// if (plant == Botany.flower) {
|
||||
// return true;
|
||||
// }
|
||||
// if (plant == Botany.plant) {
|
||||
// return !this.weedKilled || !BlockPlant.isWeed(world, x, y, z);
|
||||
// }
|
||||
// return world instanceof World && Blocks.dirt.canSustainPlant(world, x, y, z, direction, plantable);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean resistsWeeds(final World world, final BlockPos pos) {
|
||||
return this.weedKilled;
|
||||
}
|
||||
|
||||
public boolean isWeedKilled() {
|
||||
return weedKilled;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ import binnie.core.BinnieCore;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -41,34 +43,34 @@ public class Gardening {
|
||||
return isSoil(item.getItem());
|
||||
}
|
||||
|
||||
// public static EnumMoisture getNaturalMoisture(final World world, final BlockPos pos) {
|
||||
// float bias = getBiomeMoisture(world.getBiome(pos), pos.getY());
|
||||
// for (int dx = -1; dx < 2; ++dx) {
|
||||
// for (int dz = -1; dz < 2; ++dz) {
|
||||
// if (dx != 0 || dz != 0) {
|
||||
// if (world.getBlock(x + dx, y, z + dz) == Blocks.sand) {
|
||||
// bias -= 1.5;
|
||||
// }
|
||||
// else if (world.getBlock(x + dx, y, z + dz) == Blocks.water) {
|
||||
// bias += 1.5;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (world.isRaining() && world.canBlockSeeTheSky(x, y + 1, z) && world.getPrecipitationHeight(x, z) <= y + 1) {
|
||||
// bias += 1.5;
|
||||
// }
|
||||
// for (int dx = -1; dx < 2; ++dx) {
|
||||
// for (int dz = -1; dz < 2; ++dz) {
|
||||
// if (dx != 0 || dz != 0) {
|
||||
// if (world.getBlock(x + dx, y, z + dz) == Blocks.gravel && bias > 0.0f) {
|
||||
// bias *= 0.4f;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return (bias <= -1.0f) ? EnumMoisture.Dry : ((bias >= 1.0f) ? EnumMoisture.Damp : EnumMoisture.Normal);
|
||||
// }
|
||||
public static EnumMoisture getNaturalMoisture(final World world, final BlockPos pos) {
|
||||
float bias = getBiomeMoisture(world.getBiome(pos), pos.getY());
|
||||
for (int dx = -1; dx < 2; ++dx) {
|
||||
for (int dz = -1; dz < 2; ++dz) {
|
||||
if (dx != 0 || dz != 0) {
|
||||
if (world.getBlockState(pos.add(dx, 0, dz)) == Blocks.SAND) {
|
||||
bias -= 1.5;
|
||||
}
|
||||
else if (world.getBlockState(pos.add(dx, 0, dz)) == Blocks.WATER) {
|
||||
bias += 1.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (world.isRaining() && world.canBlockSeeSky(pos.up()) && world.getPrecipitationHeight(pos).getY() <= pos.getY() + 1) {
|
||||
bias += 1.5;
|
||||
}
|
||||
for (int dx = -1; dx < 2; ++dx) {
|
||||
for (int dz = -1; dz < 2; ++dz) {
|
||||
if (dx != 0 || dz != 0) {
|
||||
if (world.getBlockState(pos.add(dx, 0, dz)).getBlock() == Blocks.GRAVEL && bias > 0.0f) {
|
||||
bias *= 0.4f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (bias <= -1.0f) ? EnumMoisture.Dry : ((bias >= 1.0f) ? EnumMoisture.Damp : EnumMoisture.Normal);
|
||||
}
|
||||
|
||||
public static EnumAcidity getNaturalPH(final World world, final BlockPos pos) {
|
||||
final float bias = getBiomePH(world.getBiome(pos), pos.getY());
|
||||
@@ -88,10 +90,10 @@ public class Gardening {
|
||||
return (float) (-3.0 * (R - 0.5) + 0.5 * (T - 0.699999988079071) * (T - 0.699999988079071) + 0.02f * (H - 64) - 0.15000000596046448);
|
||||
}
|
||||
|
||||
// public static void createSoil(final World world, final BlockPos pos, final EnumSoilType soil, final EnumMoisture moisture, final EnumAcidity acidity) {
|
||||
// final int meta = moisture.ordinal() + acidity.ordinal() * 3;
|
||||
// world.setBlockState(x, y, z, getSoilBlock(soil), meta, 2);
|
||||
// }
|
||||
public static void createSoil(final World world, final BlockPos pos, final EnumSoilType soil, final EnumMoisture moisture, final EnumAcidity acidity) {
|
||||
final int meta = moisture.ordinal() + acidity.ordinal() * 3;
|
||||
world.setBlockState(pos, getSoilBlock(soil).getStateFromMeta(meta), 2);
|
||||
}
|
||||
|
||||
public static boolean plant(final World world, final BlockPos pos, final IFlower flower, final GameProfile owner) {
|
||||
final boolean set = world.setBlockState(pos, Botany.flower.getDefaultState());
|
||||
@@ -194,22 +196,23 @@ public class Gardening {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// public static boolean canTolerate(final IFlower flower, final World world, final BlockPos pos) {
|
||||
// if (flower == null || flower.getGenome() == null) {
|
||||
// return false;
|
||||
// }
|
||||
// final Block soil = world.getBlock(x, y - 1, z);
|
||||
// final int soilMeta = world.getBlockMetadata(x, y - 1, z);
|
||||
// final BiomeGenBase biome = world.getBiomeGenForCoords(x, z);
|
||||
// return canTolerate(flower, EnumAcidity.values()[soilMeta / 3 % 3], EnumMoisture.values()[soilMeta % 3], EnumTemperature.getFromValue(biome.temperature));
|
||||
// }
|
||||
//
|
||||
// public static EnumSoilType getSoilType(final World world, final BlockPos pos) {
|
||||
// if (world.getBlock(x, y, z) instanceof IBlockSoil) {
|
||||
// return ((IBlockSoil) world.getBlock(x, y, z)).getType(world, x, y, z);
|
||||
// }
|
||||
// return EnumSoilType.SOIL;
|
||||
// }
|
||||
public static boolean canTolerate(final IFlower flower, final World world, final BlockPos pos) {
|
||||
if (flower == null || flower.getGenome() == null) {
|
||||
return false;
|
||||
}
|
||||
IBlockState soil = world.getBlockState(pos.down());
|
||||
final Block soilBlock = soil.getBlock();
|
||||
final int soilMeta = soilBlock.getMetaFromState(soil);
|
||||
final Biome biome = world.getBiome(pos);
|
||||
return canTolerate(flower, EnumAcidity.values()[soilMeta / 3 % 3], EnumMoisture.values()[soilMeta % 3], EnumTemperature.getFromValue(biome.getTemperature()));
|
||||
}
|
||||
|
||||
public static EnumSoilType getSoilType(final World world, final BlockPos pos) {
|
||||
if (world.getBlockState(pos).getBlock() instanceof IBlockSoil) {
|
||||
return ((IBlockSoil) world.getBlockState(pos).getBlock()).getType(world, pos);
|
||||
}
|
||||
return EnumSoilType.SOIL;
|
||||
}
|
||||
|
||||
public static Block getSoilBlock(final EnumSoilType type) {
|
||||
return getSoilBlock(type, false);
|
||||
@@ -229,26 +232,28 @@ public class Gardening {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canTolerate(final IFlower flower, final EnumAcidity ePH, final EnumMoisture eMoisture, final EnumTemperature eTemp) {
|
||||
public static boolean canTolerate(IFlower flower, EnumAcidity ePH, EnumMoisture eMoisture, EnumTemperature eTemp) {
|
||||
return flower.getGenome().canTolerate(ePH) && flower.getGenome().canTolerate(eMoisture) && flower.getGenome().canTolerate(eTemp);
|
||||
}
|
||||
|
||||
public static boolean isWeedkiller(final ItemStack heldItem) {
|
||||
public static boolean isWeedkiller(ItemStack heldItem) {
|
||||
return heldItem != null && heldItem.isItemEqual(BotanyItems.Weedkiller.get(1));
|
||||
}
|
||||
|
||||
// public static boolean addWeedKiller(final World world, final BlockPos pos) {
|
||||
// if (!(world.getBlockState(pos).getBlock() instanceof IBlockSoil)) {
|
||||
// return false;
|
||||
// }
|
||||
// final EnumSoilType type = getSoilType(world, pos);
|
||||
// final Block block = getSoilBlock(type, true);
|
||||
// final boolean done = world.setBlock(x, y, z, block, world.getBlockMetadata(x, y, z), 2);
|
||||
// if (done && BlockPlant.isWeed(world, pos.up())) {
|
||||
// world.setBlockToAir(pos.up());
|
||||
// }
|
||||
// return done;
|
||||
// }
|
||||
public static boolean addWeedKiller(World world, BlockPos pos) {
|
||||
if (!(world.getBlockState(pos).getBlock() instanceof IBlockSoil)) {
|
||||
return false;
|
||||
}
|
||||
EnumSoilType type = getSoilType(world, pos);
|
||||
Block block = getSoilBlock(type, true);
|
||||
IBlockState oldState = world.getBlockState(pos);
|
||||
IBlockState newState = block.getStateFromMeta(oldState.getBlock().getMetaFromState(oldState));
|
||||
boolean done = world.setBlockState(pos, newState, 2);
|
||||
if (done && BlockPlant.isWeed(world, pos.up())) {
|
||||
world.setBlockToAir(pos.up());
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
static {
|
||||
Gardening.fertiliserAcid = new LinkedHashMap<>();
|
||||
|
||||
@@ -1,61 +1,48 @@
|
||||
package binnie.botany.gardening;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.botany.api.EnumAcidity;
|
||||
import binnie.botany.api.EnumMoisture;
|
||||
import binnie.botany.api.EnumSoilType;
|
||||
import forestry.core.utils.Translator;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSoil extends ItemBlock {
|
||||
EnumSoilType type;
|
||||
private boolean noWeed;
|
||||
private final EnumSoilType type;
|
||||
private final boolean noWeed;
|
||||
|
||||
public ItemSoil(BlockSoil block) {
|
||||
super(block);
|
||||
this.type = block.getType();
|
||||
this.noWeed = block.isWeedKilled();
|
||||
this.hasSubtypes = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(final ItemStack stack, final EntityPlayer playerIn, final List tooltip, final boolean advanced) {
|
||||
super.addInformation(stack, playerIn, tooltip, advanced);
|
||||
final EnumMoisture moisture = EnumMoisture.values()[stack.getItemDamage() % 3];
|
||||
final EnumAcidity acidity = EnumAcidity.values()[stack.getItemDamage() / 3];
|
||||
String info = "";
|
||||
if (moisture == EnumMoisture.Dry) {
|
||||
info += "§eDry§f";
|
||||
}
|
||||
if (moisture == EnumMoisture.Damp) {
|
||||
info += "§9Damp§f";
|
||||
}
|
||||
if (acidity == EnumAcidity.Acid) {
|
||||
if (info.length() > 0) {
|
||||
info += ", ";
|
||||
}
|
||||
info += "§cAcidic§f";
|
||||
}
|
||||
if (acidity == EnumAcidity.Alkaline) {
|
||||
if (info.length() > 0) {
|
||||
info += ", ";
|
||||
}
|
||||
info += "§bAlkaline§f";
|
||||
info+=BlockSoil.getMoisture(stack, true);
|
||||
if (info.length() > 0) {
|
||||
info += ", ";
|
||||
}
|
||||
info+=BlockSoil.getPH(stack, true);
|
||||
if (info.length() > 0) {
|
||||
tooltip.add(info);
|
||||
}
|
||||
if (this.noWeed) {
|
||||
tooltip.add("Weedkiller");
|
||||
tooltip.add(TextFormatting.GREEN + Binnie.Language.localise("botany.soil.weedkiller"));
|
||||
}
|
||||
}
|
||||
|
||||
public ItemSoil(final Block block) {
|
||||
super(block);
|
||||
this.type = ((BlockSoil) this.block).getType();
|
||||
this.noWeed = ((BlockSoil) this.block).weedKilled;
|
||||
this.hasSubtypes = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack stack) {
|
||||
return this.type.name().substring(0, 1) + this.type.name().toLowerCase().substring(1);
|
||||
|
||||
+4
-5
@@ -5,7 +5,6 @@ import javax.annotation.Nonnull;
|
||||
import binnie.genetics.integration.jei.GeneticsJeiPlugin;
|
||||
import binnie.genetics.integration.jei.RecipeUids;
|
||||
import binnie.genetics.machine.Incubator;
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
@@ -19,15 +18,15 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class IncubatorRecipeCategory extends BlankRecipeCategory {
|
||||
|
||||
@Nonnull
|
||||
private final IDrawable tank;
|
||||
@Nonnull
|
||||
private final IDrawable tankOverlay;
|
||||
@Nonnull
|
||||
private final ResourceLocation guiTank = new ResourceLocation("binniecore:textures/gui/craftgui-slots.png");
|
||||
@Nonnull
|
||||
private final ResourceLocation guiArrow = new ResourceLocation("binniecore:textures/gui/craftgui-panels.png");
|
||||
|
||||
@Nonnull
|
||||
private final IDrawable tank;
|
||||
@Nonnull
|
||||
private final IDrawable tankOverlay;
|
||||
@Nonnull
|
||||
private final IDrawable arrow;
|
||||
@Nonnull
|
||||
|
||||
Reference in new issue
Block a user