diff --git a/.gitignore b/.gitignore index 0e02516..6f247fb 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ src/btw/** **/run/ /release +/libs diff --git a/build.gradle b/build.gradle index 1ff26e9..9ec34cb 100644 --- a/build.gradle +++ b/build.gradle @@ -66,8 +66,12 @@ dependencies { modImplementation("io.github.minecraft-cursed-legacy:cursed-fabric-loader:${loader_version}") { transitive false } + + compileOnly fileTree(dir: "libs", include: "Deco-Addon-4.1.2.jar") } + + loom { accessWidener = file("src/main/resources/sockscrops.accesswidener") } diff --git a/gradle.properties b/gradle.properties index 6b0eca9..a7a30e4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version = 1.5.2 yarn_mappings = 1.5.2+build.202201092137 loader_version = 1.0.0 -mod_version = 2.0.0 +mod_version = 2.0.0 Prerelease 1 maven_group = net.fabricmc archives_base_name = socks-crops-addon diff --git a/src/main/java/btw/community/sockthing/sockscrops/SocksCropsAddon.java b/src/main/java/btw/community/sockthing/sockscrops/SocksCropsAddon.java index 2e55813..25ce82d 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/SocksCropsAddon.java +++ b/src/main/java/btw/community/sockthing/sockscrops/SocksCropsAddon.java @@ -52,5 +52,17 @@ public static SocksCropsAddon getInstance() { return instance; } + public static boolean isDecoInstalled() { + return AddonHandler.isModInstalled("Deco Addon"); + } + + public static boolean isBTAInstalled() { + return AddonHandler.isModInstalled("Better Terrain"); + } + + public static boolean isBBInstalled() { + return AddonHandler.isModInstalled("Better Biomes"); + } + } diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/SCBlockIDs.java b/src/main/java/btw/community/sockthing/sockscrops/block/SCBlockIDs.java index 8b98839..8e4d105 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/block/SCBlockIDs.java +++ b/src/main/java/btw/community/sockthing/sockscrops/block/SCBlockIDs.java @@ -2,43 +2,95 @@ public class SCBlockIDs { +//2600 - 2629 Nutrition +//2630 - 2049 Planters +//2650 - 2689 Plants +//2690 - 2694 Moss +//2695 - 2699 Hollow Logs +//2700 - 2704 Berries +//2705 - 2799 Crops +//2800 - 2849 Misc +//2850 - 2899 Tile Entities + + //----------- Grass -----------// - public static final int GRASS_NUTRITION_ID = 2625; + public static final int GRASS_NUTRITION_ID = 2600; //----------- Farmland -----------// - public static final int FARMLAND_FULL_NUTRITION_ID = 2626; - public static final int FARMLAND_REDUCED_NUTRITION_ID = 2627; - public static final int FARMLAND_LOW_NUTRITION_ID = 2628; - public static final int FARMLAND_DEPLETED_NUTRITION_ID = 2629; - - public static final int FARMLAND_FERTILIZED_FULL_NUTRITION_ID = 2630; - public static final int FARMLAND_FERTILIZED_REDUCED_NUTRITION_ID = 2631; - public static final int FARMLAND_FERTILIZED_LOW_NUTRITION_ID = 2632; - public static final int FARMLAND_FERTILIZED_DEPLETED_NUTRITION_ID = 2633; - - public static final int FARMLAND_DUNG_FULL_NUTRITION_ID = 2634; - public static final int FARMLAND_DUNG_REDUCED_NUTRITION_ID = 2635; - public static final int FARMLAND_DUNG_LOW_NUTRITION_ID = 2636; - public static final int FARMLAND_DUNG_DEPLETED_NUTRITION_ID = 2637; - - public static final int FARMLAND_MULCH_FULL_NUTRITION_ID = 2638; - public static final int FARMLAND_MULCH_REDUCED_NUTRITION_ID = 2639; - public static final int FARMLAND_MULCH_LOW_NUTRITION_ID = 2640; - public static final int FARMLAND_MULCH_DEPLETED_NUTRITION_ID = 2641; + public static final int FARMLAND_FULL_NUTRITION_ID = 2601; + public static final int FARMLAND_REDUCED_NUTRITION_ID = 2602; + public static final int FARMLAND_LOW_NUTRITION_ID = 2603; + public static final int FARMLAND_DEPLETED_NUTRITION_ID = 2604; - //----------- Planters -----------// - public static final int GRASS_PLANTER_ID = 2646; - public static final int FARMLAND_PLANTER_ID = 2647; - public static final int FERTILIZED_PLANTER_ID = 2648; - public static final int DUNG_PLANTER_ID = 2649; + public static final int FARMLAND_FERTILIZED_FULL_NUTRITION_ID = 2605; + public static final int FARMLAND_FERTILIZED_REDUCED_NUTRITION_ID = 2606; + public static final int FARMLAND_FERTILIZED_LOW_NUTRITION_ID = 2607; + public static final int FARMLAND_FERTILIZED_DEPLETED_NUTRITION_ID = 2608; + + public static final int FARMLAND_DUNG_FULL_NUTRITION_ID = 2609; + public static final int FARMLAND_DUNG_REDUCED_NUTRITION_ID = 2610; + public static final int FARMLAND_DUNG_LOW_NUTRITION_ID = 2611; + public static final int FARMLAND_DUNG_DEPLETED_NUTRITION_ID = 2612; + + public static final int FARMLAND_MULCH_FULL_NUTRITION_ID = 2613; + public static final int FARMLAND_MULCH_REDUCED_NUTRITION_ID = 2614; + public static final int FARMLAND_MULCH_LOW_NUTRITION_ID = 2615; + public static final int FARMLAND_MULCH_DEPLETED_NUTRITION_ID = 2616; //----------- Planters -----------// - public static final int DOUBLE_TALL_GRASS_ID = 2657; + public static final int GRASS_PLANTER_ID = 2630; + public static final int FARMLAND_PLANTER_ID = 2631; + public static final int FERTILIZED_PLANTER_ID = 2632; + public static final int DUNG_PLANTER_ID = 2633; + + //----------- Plants -----------// + public static final int CLOVER_ID = 2650; + public static final int PURPLE_CLOVER_ID = 2651; + public static final int WHITE_CLOVER_ID = 2652; + public static final int RED_CLOVER_ID = 2653; + public static final int MUTLIFLOWER_ID = 2654; + public static final int SIDESHROOM_ID = 2655; + public static final int SHORT_GRASS_ID = 2656; + public static final int DOUBLE_TALL_PLANT_ID = 2657; //overlap with deco + public static final int DOUBLE_TALL_FLOWER_ID = 2658; + public static final int SHORT_WATER_PLANT_ID = 2659; + public static final int TALL_WATER_PLANT_ID = 2660; + public static final int FLOWER_LILY_ID = 2661; + + public static final int WICKER_GROWN_ID = 2680; + public static final int GRATE_GROWN_ID = 2681; + public static final int SLATS_GROWN_ID = 2682; + public static final int IRON_BARS_GROWN_ID = 2683; + public static final int WROUGHT_BARS_GROWN_ID = 2684; + + public static final int MOSS_CARPET_ID = 2690; + public static final int MOSS_BLOCK_ID = 2691; + + //----------- Hollow Logs -----------// + public static final int HOLLOW_LOG_ID = 2695; + public static final int HOLLOW_LOG_2_ID = 2696; + public static final int DECO_HOLLOW_LOG_ID = 2697; + public static final int DECO_HOLLOW_LOG_2_ID = 2698; + public static final int DECO_HOLLOW_LOG_3_ID = 2699; + + //----------- Bushes -----------// + public static final int SWEETBERRY_BUSH_ID = 2700; + public static final int BLUEBERRY_BUSH_ID = 2701; + + //----------- Sunflower -----------// + public static final int SUNFLOWER_CROP_ID = 2705; + public static final int SUNFLOWER_CROP_TOP_ID = 2706; //----------- Hay -----------// - public static final int DRYING_HAY_ID = 2825; - public static final int DRIED_HAY_ID = 2826; - public static final int HAY_BALE_ID = 2827; - public static final int STRAW_BALE_ID = 3025; // copy of deco, ID overlap + public static final int DRYING_HAY_ID = 2800; + public static final int DRIED_HAY_ID = 2801; + public static final int HAY_BALE_ID = 2802; + public static final int SMALL_PACKED_BLOCK_ID = 2803; + + public static final int LARGE_FLOWERPOT_ID = 2805; + public static final int FLOWERPOT_ID = 2806; + + //----------- Deco Overlap -----------// + public static final int STRAW_BALE_ID = 3025; } diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/SCBlocks.java b/src/main/java/btw/community/sockthing/sockscrops/block/SCBlocks.java index 8b69b80..f97b95f 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/block/SCBlocks.java +++ b/src/main/java/btw/community/sockthing/sockscrops/block/SCBlocks.java @@ -1,13 +1,33 @@ package btw.community.sockthing.sockscrops.block; import btw.block.BTWBlocks; +import btw.community.sockthing.sockscrops.SocksCropsAddon; import btw.community.sockthing.sockscrops.block.blocks.*; +import btw.community.sockthing.sockscrops.block.tileentities.FlowerPotTileEntity; import btw.community.sockthing.sockscrops.block.tileentities.HayDryingTileEntity; +import btw.community.sockthing.sockscrops.block.tileentities.LargeFlowerPotTileEntity; +import btw.community.sockthing.sockscrops.item.SCItemIDs; +import btw.community.sockthing.sockscrops.item.items.DoubleTallWaterPlantItem; +import btw.community.sockthing.sockscrops.item.items.FlowerLilyItem; +import btw.community.sockthing.sockscrops.item.items.SideShroomItemBlock; +import btw.community.sockthing.sockscrops.item.items.WaterPlantItem; +import btw.community.sockthing.sockscrops.mixins.PlaceAsBlockItemAccessor; import btw.community.sockthing.sockscrops.utils.NutritionUtils; +import btw.item.items.PlaceAsBlockItem; import net.minecraft.src.*; public class SCBlocks { +// 2600 - 2629 Nutrition +// 2630 - 2049 Planters +// 2650 - 2689 Plants +// 2690 - 2694 Moss +// 2695 - 2699 Hollow Logs +// 2700 - 2704 Berries +// 2705 - 2799 Crops +// 2800 - 2849 Misc +// 2850 - 2899 Tile Entities + //----------- Grass -----------// public static Block grassNutrition; @@ -39,29 +59,66 @@ public class SCBlocks { public static Block planterFarmlandDung; //----------- Plants -----------// - public static Block doubleTallGrass; + public static Block tallFlower; + public static Block doubleTallPlant; + public static Block shortGrass; + public static Block multiFlower; + public static Block clover; + public static Block cloverPurple; + public static Block cloverWhite; + public static Block cloverRed; + public static Block sideShroom; + public static Block flowerLily; + public static Block shortWaterPlant; + public static Block tallWaterPlant; + + //----------- Decorative -----------// + public static Block grownWicker; + public static Block grownSlats; + public static Block grownGrate; + public static Block grownIronBars; + public static Block grownWroughtBars; + public static Block mossCarpet; + public static Block mossBlock; + public static Block hollowLog; + public static Block hollowLog2; + public static Block decoHollowLog; + public static Block decoHollowLog2; + public static Block decoHollowLog3; + + //----------- Bushes -----------// + public static Block sweetberryBush; + public static Block blueberryBush; + + //----------- Sunflower -----------// + public static Block sunflowerCrop; + public static Block sunflowerTopCrop; //----------- Hay -----------// public static Block dryingHay; public static Block driedHay; public static Block hayBale; public static Block strawBale; + public static Block smallPackedBlock; + public static Block largeFlowerpot; + public static Block flowerPot; + + public static void initBlocks() { + initVanillaOverrides(); + initTileEnityMapping(); initPlantBlocks(); + initCropBlocks(); + initBushBlocks(); initNutritionBlocks(); initHayBlocks(); - } - - private static void initTileEnityMapping() { - TileEntity.addMapping(HayDryingTileEntity.class, "SCHayDrying"); - } - - private static void initPlantBlocks() { - doubleTallGrass = new DoubleTallGrassBlock(SCBlockIDs.DOUBLE_TALL_GRASS_ID, "scBlockDoubleTallPlant"); - Item.itemsList[doubleTallGrass.blockID] = new ItemMultiTextureTile(SCBlockIDs.DOUBLE_TALL_GRASS_ID - 256, doubleTallGrass, - new String[]{"grass", "fern"}); + initPackedBlocks(); + initMossBlocks(); + initHollowLogs(); + initGrownPanes(); + initFlowerPots(); } private static void initNutritionBlocks() { @@ -70,11 +127,10 @@ private static void initNutritionBlocks() { initPlanterBlocks(); } - private static void initDirtRelatedBlocks() { - //----------- Grass -----------// - grassNutrition = new GrassNutritionBlock(SCBlockIDs.GRASS_NUTRITION_ID, "scBlockGrassNutrition"); - Item.itemsList[grassNutrition.blockID] = new ItemMultiTextureTile(SCBlockIDs.GRASS_NUTRITION_ID - 256, grassNutrition, - NutritionUtils.GRASS_TEXTURE_NAMES); + private static void initVanillaOverrides() { + //----------- Dandilion -----------// + Item.itemsList[Block.plantYellow.blockID] = new ItemMultiTextureTile(Block.plantYellow.blockID - 256, Block.plantYellow, + new String[]{"flower", "dandilion"}); //----------- Dirt -----------// Item.itemsList[Block.dirt.blockID] = new ItemMultiTextureTile(Block.dirt.blockID - 256, Block.dirt, @@ -86,91 +142,228 @@ private static void initDirtRelatedBlocks() { //----------- Vanilla Farmland Overrides -----------// Item.itemsList[BTWBlocks.farmland.blockID].setCreativeTab(null); Item.itemsList[BTWBlocks.fertilizedFarmland.blockID].setCreativeTab(null); + + } + + private static void initTileEnityMapping() { + TileEntity.addMapping(HayDryingTileEntity.class, "SCHayDrying"); + TileEntity.addMapping(LargeFlowerPotTileEntity.class, "SCLargeFlowerpot"); + TileEntity.addMapping(FlowerPotTileEntity.class, "SCFlowerPot"); + } + + private static void initPlantBlocks() { + if (!SocksCropsAddon.isDecoInstalled()){ + doubleTallPlant = new DoubleTallPlantBlock(SCBlockIDs.DOUBLE_TALL_PLANT_ID, "tall_plant"); + Item.itemsList[doubleTallPlant.blockID] = new ItemMultiTextureTile(SCBlockIDs.DOUBLE_TALL_PLANT_ID - 256, doubleTallPlant, + DoubleTallPlantBlock.types); + } + + tallFlower = new DoubleTallFlowerBlock(SCBlockIDs.DOUBLE_TALL_FLOWER_ID, "tall_flower"); +// Item.itemsList[tallFlower.blockID] = new ItemMultiTextureTile(SCBlockIDs.TALL_FLOWER_ID - 256, tallFlower, +// new String[]{"", "", "sunflower"}); + + shortGrass = new ShortGrassBlock(SCBlockIDs.SHORT_GRASS_ID, "short_grass"); + Item.itemsList[shortGrass.blockID] = new ItemMultiTextureTile(SCBlockIDs.SHORT_GRASS_ID - 256, shortGrass, + new String[]{"", "grass"}); + +// multiFlower = new MultiFlowerBlock(SCBlockIDs.MUTLIFLOWER_ID); +// Item.itemsList[multiFlower.blockID] = new ItemBlock(SCBlockIDs.MUTLIFLOWER_ID - 256); + + clover = new CloverBlock(SCBlockIDs.CLOVER_ID, 0, "clover"); + Item.itemsList[clover.blockID] = new ItemBlock(SCBlockIDs.CLOVER_ID - 256); + + cloverPurple = new CloverBlock(SCBlockIDs.PURPLE_CLOVER_ID, 1, "clover_purple"); + Item.itemsList[cloverPurple.blockID] = new ItemBlock(SCBlockIDs.PURPLE_CLOVER_ID - 256); + + cloverWhite = new CloverBlock(SCBlockIDs.WHITE_CLOVER_ID, 2, "clover_white"); + Item.itemsList[cloverWhite.blockID] = new ItemBlock(SCBlockIDs.WHITE_CLOVER_ID - 256); + + cloverRed = new CloverBlock(SCBlockIDs.RED_CLOVER_ID, 3, "clover_red"); + Item.itemsList[cloverRed.blockID] = new ItemBlock(SCBlockIDs.RED_CLOVER_ID - 256); + + sideShroom = new SideShroomBlock(SCBlockIDs.SIDESHROOM_ID, "sideshroom"); + Item.itemsList[sideShroom.blockID] = new SideShroomItemBlock(SCBlockIDs.SIDESHROOM_ID - 256, sideShroom, SideShroomItemBlock.names); + + flowerLily = new FlowerLilyBlock(SCBlockIDs.FLOWER_LILY_ID, "lilyRose"); + Item.itemsList[flowerLily.blockID] = new FlowerLilyItem(SCBlockIDs.FLOWER_LILY_ID - 256, flowerLily, FlowerLilyBlock.types); + + shortWaterPlant = new WaterPlantBlock(SCBlockIDs.SHORT_WATER_PLANT_ID, "waterPlantShort"); + Item.itemsList[shortWaterPlant.blockID] = new WaterPlantItem(SCBlockIDs.SHORT_WATER_PLANT_ID - 256, shortWaterPlant, WaterPlantBlock.types); + + tallWaterPlant = new DoubleTallWaterPlantBlock(SCBlockIDs.TALL_WATER_PLANT_ID, "waterPlantTall"); + Item.itemsList[tallWaterPlant.blockID] = new DoubleTallWaterPlantItem(SCBlockIDs.TALL_WATER_PLANT_ID - 256, tallWaterPlant, DoubleTallWaterPlantBlock.types); + } + + private static void initCropBlocks() { + sunflowerCrop = new SunflowerCropBlock(SCBlockIDs.SUNFLOWER_CROP_ID, "sunflower_bottom"); + sunflowerTopCrop = new SunflowerCropTopBlock(SCBlockIDs.SUNFLOWER_CROP_TOP_ID, "sunflower_top"); + } + + private static void initBushBlocks() { + sweetberryBush = new BerryBushBlock(SCBlockIDs.SWEETBERRY_BUSH_ID, SCItemIDs.SWEETBERRY_ID, SCItemIDs.SWEETBERRY_ROOTS_ID, + "sweetberry"); + + blueberryBush = new BerryBushBlock(SCBlockIDs.BLUEBERRY_BUSH_ID, SCItemIDs.BLUEBERRY_ID, SCItemIDs.BLUEBERRY_ROOTS_ID, + "blueberry"); + } + + private static void initHayBlocks() { + dryingHay = new HayDryingBlock(SCBlockIDs.DRYING_HAY_ID, "hay_drying"); + Item.itemsList[dryingHay.blockID] = new ItemBlock(SCBlockIDs.DRYING_HAY_ID - 256); + + driedHay = new HayDriedBlock(SCBlockIDs.DRIED_HAY_ID, "hay_dried"); + Item.itemsList[driedHay.blockID] = new ItemBlock(SCBlockIDs.DRIED_HAY_ID - 256); + + hayBale = new HayBaleBlock(SCBlockIDs.HAY_BALE_ID, "bale_hay"); + Item.itemsList[hayBale.blockID] = new ItemBlock(SCBlockIDs.HAY_BALE_ID - 256); + + if (!SocksCropsAddon.isDecoInstalled()){ + strawBale = new StrawBaleBlock(SCBlockIDs.STRAW_BALE_ID, "bale_straw"); + Item.itemsList[strawBale.blockID] = new ItemBlock(SCBlockIDs.STRAW_BALE_ID - 256); + } + } + + private static void initGrownPanes() { +// grownGrate = new GrownPaneBlock(SCBlockIDs.GRATE_GROWN_ID, "grown_grate", +// "fcBlockGrate", "fcBlockGrate", +// BTWBlocks.gratePane.blockID, 0); + } + + private static void initMossBlocks() { + mossCarpet = new MossCarpetBlock(SCBlockIDs.MOSS_CARPET_ID); + Item.itemsList[mossCarpet.blockID] = new PlaceAsBlockItem(SCBlockIDs.MOSS_CARPET_ID - 256, mossCarpet.blockID) + .setUnlocalizedName("moss_carpet").setCreativeTab(CreativeTabs.tabDecorations); + + mossBlock = new MossBlock(SCBlockIDs.MOSS_BLOCK_ID, "moss_block"); + Item.itemsList[mossBlock.blockID] = new ItemBlock(SCBlockIDs.MOSS_BLOCK_ID - 256); + } + + private static void initHollowLogs() { + hollowLog = new HollowLogBlock(SCBlockIDs.HOLLOW_LOG_ID, "hollow_log", + HollowLogBlock.treeTextureTop, + HollowLogBlock.treeTextureInner, + HollowLogBlock.treeTextureSide); + Item.itemsList[hollowLog.blockID] = new ItemMultiTextureTile(SCBlockIDs.HOLLOW_LOG_ID - 256, hollowLog, HollowLogBlock.treeTypes); + + hollowLog2 = new HollowLogBlock(SCBlockIDs.HOLLOW_LOG_2_ID, "hollow_log", + HollowLogBlock.treeTextureTop2, + HollowLogBlock.treeTextureInner2, + HollowLogBlock.treeTextureSide2); + Item.itemsList[hollowLog2.blockID] = new ItemMultiTextureTile(SCBlockIDs.HOLLOW_LOG_2_ID - 256, hollowLog2, HollowLogBlock.treeTypes2); + + if (SocksCropsAddon.isDecoInstalled()) + { + decoHollowLog = new HollowLogBlock(SCBlockIDs.DECO_HOLLOW_LOG_ID, "hollow_log", + new String[]{"hollow_log_darkoak_top","hollow_log_acacia_top","hollow_log_mahogany_top","hollow_log_mangrove_top"}, + new String[]{"decoBlockStrippedDarkOak_side","decoBlockStrippedAcacia_side","decoBlockStrippedMahogany_side","decoBlockStrippedMangrove_side"}, + new String[]{"decoBlockLogDarkOak_side","decoBlockLogAcacia_side","decoBlockLogMahogany_side","decoBlockLogMangrove_side"}); + Item.itemsList[decoHollowLog.blockID] = new ItemMultiTextureTile(SCBlockIDs.DECO_HOLLOW_LOG_ID - 256, decoHollowLog, HollowLogBlock.decoTreeTypes); + + decoHollowLog2 = new HollowLogBlock(SCBlockIDs.DECO_HOLLOW_LOG_2_ID, "hollow_log", + new String[]{"hollow_log_hazel_top","hollow_log_fir_top","hollow_log_aspen_top","hollow_log_willow_top"}, + new String[]{"decoBlockStrippedHazel_side","decoBlockStrippedFir_side","decoBlockStrippedAspen_side","decoBlockStrippedWillow_side"}, + new String[]{"decoBlockLogHazel_side","decoBlockLogFir_side","decoBlockLogAspen_side","decoBlockLogWillow_side"}); + Item.itemsList[decoHollowLog2.blockID] = new ItemMultiTextureTile(SCBlockIDs.DECO_HOLLOW_LOG_2_ID - 256, decoHollowLog2, HollowLogBlock.decoTreeTypes2); + + decoHollowLog3 = new HollowLogBlock(SCBlockIDs.DECO_HOLLOW_LOG_3_ID, "hollow_log", + new String[]{"hollow_log_cherry_top","hollow_log_redwood_top"}, + new String[]{"decoBlockStrippedCherry_side","decoBlockStrippedRedwood_side"}, + new String[]{"decoBlockLogCherry_side","decoBlockLogRedwood_side"}); + Item.itemsList[decoHollowLog3.blockID] = new ItemMultiTextureTile(SCBlockIDs.DECO_HOLLOW_LOG_3_ID - 256, decoHollowLog3, HollowLogBlock.decoTreeTypes3); + + } + } + + private static void initPackedBlocks() { + smallPackedBlock = new PackedBlock(SCBlockIDs.SMALL_PACKED_BLOCK_ID, Material.leaves,"packed"); + + Item.itemsList[smallPackedBlock.blockID] = new ItemMultiTextureTile(SCBlockIDs.SMALL_PACKED_BLOCK_ID - 256, smallPackedBlock, + PackedBlock.types); + } + + private static void initFlowerPots() { + largeFlowerpot = new LargeFlowerpotBlock(SCBlockIDs.LARGE_FLOWERPOT_ID, "large_flowerpot"); + + flowerPot = new FlowerpotBlock(SCBlockIDs.FLOWERPOT_ID); + } + + private static void initDirtRelatedBlocks() { + //----------- Grass -----------// + grassNutrition = new GrassNutritionBlock(SCBlockIDs.GRASS_NUTRITION_ID, "grassNutrition"); + Item.itemsList[grassNutrition.blockID] = new ItemMultiTextureTile(SCBlockIDs.GRASS_NUTRITION_ID - 256, grassNutrition, + NutritionUtils.GRASS_TEXTURE_NAMES); } private static void initFarmlandBlocks() { + //----------- Farmland -----------// - farmlandFullNutrition = new FarmlandFullNutritionBlock(SCBlockIDs.FARMLAND_FULL_NUTRITION_ID, "scBlockFarmlandNutrition_full"); + farmlandFullNutrition = new FarmlandFullNutritionBlock(SCBlockIDs.FARMLAND_FULL_NUTRITION_ID, "farmlandNutrition_full"); Item.itemsList[farmlandFullNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_FULL_NUTRITION_ID - 256); - farmlandReducedNutrition = new FarmlandReducedNutritionBlock(SCBlockIDs.FARMLAND_REDUCED_NUTRITION_ID, "scBlockFarmlandNutrition_reduced"); + farmlandReducedNutrition = new FarmlandReducedNutritionBlock(SCBlockIDs.FARMLAND_REDUCED_NUTRITION_ID, "farmlandNutrition_reduced"); Item.itemsList[farmlandReducedNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_REDUCED_NUTRITION_ID - 256); - farmlandLowNutrition = new FarmlandLowNutritionBlock(SCBlockIDs.FARMLAND_LOW_NUTRITION_ID, "scBlockFarmlandNutrition_low"); + farmlandLowNutrition = new FarmlandLowNutritionBlock(SCBlockIDs.FARMLAND_LOW_NUTRITION_ID, "farmlandNutrition_low"); Item.itemsList[farmlandLowNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_LOW_NUTRITION_ID - 256); - farmlandDepletedNutrition = new FarmlandDepletedNutritionBlock(SCBlockIDs.FARMLAND_DEPLETED_NUTRITION_ID, "scBlockFarmlandNutrition_depleted"); + farmlandDepletedNutrition = new FarmlandDepletedNutritionBlock(SCBlockIDs.FARMLAND_DEPLETED_NUTRITION_ID, "farmlandNutrition_depleted"); Item.itemsList[farmlandDepletedNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_DEPLETED_NUTRITION_ID - 256); //----------- Farmland Fertilized -----------// - farmlandFertilizedFullNutrition = new FarmlandFertilizedFullNutritionBlock(SCBlockIDs.FARMLAND_FERTILIZED_FULL_NUTRITION_ID, "scBlockFarmlandFertilizedNutrition_full"); + farmlandFertilizedFullNutrition = new FarmlandFertilizedFullNutritionBlock(SCBlockIDs.FARMLAND_FERTILIZED_FULL_NUTRITION_ID, "farmlandFertilizedNutrition_full"); Item.itemsList[farmlandFertilizedFullNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_FERTILIZED_FULL_NUTRITION_ID - 256); - farmlandFertilizedReducedNutrition = new FarmlandFertilizedReducedNutritionBlock(SCBlockIDs.FARMLAND_FERTILIZED_REDUCED_NUTRITION_ID, "scBlockFarmlandFertilizedNutrition_reduced"); + farmlandFertilizedReducedNutrition = new FarmlandFertilizedReducedNutritionBlock(SCBlockIDs.FARMLAND_FERTILIZED_REDUCED_NUTRITION_ID, "farmlandFertilizedNutrition_reduced"); Item.itemsList[farmlandFertilizedReducedNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_FERTILIZED_REDUCED_NUTRITION_ID - 256); - farmlandFertilizedLowNutrition = new FarmlandFertilizedLowNutritionBlock(SCBlockIDs.FARMLAND_FERTILIZED_LOW_NUTRITION_ID, "scBlockFarmlandFertilizedNutrition_low"); + farmlandFertilizedLowNutrition = new FarmlandFertilizedLowNutritionBlock(SCBlockIDs.FARMLAND_FERTILIZED_LOW_NUTRITION_ID, "farmlandFertilizedNutrition_low"); Item.itemsList[farmlandFertilizedLowNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_FERTILIZED_LOW_NUTRITION_ID - 256); - farmlandFertilizedDepletedNutrition = new FarmlandFertilizedDepletedNutritionBlock(SCBlockIDs.FARMLAND_FERTILIZED_DEPLETED_NUTRITION_ID, "scBlockFarmlandFertilizedNutrition_depleted"); + farmlandFertilizedDepletedNutrition = new FarmlandFertilizedDepletedNutritionBlock(SCBlockIDs.FARMLAND_FERTILIZED_DEPLETED_NUTRITION_ID, "farmlandFertilizedNutrition_depleted"); Item.itemsList[farmlandFertilizedDepletedNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_FERTILIZED_DEPLETED_NUTRITION_ID - 256); //FARMLAND DUNG - farmlandDungFullNutrition = new FarmlandDungFullNutritionBlock(SCBlockIDs.FARMLAND_DUNG_FULL_NUTRITION_ID, "scBlockFarmlandDungNutrition_full"); + farmlandDungFullNutrition = new FarmlandDungFullNutritionBlock(SCBlockIDs.FARMLAND_DUNG_FULL_NUTRITION_ID, "farmlandDungNutrition_full"); Item.itemsList[farmlandDungFullNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_DUNG_FULL_NUTRITION_ID - 256); - farmlandDungReducedNutrition = new FarmlandDungReducedNutritionBlock(SCBlockIDs.FARMLAND_DUNG_REDUCED_NUTRITION_ID, "scBlockFarmlandDungNutrition_reduced"); + farmlandDungReducedNutrition = new FarmlandDungReducedNutritionBlock(SCBlockIDs.FARMLAND_DUNG_REDUCED_NUTRITION_ID, "farmlandDungNutrition_reduced"); Item.itemsList[farmlandDungReducedNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_DUNG_REDUCED_NUTRITION_ID - 256); - farmlandDungLowNutrition = new FarmlandDungLowNutritionBlock(SCBlockIDs.FARMLAND_DUNG_LOW_NUTRITION_ID, "scBlockFarmlandDungNutrition_low"); + farmlandDungLowNutrition = new FarmlandDungLowNutritionBlock(SCBlockIDs.FARMLAND_DUNG_LOW_NUTRITION_ID, "farmlandDungNutrition_low"); Item.itemsList[farmlandDungLowNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_DUNG_LOW_NUTRITION_ID - 256); - farmlandDungDepletedNutrition = new FarmlandDungDepletedNutritionBlock(SCBlockIDs.FARMLAND_DUNG_DEPLETED_NUTRITION_ID, "scBlockFarmlandDungNutrition_depleted"); + farmlandDungDepletedNutrition = new FarmlandDungDepletedNutritionBlock(SCBlockIDs.FARMLAND_DUNG_DEPLETED_NUTRITION_ID, "farmlandDungNutrition_depleted"); Item.itemsList[farmlandDungDepletedNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_DUNG_DEPLETED_NUTRITION_ID - 256); //FARMLAND MULCH - farmlandMulchFullNutrition = new FarmlandMulchFullNutritionBlock(SCBlockIDs.FARMLAND_MULCH_FULL_NUTRITION_ID, "scBlockFarmlandMulchNutrition_full"); + farmlandMulchFullNutrition = new FarmlandMulchFullNutritionBlock(SCBlockIDs.FARMLAND_MULCH_FULL_NUTRITION_ID, "farmlandMulchNutrition_full"); Item.itemsList[farmlandMulchFullNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_MULCH_FULL_NUTRITION_ID - 256); - farmlandMulchReducedNutrition = new FarmlandMulchReducedNutritionBlock(SCBlockIDs.FARMLAND_MULCH_REDUCED_NUTRITION_ID, "scBlockFarmlandMulchNutrition_reduced"); + farmlandMulchReducedNutrition = new FarmlandMulchReducedNutritionBlock(SCBlockIDs.FARMLAND_MULCH_REDUCED_NUTRITION_ID, "farmlandMulchNutrition_reduced"); Item.itemsList[farmlandMulchReducedNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_MULCH_REDUCED_NUTRITION_ID - 256); - farmlandMulchLowNutrition = new FarmlandMulchLowNutritionBlock(SCBlockIDs.FARMLAND_MULCH_LOW_NUTRITION_ID, "scBlockFarmlandMulchNutrition_low"); + farmlandMulchLowNutrition = new FarmlandMulchLowNutritionBlock(SCBlockIDs.FARMLAND_MULCH_LOW_NUTRITION_ID, "farmlandMulchNutrition_low"); Item.itemsList[farmlandMulchLowNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_MULCH_LOW_NUTRITION_ID - 256); - farmlandMulchDepletedNutrition = new FarmlandMulchDepletedNutritionBlock(SCBlockIDs.FARMLAND_MULCH_DEPLETED_NUTRITION_ID, "scBlockFarmlandMulchNutrition_depleted"); + farmlandMulchDepletedNutrition = new FarmlandMulchDepletedNutritionBlock(SCBlockIDs.FARMLAND_MULCH_DEPLETED_NUTRITION_ID, "farmlandMulchNutrition_depleted"); Item.itemsList[farmlandMulchDepletedNutrition.blockID] = new ItemBlock(SCBlockIDs.FARMLAND_MULCH_DEPLETED_NUTRITION_ID - 256); } private static void initPlanterBlocks() { - planterGrass = new PlanterGrassBlock(SCBlockIDs.GRASS_PLANTER_ID, "scBlockPlanter_grass"); + planterGrass = new PlanterGrassBlock(SCBlockIDs.GRASS_PLANTER_ID, "planter_grass"); Item.itemsList[planterGrass.blockID] = new ItemMultiTextureTile(SCBlockIDs.GRASS_PLANTER_ID - 256, planterGrass, NutritionUtils.GRASS_PLANTER_TEXTURE_NAMES); - planterFarmland = new PlanterFarmlandBlock(SCBlockIDs.FARMLAND_PLANTER_ID, "scBlockPlanter_farmland"); + planterFarmland = new PlanterFarmlandBlock(SCBlockIDs.FARMLAND_PLANTER_ID, "planter_farmland"); Item.itemsList[planterFarmland.blockID] = new ItemMultiTextureTile(SCBlockIDs.FARMLAND_PLANTER_ID - 256, planterFarmland, NutritionUtils.PLANTER_TEXTURE_NAMES); - planterFarmlandFertilized = new PlanterFarmlandFertilizedBlock(SCBlockIDs.FERTILIZED_PLANTER_ID, "scBlockPlanter_farmland_fertilized"); + planterFarmlandFertilized = new PlanterFarmlandFertilizedBlock(SCBlockIDs.FERTILIZED_PLANTER_ID, "planter_farmland_fertilized"); Item.itemsList[planterFarmlandFertilized.blockID] = new ItemMultiTextureTile(SCBlockIDs.FERTILIZED_PLANTER_ID - 256, planterFarmlandFertilized, NutritionUtils.PLANTER_TEXTURE_NAMES); - planterFarmlandDung = new PlanterFarmlandDungBlock(SCBlockIDs.DUNG_PLANTER_ID, "scBlockPlanter_farmland_dung"); + planterFarmlandDung = new PlanterFarmlandDungBlock(SCBlockIDs.DUNG_PLANTER_ID, "planter_farmland_dung"); Item.itemsList[planterFarmlandDung.blockID] = new ItemMultiTextureTile(SCBlockIDs.DUNG_PLANTER_ID - 256, planterFarmlandDung, NutritionUtils.PLANTER_TEXTURE_NAMES); } - - private static void initHayBlocks() { - dryingHay = new HayDryingBlock(SCBlockIDs.DRYING_HAY_ID, "scBlockHay_drying"); - Item.itemsList[dryingHay.blockID] = new ItemBlock(SCBlockIDs.DRYING_HAY_ID - 256); - - driedHay = new HayDriedBlock(SCBlockIDs.DRIED_HAY_ID, "scBlockHay_dried"); - Item.itemsList[driedHay.blockID] = new ItemBlock(SCBlockIDs.DRIED_HAY_ID - 256); - - hayBale = new HayBaleBlock(SCBlockIDs.HAY_BALE_ID, "scBlockBale_hay"); - Item.itemsList[hayBale.blockID] = new ItemBlock(SCBlockIDs.HAY_BALE_ID - 256); - - strawBale = new StrawBaleBlock(SCBlockIDs.STRAW_BALE_ID, "scBlockBale_straw"); - Item.itemsList[strawBale.blockID] = new ItemBlock(SCBlockIDs.STRAW_BALE_ID - 256); - } } diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/BaleBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/BaleBlock.java index bce432b..35b2b33 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/BaleBlock.java +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/BaleBlock.java @@ -108,11 +108,6 @@ public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, else return 2; } - @Override - public boolean canToolsStickInBlock(IBlockAccess blockAccess, int x, int y, int u) { - return false; - } - @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving player, ItemStack stack) {/* int var7 = FCUtilsMisc.ConvertPlacingEntityOrientationToBlockFacing(var5); diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/BaseLogBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/BaseLogBlock.java new file mode 100644 index 0000000..78410d7 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/BaseLogBlock.java @@ -0,0 +1,27 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.blocks.LogBlock; +import net.minecraft.src.BlockLog; +import net.minecraft.src.ItemStack; +import net.minecraft.src.World; + +public abstract class BaseLogBlock extends LogBlock { + + public static final String[] treeNames = new String[] {"oak", "spruce", "birch", "jungle"}; + + protected BaseLogBlock(int blockID) { + super(blockID); + } + + @Override + public boolean canConvertBlock(ItemStack stack, World world, int i, int j, int k ) + { + return false; + } + + @Override + public boolean getCanBlockBeIncinerated( World world, int i, int j, int k ) + { + return false; + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/BerryBushBaseBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/BerryBushBaseBlock.java new file mode 100644 index 0000000..ba8356b --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/BerryBushBaseBlock.java @@ -0,0 +1,156 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.util.Flammability; +import btw.item.items.ShearsItem; +import btw.item.util.ItemUtils; +import net.minecraft.src.*; + +import java.util.Random; + +public abstract class BerryBushBaseBlock extends BlockFlower { + + public BerryBushBaseBlock(int blockID) + { + super(blockID); + this.setAxesEffectiveOn( true ); + this.setBuoyant(); + this.setFireProperties( Flammability.CROPS ); + this.setTickRandomly(true); + this.setStepSound(soundGrassFootstep); + + float var3 = 0.3F; + initBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, 0.5F + var3, 0.5F + var3); + } + + private float getBaseGrowthChance() + { + return 0.05F; + } + + @Override + public void updateTick(World world, int i, int j, int k, Random rand) + { + if (!world.isRemote && rand.nextFloat() <= getBaseGrowthChance() ) + { + if (world.getBlockMetadata(i, j, k) < 5) + { + world.setBlockMetadataWithNotify(i, j, k, world.getBlockMetadata(i, j, k) + 1); + + if (world.getBlockMetadata(i, j, k) == 4) + { + Block blockBelow = Block.blocksList[world.getBlockId( i, j - 1, k )]; + + if ( blockBelow != null ) + { + blockBelow.notifyOfFullStagePlantGrowthOn( world, i, j - 1, k, this ); + } + } + } + } + } + + +// protected void AttemptToGrow( World world, int i, int j, int k, Random rand ) +// { +// if ( GetWeedsGrowthLevel( world, i, j, k ) == 0 && +// GetGrowthLevel( world, i, j, k ) < 7 && +// world.getBlockLightValue( i, j + 1, k ) >= 9 ) +// { +// Block blockBelow = Block.blocksList[world.getBlockId( i, j - 1, k )]; +// +// if ( blockBelow != null && +// blockBelow.IsBlockHydratedForPlantGrowthOn( world, i, j - 1, k ) ) +// { +// float fGrowthChance = GetBaseGrowthChance( world, i, j, k ) * +// blockBelow.GetPlantGrowthOnMultiplier( world, i, j - 1, k, this ); +// +// if ( rand.nextFloat() <= fGrowthChance ) +// { +// IncrementGrowthLevel( world, i, j, k ); +// } +// } +// } +// } + + @Override + public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int iFacing, float fXClick, float fYClick, float fZClick ) + { + ItemStack playerEquippedItem = player.getCurrentEquippedItem(); + + if ( !world.isRemote && world.getBlockMetadata(i, j, k) == 5 && (playerEquippedItem == null || playerEquippedItem.itemID == getBerryID() )) // must have empty hand to rc + { + int amount = world.rand.nextInt(2) + 1 ; + // click sound + world.playAuxSFX( 2001, i, j, k, this.blockID ); + ItemUtils.dropStackAsIfBlockHarvested( world, i, j, k, + new ItemStack( getBerryID(), amount, 0 ) ); + world.setBlock(i, j, k, this.blockID); + world.setBlockMetadataWithNotify(i, j, k, 1); + + return true; + } + + return false; + } + + @Override + public void harvestBlock( World world, EntityPlayer player, int i, int j, int k, int iMetadata ) + { + int amount = world.rand.nextInt(2) + 1 ; + + if( !world.isRemote ) + { + ItemStack heldItem = player.getCurrentEquippedItem(); + + // kill the plant if not harvested by shears + if ( heldItem == null || !(heldItem.getItem() instanceof ShearsItem ) ) + { + if ( iMetadata == 5 ) + { + ItemUtils.dropStackAsIfBlockHarvested(world,i,j,k, new ItemStack(this.getBerryID(), amount, 0)); + world.setBlockToAir( i, j , k ); + } + } + else if (heldItem.getItem() instanceof ShearsItem) + { + if ( iMetadata == 5 ) + { + this.dropBlockAsItem_do(world, i, j, k, new ItemStack(this.getBerryID(), amount, 0)); + } + + this.dropBlockAsItem_do(world, i, j, k, new ItemStack(this.getSaplingID(), 1, 0)); + heldItem.damageItem(1, player); + + world.setBlockToAir( i, j , k ); + } + } + + } + + @Override + public int idDropped(int iMetadata, Random random, int iFortuneModifier) + { + return 0; + } + + protected abstract int getBerryID(); + + protected abstract int getSaplingID(); + + @Override + public int idPicked(World world, int i, int j, int k) + { + return getSaplingID(); + } + + @Override + protected boolean canGrowOnBlock(World var1, int var2, int var3, int var4) + { + Block var5 = Block.blocksList[var1.getBlockId(var2, var3, var4)]; + return var5 != null && var5.canWildVegetationGrowOnBlock(var1, var2, var3, var4); + } + + + + +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/BerryBushBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/BerryBushBlock.java new file mode 100644 index 0000000..530edb2 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/BerryBushBlock.java @@ -0,0 +1,106 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.BTWBlocks; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import net.minecraft.src.*; + +import java.util.List; + +public class BerryBushBlock extends BerryBushBaseBlock { + + private int berryID; + private int saplingID; + private String textureName; + + public BerryBushBlock(int blockID, int berryID, int saplingID, String name) + { + super(blockID); + this.textureName = name; + this.berryID = berryID; + this.saplingID = saplingID; + + this.setUnlocalizedName(name); + this.setCreativeTab(CreativeTabs.tabDecorations); + } + + @Override + public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { + par3List.add(new ItemStack(par1, 1, 0)); + par3List.add(new ItemStack(par1, 1, 1)); + par3List.add(new ItemStack(par1, 1, 2)); + par3List.add(new ItemStack(par1, 1, 3)); + par3List.add(new ItemStack(par1, 1, 4)); + par3List.add(new ItemStack(par1, 1, 5)); + } + + @Override + protected int getBerryID() + { + return berryID; + } + + @Override + protected int getSaplingID() + { + return saplingID; + } + + private Icon[] bushIcon = new Icon[6]; + private Icon[] snowOverlay = new Icon[6]; + + @Override + public void registerIcons( IconRegister register ) + { + for (int i = 0; i < bushIcon.length; i++) { + bushIcon[i] = register.registerIcon( "bush_" + textureName + "_" + i ); + } + + for (int i = 0; i < snowOverlay.length; i++) + { + snowOverlay[i] = register.registerIcon("bush_snow_" + i); + } + } + + public Icon getIcon(int side, int meta) + { + return bushIcon[meta]; + } + + //----------- Client Side Functionality -----------// + + + @Override + public boolean renderBlock(RenderBlocks renderer, int i, int j, int k ) + { + int meta = renderer.blockAccess.getBlockMetadata(i, j, k); + + renderer.setRenderBounds( getBlockBoundsFromPoolBasedOnState( + renderer.blockAccess, i, j, k ) ); + + SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i, j, k, bushIcon[meta], false); + + BTWBlocks.weeds.renderWeeds( this, renderer, i, j, k ); + + return true; + } + + @Override + public void renderBlockSecondPass(RenderBlocks renderer, int i, int j, int k, boolean bFirstPassResult) { + + int meta = renderer.blockAccess.getBlockMetadata(i, j, k); + + if (renderer.blockAccess.getBlockId(i, j + 1, k) == Block.snow.blockID) + { + renderer.setRenderBounds( getBlockBoundsFromPoolBasedOnState( + renderer.blockAccess, i, j, k ) ); + + SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i, j, k, snowOverlay[meta], false); + } + } + + @Override + public boolean doesItemRenderAsBlock(int iItemDamage) { + return false; + } + +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/CloverBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/CloverBlock.java new file mode 100644 index 0000000..0cb2400 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/CloverBlock.java @@ -0,0 +1,166 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.client.render.util.RenderUtils; +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.src.*; + +import java.util.List; + +public class CloverBlock extends MultiFlowerBlock { + + private int color; + private String name; + + + public CloverBlock(int blockID, int color, String name) { + super(blockID, name); + + this.color = color; + this.name = name; + } + + @Override + public boolean canBlockStay(World world, int i, int j, int k) { + return (world.getBlockId(i,j+1,k) == SCBlocks.mossCarpet.blockID && Block.blocksList[world.getBlockId(i,j-1,k)].hasLargeCenterHardPointToFacing(world, i, j - 1,k,1) ) + || super.canBlockStay( world, i, j, k ); + } + + @Environment(EnvType.CLIENT) + public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) + { + par3List.add(new ItemStack(par1, 1, 0)); + } + + private Icon[] item = new Icon[4]; + private Icon[] top_flower = new Icon[4]; + private Icon[] top = new Icon[4]; + private static Icon[] stalk = new Icon[4]; + private static Icon[] stalkFlower_purple = new Icon[2]; + private static Icon[] stalkFlower_white = new Icon[2]; + private static Icon[] stalkFlower_red = new Icon[2]; + + @Override + public Icon getIcon(int side, int meta) { + int dir = getDirection(meta); + return this.blockIcon = item[color]; + } + + @Override + public void registerIcons(IconRegister register) { + for (int i = 0; i < top_flower.length; i++) { + if (this.color == 1) + { + top_flower[i] = register.registerIcon("clover_" + "purple" + "_flower_top_" + i); + } + else if (this.color == 2) + { + top_flower[i] = register.registerIcon("clover_" + "white" + "_flower_top_" + i); + } + else if (this.color == 3) + { + top_flower[i] = register.registerIcon("clover_" + "red" + "_flower_top_" + i); + } + top[i] = register.registerIcon("clover_top_" + i); + } + + for (int i = 0; i < top_flower.length; i++) { + stalk[i] = register.registerIcon("clover_stalk_" + i); + } + + if (this.color == 1) + { + stalkFlower_purple[0] = register.registerIcon("clover_stalk_" + "purple" + "_flower_1"); + stalkFlower_purple[1] = register.registerIcon("clover_stalk_" + "purple" + "_flower_3"); + } + else if (this.color == 2) + { + stalkFlower_white[0] = register.registerIcon("clover_stalk_" + "white" + "_flower_1"); + stalkFlower_white[1] = register.registerIcon("clover_stalk_" + "white" + "_flower_3"); + } + else if (this.color == 3) + { + stalkFlower_red[0] = register.registerIcon("clover_stalk_" + "red" + "_flower_1"); + stalkFlower_red[1] = register.registerIcon("clover_stalk_" + "red" + "_flower_3"); + } + + for (int i = 0; i < item.length; i++) { + item[i] = register.registerIcon(getItemIconName()); + } + } + + @Override + public boolean renderBlock(RenderBlocks renderer, int x, int y, int z) { + int meta = renderer.blockAccess.getBlockMetadata(x,y,z); + int stage = MultiFlowerBlock.getStage(meta); + int dir = MultiFlowerBlock.getDirection(meta); + + grassPass = true; + + SCRenderUtils.renderMultiFlowerBlock(renderer, this, x, y, z, top); + + int[] numberOfStalks = { + 3, 2, 3, 2 + }; + double[][][] shifts = { + { + {4/32D, 4/32D}, {12/32D, 6/32D}, {3/32D, 11/32D}, // (xShift, zShift) for stage >= 0 + }, + { + {4/32D, -10/32D}, {12/32D, -4/32D}, // (xShift, zShift) for stage >= 1 + }, + { + {-4/32D, -8/32D}, {-12/32D, -10/32D}, {-12/32D, -2/32D}, // (xShift, zShift) for stage >= 2 + }, + { + {-4/32D, 4/32D}, {-12/32D, 10/32D}, // (xShift, zShift) for stage >= 3 + } + }; + SCRenderUtils.renderStalks(renderer, this, x, y, z, + stage, dir, + numberOfStalks, shifts, + stalk); + grassPass = false; + + if (this.color > 0) { + + Icon[] stalkFlower = new Icon[2]; + + if (this.color == 1) stalkFlower = stalkFlower_purple; + if (this.color == 2) stalkFlower = stalkFlower_white; + if (this.color == 3) stalkFlower = stalkFlower_red; + + SCRenderUtils.renderStalkFlowers(renderer, this, x, y, z, + stage, dir, + numberOfStalks, shifts, + stalkFlower); + } + + return true; + } + + @Override + public void renderBlockSecondPass(RenderBlocks renderer, int x, int y, int z, boolean bFirstPassResult) { + + if (this.color > 0) SCRenderUtils.renderMultiFlowerBlock(renderer, this, x, y, z, top_flower); + + } + + @Environment(EnvType.CLIENT) + public String getItemIconName() + { + if (color == 1) return "clover_purple"; + if (color == 2) return "clover_white"; + if (color == 3) return "clover_red"; + else return "clover"; + } + + @Override + public void renderBlockAsItem(RenderBlocks renderBlocks, int iItemDamage, float fBrightness) { + renderBlocks.setOverrideBlockTexture(item[this.color]); + renderBlocks.renderBlockAsItemVanilla( this, iItemDamage, fBrightness ); + renderBlocks.clearOverrideBlockTexture(); + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/DoubleTallFlowerBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/DoubleTallFlowerBlock.java new file mode 100644 index 0000000..bd4490b --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/DoubleTallFlowerBlock.java @@ -0,0 +1,17 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import net.minecraft.src.Block; +import net.minecraft.src.CreativeTabs; +import net.minecraft.src.ItemStack; + +import java.util.List; + +public class DoubleTallFlowerBlock extends DoubleTallPlantBlock { + public DoubleTallFlowerBlock(int blockID, String name) { + super(blockID, name); + } + + public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { + + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/DoubleTallGrassBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/DoubleTallGrassBlock.java index 78dc949..4c3170e 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/DoubleTallGrassBlock.java +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/DoubleTallGrassBlock.java @@ -1,327 +1,107 @@ package btw.community.sockthing.sockscrops.block.blocks; -import btw.block.util.Flammability; -import btw.community.sockthing.sockscrops.block.SCBlocks; -import btw.community.sockthing.sockscrops.item.SCItems; -import btw.community.sockthing.sockscrops.item.items.KnifeItem; -import btw.community.sockthing.sockscrops.utils.NutritionUtils; -import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import btw.community.sockthing.sockscrops.block.blocks.TallPlantBlock; import btw.item.items.ShearsItem; import com.prupe.mcpatcher.cc.ColorizeBlock; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.src.*; -import java.util.List; import java.util.Random; -public class DoubleTallGrassBlock extends BlockFlower { +public class DoubleTallGrassBlock extends TallPlantBlock { + public static final int GRASS_TYPE = 0; + public static final int FERN_TYPE = 1; - private static final double HALF_WIDTH = 0.3F; - public static final int GRASS = 0; - public static final int FERN = 1; - public static final int SUNFLOWER = 2; + public DoubleTallGrassBlock(int blockID) { + super(blockID, "tall_plant", + new String [] { + "grass", + "fern" + }); - public DoubleTallGrassBlock(int blockID, String name) { - super(blockID); - - setHardness(0F); - setBuoyant(); - setFireProperties(Flammability.GRASS); - initBlockBounds(0.5D - HALF_WIDTH, 0D, 0.5D - HALF_WIDTH, - 0.5D + HALF_WIDTH, 0.8D, 0.7D + HALF_WIDTH); - - setCreativeTab(CreativeTabs.tabDecorations); - setStepSound(soundGrassFootstep); - setUnlocalizedName(name); - - } - - /** - * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the - * block and l is the block's subtype/damage. - */ - public void harvestBlock(World world, EntityPlayer player, int i, int j, int k, int meta) { - ItemStack heldStack = player.getCurrentEquippedItem(); - - /* - if (!world.isRemote && (meta&7) == SUNFLOWER) - { - this.dropBlockAsItem_do(world, i, j, k, new ItemStack(SCDefs.sunflower)); - return; - } - */ - - if (!world.isRemote && heldStack != null) { - if (heldStack.getItem() instanceof ShearsItem) { - player.getHeldItem().damageItem(1, player); - - if (isTopBlock(meta)) { - this.dropBlockAsItem_do(world, i, j, k, new ItemStack(this.blockID, 1, meta - 8)); - } else this.dropBlockAsItem_do(world, i, j, k, new ItemStack(this.blockID, 1, meta)); - } - /* - else if( heldStack.getItem() instanceof KnifeItem && getType(meta) == GRASS) - { - player.getHeldItem().damageItem(1, player); - - if (world.rand.nextFloat() <= 1/8F) - { - this.dropBlockAsItem_do(world, i, j, k, new ItemStack(SCDefs.grassSeeds)); - } - } - */ - else if (heldStack.getItem() instanceof KnifeItem) { - player.getHeldItem().damageItem(1, player); - - if (world.rand.nextFloat() <= 1 / 8F) { - this.dropBlockAsItem_do(world, i, j, k, new ItemStack(SCItems.cuttings)); - } - } - } else { - super.harvestBlock(world, player, i, j, k, meta); - } - } - - private int getType(int meta) { - return meta & 7; - } - - @Override - public int idDropped(int iMetadata, Random rand, int iFortuneModifier) { - /* - if ((iMetadata&7) == SUNFLOWER) - { - return SCDefs.sunflower.itemID; - } - */ - return 0; + this.blockMaterial = Material.vine; } @Override - public int damageDropped(int par1) { + public int idDropped(int metadata, Random rand, int fortunateModifier) { return 0; } @Override - public boolean canSpitWebReplaceBlock(World world, int i, int j, int k) { + public boolean canSpitWebReplaceBlock(World world, int x, int y, int z) { return true; } @Override - public boolean isReplaceableVegetation(World world, int i, int j, int k) { + public boolean isReplaceableVegetation(World world, int x, int y, int z) { return true; } - public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { - par3List.add(new ItemStack(par1, 1, GRASS)); - par3List.add(new ItemStack(par1, 1, FERN)); - } - - @Override - public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving player, - ItemStack itemStack) { - - if (world.getBlockId(i, j + 1, k) == 0) { - world.setBlockAndMetadataWithNotify(i, j + 1, k, this.blockID, setTopBlock(world.getBlockMetadata(i, j, k))); - } - } - @Override - public void onNeighborBlockChange(World world, int i, int j, int k, int neighbourID) { - int meta = world.getBlockMetadata(i, j, k); + public void harvestBlock(World world, EntityPlayer player, int x, int y, int z, int metadata) { + if (!world.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ShearsItem) { + player.addStat(StatList.mineBlockStatArray[this.blockID], 1); + player.getHeldItem().damageItem(1, player); - if (isTopBlock(meta)) { - if (world.getBlockId(i, j - 1, k) != this.blockID) { - world.setBlockToAir(i, j, k); - //FCUtilsItem.DropSingleItemAsIfBlockHarvested(world, i, j, k, this.blockID, meta - 8); - } - } else { - if (world.getBlockId(i, j + 1, k) != this.blockID) { - world.setBlockToAir(i, j, k); - //FCUtilsItem.DropSingleItemAsIfBlockHarvested(world, i, j, k, this.blockID, meta); + if (!isTopBlock(metadata)) { + this.dropBlockAsItem_do(world, x, y, z, new ItemStack(this.blockID, 1, metadata & 7)); } } - - super.onNeighborBlockChange(world, i, j, k, neighbourID); + else { + super.harvestBlock(world, player, x, y, z, metadata); + } } @Override - public boolean canBlockStay(World world, int i, int j, int k) { - - int meta = world.getBlockMetadata(i, j, k); - if (isTopBlock(meta)) { - return world.getBlockId(i, j - 1, k) == this.blockID; - } else return super.canBlockStay(world, i, j, k); + public int getHerbivoreItemFoodValue(int itemDamage) { + return Item.BASE_HERBIVORE_ITEM_FOOD_VALUE / 2; } @Override - protected boolean canGrowOnBlock(World world, int i, int j, int k) { - int meta = world.getBlockMetadata(i, j, k); - - if (isTopBlock(meta)) { - return world.getBlockId(i, j - 1, k) == this.blockID; - } else return super.canGrowOnBlock(world, i, j, k); + public float getHalfWidth() { + return 0.4F; } - public boolean isTopBlock(int meta) { - return meta > 7; + @Override + public float getHeight() { + return 0.8F; } - public static int setTopBlock(int meta) { - return meta + 8; - } + //----------- Client Side Functionality -----------// + @Environment(EnvType.CLIENT) + @Override public int getBlockColor() { if (ColorizeBlock.colorizeBlock(this)) { return ColorizeBlock.blockColor; - } else { + } + else { double var1 = 0.5D; double var3 = 1.0D; return ColorizerGrass.getGrassColor(var1, var3); } } - /** - * Returns the color this block should be rendered. Used by leaves. - */ - public int getRenderColor(int par1) { - if ((par1 & 7) == SUNFLOWER) return 0xFFFFFF; - - if (ColorizeBlock.colorizeBlock(this, par1)) { - return ColorizeBlock.blockColor; - } else { - return ColorizerFoliage.getFoliageColorBasic(); - } - } - - /** - * Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called - * when first determining what to render. - */ - public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { - if (ColorizeBlock.colorizeBlock(this, par1IBlockAccess, par2, par3, par4)) { + @Environment(EnvType.CLIENT) + @Override + public int getRenderColor(int metadata) { + if (ColorizeBlock.colorizeBlock(this, metadata)) { return ColorizeBlock.blockColor; - } else { - int var5 = par1IBlockAccess.getBlockMetadata(par2, par3, par4); - - if ((var5 & 7) == SUNFLOWER) { - return 0xFFFFFF; - } - - return getColorBasedOnNutritionBelow(par1IBlockAccess, par2, par3, par4); } - } - - private int getColorBasedOnNutritionBelow(IBlockAccess blockAccess, int x, int y, int z) { - int metaBelow = blockAccess.getBlockMetadata(x, y - 1, z); - int nutritionLevel; - - if (blockAccess.getBlockId(x, y - 1, z) == this.blockID) { - metaBelow = blockAccess.getBlockMetadata(x, y - 2, z); + else { + return ColorizerFoliage.getFoliageColorBasic(); } - - if (blockAccess.getBlockId(x, y - 1, z) == Block.grass.blockID - || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.grassNutrition.blockID) { - nutritionLevel = NutritionUtils.getGrassNutritionLevel(metaBelow); - } else if (Block.blocksList[blockAccess.getBlockId(x, y - 1, z)] instanceof PlanterBaseBlock) { - nutritionLevel = NutritionUtils.getPlanterNutritionLevel(metaBelow); - } else if (blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandFullNutrition.blockID - || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandFertilizedFullNutrition.blockID - || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandDungFullNutrition.blockID - || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandMulchFullNutrition.blockID) { - nutritionLevel = NutritionUtils.FULL_NUTRITION_LEVEL; - } else if (blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandReducedNutrition.blockID - || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandFertilizedReducedNutrition.blockID - || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandDungReducedNutrition.blockID - || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandMulchReducedNutrition.blockID) { - nutritionLevel = NutritionUtils.REDUCED_NUTRITION_LEVEL; - } else if (blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandLowNutrition.blockID - || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandFertilizedLowNutrition.blockID - || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandDungLowNutrition.blockID - || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandMulchLowNutrition.blockID) { - nutritionLevel = NutritionUtils.LOW_NUTRITION_LEVEL; - } else if (blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandDepletedNutrition.blockID - || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandFertilizedDepletedNutrition.blockID - || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandDungDepletedNutrition.blockID - || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandMulchDepletedNutrition.blockID) { - nutritionLevel = NutritionUtils.DEPLETED_NUTRITION_LEVEL; - } else nutritionLevel = NutritionUtils.getNutritionLevel(metaBelow); - - if (nutritionLevel == NutritionUtils.REDUCED_NUTRITION_LEVEL) { - return (SCRenderUtils.color(blockAccess, x, y, z, 150, -25, 0)); - } else if (nutritionLevel == NutritionUtils.LOW_NUTRITION_LEVEL) { - return (SCRenderUtils.color(blockAccess, x, y, z, 300, -50, 0)); - } else if (nutritionLevel == NutritionUtils.DEPLETED_NUTRITION_LEVEL) { - return (SCRenderUtils.color(blockAccess, x, y, z, 400, -100, 0)); - } else return (SCRenderUtils.color(blockAccess, x, y, z, 0, 0, 0)); } - private final Icon[] topIcon = new Icon[8]; - private final Icon[] bottomIcon = new Icon[8]; - private final Icon[] sunflowerFace = new Icon[2]; - + @Environment(EnvType.CLIENT) @Override - public void registerIcons(IconRegister register) { - - topIcon[0] = register.registerIcon("large_grass_top"); - topIcon[1] = register.registerIcon("large_fern_top"); -// topIcon[2] = register.registerIcon("SCBlockFlowerSunflower_top_3"); - - bottomIcon[0] = register.registerIcon("large_grass_bottom"); - bottomIcon[1] = register.registerIcon("large_fern_bottom"); -// bottomIcon[2] = register.registerIcon("SCBlockFlowerSunflower_bottom_4"); - -// sunflowerFace[0] = register.registerIcon("SCBlockFlowerSunflower_front_3"); -// sunflowerFace[1] = register.registerIcon("SCBlockFlowerSunflower_back_3"); - } - - @Override - public Icon getIcon(int side, int meta) { - - if ((meta & 7) == SUNFLOWER) return bottomIcon[2]; - - if (side == 0) { - return bottomIcon[meta & 7]; + public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z) { + if (ColorizeBlock.colorizeBlock(this, blockAccess, x, y, z)) { + return ColorizeBlock.blockColor; } - - if (isTopBlock(meta)) { - return topIcon[meta - 8]; - } else return topIcon[meta]; - } - - @Override - public Icon getBlockTexture(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) { - int meta = par1iBlockAccess.getBlockMetadata(par2, par3, par4); - int metaBelow = par1iBlockAccess.getBlockMetadata(par2, par3 - 1, par4); - int blockBelow = par1iBlockAccess.getBlockId(par2, par3 - 1, par4); - - if ((meta & 7) == SUNFLOWER) return bottomIcon[2]; - - if (isTopBlock(meta)) { - return topIcon[meta - 8]; - } else return bottomIcon[meta]; - } - - @Override - public boolean renderBlock(RenderBlocks renderer, int i, int j, int k) { - int meta = renderer.blockAccess.getBlockMetadata(i, j, k); - - /*if ((meta&7) == SUNFLOWER) - { - if (!isTopBlock(meta)) - { - SCRenderUtils.RenderCrossedSquaresWithTextureAndOffset(renderer, this, i, j, k, bottomIcon[SUNFLOWER], false); - } - else - { - SCRenderUtils.RenderCrossedSquaresWithTextureAndOffset(renderer, this, i, j, k, topIcon[SUNFLOWER], false); - - SCRenderUtils.renderSunflowerPlaneWithTexturesAndRotation(renderer, this, i, j, k, sunflowerFace[0], 0, 6); - SCRenderUtils.renderBackSunflowerPlaneWithTexturesAndRotation(renderer, this, i, j, k, sunflowerFace[1], 0, 6); - } + else { + return blockAccess.getBiomeGenForCoords(x, z).getBiomeGrassColor(); } - else */ - SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i, j, k, getBlockTexture(renderer.blockAccess, i, j, k, meta), true); - return true; } - } \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/DoubleTallPlantBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/DoubleTallPlantBlock.java new file mode 100644 index 0000000..31cfd7b --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/DoubleTallPlantBlock.java @@ -0,0 +1,353 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.util.Flammability; +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.item.SCItems; +import btw.community.sockthing.sockscrops.item.items.KnifeItem; +import btw.community.sockthing.sockscrops.utils.NutritionUtils; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import btw.item.items.ShearsItem; +import com.prupe.mcpatcher.cc.ColorizeBlock; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.src.*; + +import java.util.List; +import java.util.Random; + +public class DoubleTallPlantBlock extends BlockFlower { + + private static final double HALF_WIDTH = 0.25F; + public static final int GRASS = 0; + public static final int FERN = 1; + public static final int SUNFLOWER = 2; + public static String[] types = new String[]{"grass", "fern"}; + + public DoubleTallPlantBlock(int blockID, String name) { + super(blockID); + + setHardness(0F); + setBuoyant(); + setFireProperties(Flammability.GRASS); + + initBlockBounds(0.5D - HALF_WIDTH, 0D, 0.5D - HALF_WIDTH, + 0.5D + HALF_WIDTH, 1D, 0.5D + HALF_WIDTH); + + setCreativeTab(CreativeTabs.tabDecorations); + setStepSound(soundGrassFootstep); + setUnlocalizedName(name); + + } + + + /** + * Called when the player destroys a block with an item that can harvest it. (i, j, k) are the coordinates of the + * block and l is the block's subtype/damage. + */ + public void harvestBlock(World world, EntityPlayer player, int i, int j, int k, int meta) { + ItemStack heldStack = player.getCurrentEquippedItem(); + + if (!world.isRemote && (meta&7) == SUNFLOWER) + { + this.dropBlockAsItem_do(world, i, j, k, new ItemStack(SCItems.sunflower)); + return; + } + + if (!world.isRemote && heldStack != null) { + if (heldStack.getItem() instanceof ShearsItem) { + player.getHeldItem().damageItem(1, player); + + if (isTopBlock(meta)) { + this.dropBlockAsItem_do(world, i, j, k, new ItemStack(this.blockID, 1, meta - 8)); + } else this.dropBlockAsItem_do(world, i, j, k, new ItemStack(this.blockID, 1, meta)); + } + /* + else if( heldStack.getItem() instanceof KnifeItem && getType(meta) == GRASS) + { + player.getHeldItem().damageItem(1, player); + + if (world.rand.nextFloat() <= 1/8F) + { + this.dropBlockAsItem_do(world, i, j, k, new ItemStack(SCDefs.grassSeeds)); + } + } + */ + else if (heldStack.getItem() instanceof KnifeItem) { + player.getHeldItem().damageItem(1, player); + + if (world.rand.nextFloat() <= 1 / 8F) { + this.dropBlockAsItem_do(world, i, j, k, new ItemStack(SCItems.cuttings)); + } + } + } else { + super.harvestBlock(world, player, i, j, k, meta); + } + } + + private int getType(int meta) { + return meta & 7; + } + + @Override + public int idDropped(int iMetadata, Random rand, int iFortuneModifier) { + if ((iMetadata&7) == SUNFLOWER) + { + return SCItems.sunflower.itemID; + } + return 0; + } + + @Override + public int damageDropped(int par1) { + return 0; + } + + @Override + public boolean canSpitWebReplaceBlock(World world, int i, int j, int k) { + return true; + } + + @Override + public boolean isReplaceableVegetation(World world, int i, int j, int k) { + return true; + } + + public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { + par3List.add(new ItemStack(par1, 1, GRASS)); + par3List.add(new ItemStack(par1, 1, FERN)); + } + + @Override + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving player, + ItemStack itemStack) { + + if (world.getBlockId(i, j + 1, k) == 0) { + world.setBlockAndMetadataWithNotify(i, j + 1, k, this.blockID, setTopBlock(world.getBlockMetadata(i, j, k))); + } + } + + @Override + public void onNeighborBlockChange(World world, int i, int j, int k, int neighbourID) { + int meta = world.getBlockMetadata(i, j, k); + + if (isTopBlock(meta)) { + if (world.getBlockId(i, j - 1, k) != this.blockID) { + world.setBlockToAir(i, j, k); + //FCUtilsItem.DropSingleItemAsIfBlockHarvested(world, i, j, k, this.blockID, meta - 8); + } + } else { + if (world.getBlockId(i, j + 1, k) != this.blockID) { + world.setBlockToAir(i, j, k); + //FCUtilsItem.DropSingleItemAsIfBlockHarvested(world, i, j, k, this.blockID, meta); + } + } + + super.onNeighborBlockChange(world, i, j, k, neighbourID); + } + + @Override + public boolean canPlaceBlockAt(World world, int i, int j, int k) { + if (world.getBlockId(i, j + 1, k) != 0) return false; + + return super.canPlaceBlockAt(world, i, j, k); + } + + @Override + public boolean canBlockStay(World world, int i, int j, int k) { + + int meta = world.getBlockMetadata(i, j, k); + if (isTopBlock(meta)) { + return world.getBlockId(i, j - 1, k) == this.blockID; + } else { + return world.getBlockId(i,j-1,k) == Block.grass.blockID || world.getBlockId(i,j-1,k) == SCBlocks.grassNutrition.blockID && super.canBlockStay(world, i, j, k); + } + } + + @Override + protected boolean canGrowOnBlock(World world, int i, int j, int k) { + int meta = world.getBlockMetadata(i, j, k); + + if (isTopBlock(meta)) { + return world.getBlockId(i, j - 1, k) == this.blockID; + } else return super.canGrowOnBlock(world, i, j, k); + } + + public boolean isTopBlock(int meta) { + return meta > 7; + } + + public static int setTopBlock(int meta) { + return meta + 8; + } + + @Override + public AxisAlignedBB getBlockBoundsFromPoolBasedOnState(IBlockAccess blockAccess, int x, int y, int z) { + int metadata = blockAccess.getBlockMetadata(x, y, z); + float minHeight; + float maxHeight; + + if (this.isTopBlock(metadata)) { + minHeight = -1F; + maxHeight = 0.8F; + } + else { + minHeight = 0F; + maxHeight = 1 + 0.8F; + } + + return AxisAlignedBB.getBoundingBox(0.5F - 0.4F, minHeight, 0.5F - 0.4F, + 0.5F + 0.4F, maxHeight, 0.5F + 0.4F); + } + + /** + * Returns the color this block should be rendered. Used by ItemBlock. + */ + @Override + @Environment(EnvType.CLIENT) + public int getRenderColor(int itemDamage) { + if ((itemDamage & 7) == SUNFLOWER) return 0xFF0000; + + double var1 = 0.5D; + double var3 = 1.0D; + return ColorizerGrass.getGrassColor(var1, var3); + } + + /** + * Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called + * when first determining what to render. + */ + public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { + if (ColorizeBlock.colorizeBlock(this, par1IBlockAccess, par2, par3, par4)) { + return ColorizeBlock.blockColor; + } else { + int meta = par1IBlockAccess.getBlockMetadata(par2, par3, par4); + + if (sunflowerPass) { + return 0xFFFFFF; + } + + return getColorBasedOnNutritionBelow(par1IBlockAccess, par2, par3, par4); + } + } + + private int getColorBasedOnNutritionBelow(IBlockAccess blockAccess, int x, int y, int z) { + int metaBelow = blockAccess.getBlockMetadata(x, y - 1, z); + int nutritionLevel; + + if (blockAccess.getBlockId(x, y - 1, z) == this.blockID) { + metaBelow = blockAccess.getBlockMetadata(x, y - 2, z); + } + + if (blockAccess.getBlockId(x, y - 1, z) == Block.grass.blockID + || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.grassNutrition.blockID) { + nutritionLevel = NutritionUtils.getGrassNutritionLevel(metaBelow); + } else if (Block.blocksList[blockAccess.getBlockId(x, y - 1, z)] instanceof PlanterBaseBlock) { + nutritionLevel = NutritionUtils.getPlanterNutritionLevel(metaBelow); + } else if (blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandFullNutrition.blockID + || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandFertilizedFullNutrition.blockID + || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandDungFullNutrition.blockID + || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandMulchFullNutrition.blockID) { + nutritionLevel = NutritionUtils.FULL_NUTRITION_LEVEL; + } else if (blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandReducedNutrition.blockID + || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandFertilizedReducedNutrition.blockID + || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandDungReducedNutrition.blockID + || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandMulchReducedNutrition.blockID) { + nutritionLevel = NutritionUtils.REDUCED_NUTRITION_LEVEL; + } else if (blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandLowNutrition.blockID + || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandFertilizedLowNutrition.blockID + || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandDungLowNutrition.blockID + || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandMulchLowNutrition.blockID) { + nutritionLevel = NutritionUtils.LOW_NUTRITION_LEVEL; + } else if (blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandDepletedNutrition.blockID + || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandFertilizedDepletedNutrition.blockID + || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandDungDepletedNutrition.blockID + || blockAccess.getBlockId(x, y - 1, z) == SCBlocks.farmlandMulchDepletedNutrition.blockID) { + nutritionLevel = NutritionUtils.DEPLETED_NUTRITION_LEVEL; + } else nutritionLevel = NutritionUtils.getNutritionLevel(metaBelow); + + if (nutritionLevel == NutritionUtils.REDUCED_NUTRITION_LEVEL) { + return (SCRenderUtils.color(blockAccess, x, y, z, 150, -25, 0)); + } else if (nutritionLevel == NutritionUtils.LOW_NUTRITION_LEVEL) { + return (SCRenderUtils.color(blockAccess, x, y, z, 300, -50, 0)); + } else if (nutritionLevel == NutritionUtils.DEPLETED_NUTRITION_LEVEL) { + return (SCRenderUtils.color(blockAccess, x, y, z, 400, -100, 0)); + } else return (SCRenderUtils.color(blockAccess, x, y, z, 0, 0, 0)); + } + + private final Icon[] topIcon = new Icon[8]; + private final Icon[] bottomIcon = new Icon[8]; + private static final Icon[] sunflowerFace = new Icon[2]; + + private boolean sunflowerPass = false; + + @Override + public void registerIcons(IconRegister register) { + + topIcon[0] = register.registerIcon("tall_plant_grass_top"); + topIcon[1] = register.registerIcon("tall_plant_fern_top"); + topIcon[2] = register.registerIcon("sunflower_top_3"); + + bottomIcon[0] = register.registerIcon("tall_plant_grass_bottom"); + bottomIcon[1] = register.registerIcon("tall_plant_fern_bottom"); + bottomIcon[2] = register.registerIcon("sunflower_bottom_4"); + + sunflowerFace[0] = register.registerIcon("sunflower_front_3"); + sunflowerFace[1] = register.registerIcon("sunflower_back_3"); + } + + public static Icon getSunflowerFace(int side) { + return sunflowerFace[side]; + } + + @Override + public Icon getIcon(int side, int meta) { + +// if ((meta & 7) == SUNFLOWER) return sunflowerFace[0]; + + if (isTopBlock(meta)) { + return topIcon[meta & 7]; + } else return bottomIcon[meta]; + } + + @Override + public Icon getBlockTexture(IBlockAccess par1iBlockAccess, int par2, int par3, int par4, int par5) { + int meta = par1iBlockAccess.getBlockMetadata(par2, par3, par4); + +// if ((meta & 7) == SUNFLOWER) return sunflowerFace[0]; + + if (isTopBlock(meta)) { + return topIcon[meta - 8]; + } else return bottomIcon[meta]; + } + + @Override + public boolean renderBlock(RenderBlocks renderer, int i, int j, int k) { + int meta = renderer.blockAccess.getBlockMetadata(i, j, k); + + if ((meta & 7) == SUNFLOWER) + { + sunflowerPass = true; + if (!isTopBlock(meta)) + { + SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i, j, k, bottomIcon[SUNFLOWER], false); + } + else + { + SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i, j, k, topIcon[SUNFLOWER], false); + + SCRenderUtils.renderHorizonzalPaneSunflower(renderer, this, i,j,k, + -1/16D, 2/16D, 0, + 0, 0, -45, + sunflowerFace[0], sunflowerFace[1], + false, false, 0.0D); + + } + sunflowerPass = false; + } + else { + SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i, j, k, getBlockTexture(renderer.blockAccess, i, j, k, meta), true, true); + } + return true; + } + +} \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/DoubleTallWaterPlantBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/DoubleTallWaterPlantBlock.java new file mode 100644 index 0000000..f4bf2d8 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/DoubleTallWaterPlantBlock.java @@ -0,0 +1,256 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.community.sockthing.sockscrops.item.SCItems; +import btw.community.sockthing.sockscrops.item.items.KnifeItem; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import btw.item.items.ShearsItem; +import net.minecraft.src.*; + +import java.util.List; +import java.util.Random; + +public class DoubleTallWaterPlantBlock extends FlowerLilyBlock { + + public static String[] types = {"cattail", "grass"}; + public static final int CATTAIL = 0; + public static final int GRASS = 1; + private static final double HALF_WIDTH = 0.25F; + + public DoubleTallWaterPlantBlock(int blockID, String name) { + super(blockID, name); + setCreativeTab(CreativeTabs.tabDecorations); + + initBlockBounds(0.5D - HALF_WIDTH, 0D, 0.5D - HALF_WIDTH, + 0.5D + HALF_WIDTH, 0.8D, 0.7D + HALF_WIDTH); + + } + + @Override + public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < types.length; i++) { + par3List.add(new ItemStack(par1, 1, i)); + } + } + + @Override + public boolean canPlaceBlockAt(World world, int i, int j, int k) { + int targetBlock = world.getBlockId(i, j, k); + int targetBlockBelow = world.getBlockId(i, j - 1, k); + int targetBlockBelowThat = world.getBlockId(i, j - 2, k); + return targetBlockBelow == Block.waterStill.blockID && (targetBlockBelowThat == Block.dirt.blockID || targetBlockBelowThat == Block.sand.blockID) && (targetBlock == 0); + } + + @Override + public int getRenderColor(int par1) + { + double var1 = 0.5D; + double var3 = 1.0D; + return ColorizerGrass.getGrassColor(var1, var3); + } + + public void harvestBlock(World world, EntityPlayer player, int i, int j, int k, int meta) { + ItemStack heldStack = player.getCurrentEquippedItem(); + + /* + if (!world.isRemote && (meta&7) == SUNFLOWER) + { + this.dropBlockAsItem_do(world, i, j, k, new ItemStack(SCDefs.sunflower)); + return; + } + */ + + if (!world.isRemote && heldStack != null) { + if (heldStack.getItem() instanceof ShearsItem) { + player.getHeldItem().damageItem(1, player); + + if (isTopBlock(meta)) { + this.dropBlockAsItem_do(world, i, j, k, new ItemStack(this.blockID, 1, meta - 8)); + } else this.dropBlockAsItem_do(world, i, j, k, new ItemStack(this.blockID, 1, meta)); + } + /* + else if( heldStack.getItem() instanceof KnifeItem && getType(meta) == GRASS) + { + player.getHeldItem().damageItem(1, player); + + if (world.rand.nextFloat() <= 1/8F) + { + this.dropBlockAsItem_do(world, i, j, k, new ItemStack(SCDefs.grassSeeds)); + } + } + */ + else if (heldStack.getItem() instanceof KnifeItem) { + player.getHeldItem().damageItem(1, player); + + if (world.rand.nextFloat() <= 1 / 8F) { + this.dropBlockAsItem_do(world, i, j, k, new ItemStack(SCItems.cuttings)); + } + } + } else { + super.harvestBlock(world, player, i, j, k, meta); + } + } + + @Override + public int idDropped(int iMetadata, Random rand, int iFortuneModifier) { + /* + if ((iMetadata&7) == SUNFLOWER) + { + return SCDefs.sunflower.itemID; + } + */ + return 0; + } + + @Override + public int damageDropped(int par1) { + return 0; + } + + @Override + public boolean canSpitWebReplaceBlock(World world, int i, int j, int k) { + return true; + } + + @Override + public boolean isReplaceableVegetation(World world, int i, int j, int k) { + return true; + } + + + @Override + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving player, + ItemStack itemStack) { + + if (world.getBlockId(i, j + 1, k) == 0) { + world.setBlockAndMetadataWithNotify(i, j + 1, k, this.blockID, setTopBlock(world.getBlockMetadata(i, j, k))); + } + } + + @Override + public void onNeighborBlockChange(World world, int i, int j, int k, int neighbourID) { + int meta = world.getBlockMetadata(i, j, k); + + if (isTopBlock(meta)) { + if (world.getBlockId(i, j - 1, k) != this.blockID) { + world.setBlockToAir(i, j, k); + //FCUtilsItem.DropSingleItemAsIfBlockHarvested(world, i, j, k, this.blockID, meta - 8); + } + } else { + if (world.getBlockId(i, j + 1, k) != this.blockID) { + world.setBlockToAir(i, j, k); + //FCUtilsItem.DropSingleItemAsIfBlockHarvested(world, i, j, k, this.blockID, meta); + } + } + + super.onNeighborBlockChange(world, i, j, k, neighbourID); + } + + @Override + public AxisAlignedBB getBlockBoundsFromPoolBasedOnState(IBlockAccess blockAccess, int x, int y, int z) { + int metadata = blockAccess.getBlockMetadata(x, y, z); + float minHeight; + float maxHeight; + + if (this.isTopBlock(metadata)) { + minHeight = -1F; + maxHeight = 0.8F; + } + else { + minHeight = 0F; + maxHeight = 1 + 0.8F; + } + + return AxisAlignedBB.getBoundingBox(0.5F - 0.4F, minHeight, 0.5F - 0.4F, + 0.5F + 0.4F, maxHeight, 0.5F + 0.4F); + } + + @Override + public boolean canBlockStay(World world, int i, int j, int k) { + + int meta = world.getBlockMetadata(i, j, k); + if (isTopBlock(meta)) { + return world.getBlockId(i, j - 1, k) == this.blockID; + } else return super.canBlockStay(world, i, j, k); + } + + public boolean isTopBlock(int meta) { + return meta > 7; + } + + public static int setTopBlock(int meta) { + return meta + 8; + } + + public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { + if (grassPass) + { + return par1IBlockAccess.getBiomeGenForCoords(par2, par4).getBiomeGrassColor(); + } + else return 0xffffff; + } + + private Icon[] roots = new Icon[4]; + private Icon[] bottom = new Icon[4]; + private Icon[] top = new Icon[4]; + private Icon[] overlay = new Icon[4]; + + private boolean grassPass; + + @Override + public void registerIcons(IconRegister register) { + + top[0] = register.registerIcon("cattail_top"); + bottom[0] = register.registerIcon("cattail_middle"); + roots[0] = register.registerIcon("cattail_bottom"); + overlay[0] = register.registerIcon("cattail"); + + top[1] = register.registerIcon("tall_plant_grass_top"); + bottom[1] = register.registerIcon("tall_plant_grass_bottom"); + roots[1] = register.registerIcon("tall_plant_grass_bottom"); + } + + @Override + public Icon getIcon(int side, int meta) { + if (isTopBlock(meta)) { + return this.blockIcon = top[meta - 8]; + } else return this.blockIcon = bottom[meta]; + } + + @Override + public boolean renderBlock(RenderBlocks renderer, int i, int j, int k ) + { + grassPass = true; + int meta = renderer.blockAccess.getBlockMetadata(i,j,k); + if (!isTopBlock(meta)) + { + SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i, j-1, k, roots[0], true, true, 4/16D); + + } + SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i, j, k, getBlockTexture(renderer.blockAccess, i, j, k, meta), true, true, 4/16D); + grassPass = false; + + return true; + } + + private int getType(int meta) { + return meta & 7; + } + + + @Override + public void renderBlockSecondPass(RenderBlocks renderer, int x, int y, int z, boolean firstPass) + { + grassPass = false; + int meta = renderer.blockAccess.getBlockMetadata(x, y, z); + if (isTopBlock(meta) && getType(meta) == CATTAIL) SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, x, y, z, overlay[0], true, true, 4/16D); + } + + @Override + public void renderBlockAsItem(RenderBlocks renderBlocks, int damage, float fBrightness) + { + renderBlocks.setOverrideBlockTexture(overlay[0]); + renderBlocks.renderBlockAsItemVanilla(this, damage, fBrightness); + renderBlocks.clearOverrideBlockTexture(); + + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/FlowerLilyBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/FlowerLilyBlock.java new file mode 100644 index 0000000..9e1f729 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/FlowerLilyBlock.java @@ -0,0 +1,139 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import java.util.List; + +import btw.block.blocks.LilyPadBlock; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import net.minecraft.src.*; + +public class FlowerLilyBlock extends LilyPadBlock { + + public static String[] types = {"pink","white"}; + + public static final int PINK = 0; + public static final int WHITE = 1; + + public FlowerLilyBlock(int iBlockID, String name) { + super(iBlockID); + setHardness(0.0F); + setStepSound(soundGrassFootstep); + setUnlocalizedName(name); + } + + @Override + public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < types.length; i++) { + par3List.add(new ItemStack(par1, 1, i)); + } + } + + private boolean secondRenderpass = false; + + private Icon[] rose = new Icon[16]; + private Icon[] flower = new Icon[16]; + private Icon lily; + private Icon roots; + private Icon[] icon = new Icon[16]; + + @Override + public void registerIcons(IconRegister register) { + for (int i = 0; i < types.length; i++) { + rose[i] = register.registerIcon("lily_rose_" + types[i]); + flower[i] = register.registerIcon("lily_flower_" + types[i]); + icon[i] = register.registerIcon("lily_item_" + types[i]); + } + + lily = register.registerIcon("waterlily"); + roots = register.registerIcon("lily_roots"); + } + + @Override + public Icon getIcon(int side, int meta) { + return blockIcon = icon[meta]; + } + + /** + * Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called + * when first determining what to render. + */ + public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) + { + if (secondRenderpass) + { + return 0xffffff; + } + else return super.colorMultiplier(par1IBlockAccess, par2, par3, par4); + } + + @Override + public int getRenderColor(int par1) + { + return 0xffffff; + } + + @Override + public boolean renderBlock(RenderBlocks renderer, int i, int j, int k ) + { + secondRenderpass = true; + renderer.setOverrideBlockTexture(roots); + renderer.setRenderBounds(0, 0, 0, 1, 15/16D, 1); + renderer.renderCrossedSquares(this, i, j - 1, k); + renderer.clearOverrideBlockTexture(); + secondRenderpass = false; + + renderer.setOverrideBlockTexture(lily); + renderer.setRenderBounds( getBlockBoundsFromPoolBasedOnState( renderer.blockAccess, i, j, k ) ); + renderer.renderBlockLilyPad( this, i, j, k ); + renderer.clearOverrideBlockTexture(); + + return true; + } + + @Override + public void renderBlockSecondPass(RenderBlocks renderer, int x, int y, int z, boolean bFirstPassResult) + { + int meta = renderer.blockAccess.getBlockMetadata(x, y, z); + + secondRenderpass = true; + + SCRenderUtils.renderVerticalPaneWithRotation(renderer, this, x,y,z, + 0, 1/16D, 0, + 60, 0, 0, + 0, -8/16D, 0, + rose[meta], rose[meta]); + + SCRenderUtils.renderVerticalPaneWithRotation(renderer, this, x,y,z, + 0, 1/16D, 0, + 60, -90, 0, + 0, -8/16D, 0, + rose[meta], rose[meta]); + + SCRenderUtils.renderVerticalPaneWithRotation(renderer, this, x,y,z, + 0, 1/16D, 0, + 60, 90, 0, + 0, -8/16D, 0, + rose[meta], rose[meta]); + + SCRenderUtils.renderVerticalPaneWithRotation(renderer, this, x,y,z, + 0, 1/16D, 0, + 60, 180, 0, + 0, -8/16D, 0, + rose[meta], rose[meta]); + + renderer.setOverrideBlockTexture(flower[meta]); + renderer.renderCrossedSquares(this, x, y, z); + renderer.clearOverrideBlockTexture(); + + secondRenderpass = false; + } + + @Override + public void renderBlockAsItem(RenderBlocks renderBlocks, int damage, float fBrightness) + { + renderBlocks.setOverrideBlockTexture(flower[damage]); + renderBlocks.renderBlockAsItemVanilla(this, damage, fBrightness); + renderBlocks.clearOverrideBlockTexture(); + + } + +} \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/FlowerpotBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/FlowerpotBlock.java new file mode 100644 index 0000000..fafdc10 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/FlowerpotBlock.java @@ -0,0 +1,205 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.community.sockthing.sockscrops.block.tileentities.FlowerPotTileEntity; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import btw.item.BTWItems; +import btw.item.util.ItemUtils; +import btw.world.util.WorldUtils; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.src.*; + +import java.util.Random; + +public class FlowerpotBlock extends BlockContainer { + public FlowerpotBlock(int id) { + super(id, Material.circuits); + this.initBlockBounds(0.3125D, 0.0D, 0.3125D, 0.6875D, 0.375D, 0.6875D); + this.setHardness(0.0F); + this.setStepSound(soundPowderFootstep); + this.setUnlocalizedName("flowerPot"); + } + + @Override + public boolean canPlaceBlockAt(World world, int x, int y, int z) { + return super.canPlaceBlockAt(world, x, y, z) && WorldUtils.doesBlockHaveCenterHardpointToFacing(world, x, y - 1, z, 1); + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, int par5) { + if (!WorldUtils.doesBlockHaveCenterHardpointToFacing(world, x, y - 1, z, 1)) { + this.dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0); + world.setBlockToAir(x, y, z); + } + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public void breakBlock(World world, int x, int y, int z, int var5, int var6) { + FlowerPotTileEntity potTile = (FlowerPotTileEntity) world.getBlockTileEntity(x, y, z); + int blockInPotID = potTile != null ? potTile.getStoredBlockID() : 0; + + if (blockInPotID != 0) { + int blockInPotMeta = potTile.getStoredBlockMetadata(); + ItemUtils.ejectSingleItemWithRandomOffset(world, x, y, z, blockInPotID, blockInPotMeta); + } + + super.breakBlock(world, x, y, z, var5, var6); + } + + @Override + public int idDropped(int par1, Random par2Random, int par3) { + return Item.flowerPot.itemID; + } + + @Override + public TileEntity createNewTileEntity(World par1World) { + return new FlowerPotTileEntity(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { + ItemStack handItemStack = player.getCurrentEquippedItem(); + FlowerPotTileEntity potTile = (FlowerPotTileEntity) world.getBlockTileEntity(x, y, z); + + + + //Empty hand retrieves item + if (handItemStack == null) { + potTile.retrieveItemFromPot(player, par6); + return true; + } + + int heldID = handItemStack.getItem().itemID; + int heldDamage = handItemStack.getItemDamage(); + + //System.out.println("is Valid: " + potTile.isValidItemForPot(heldID, heldDamage)); + + //If pot already has an item do nothing + if (potTile.hasItem()) { + return false; + } + //If item is placeable within the pot, place it + else if (potTile.isValidItemForPot(heldID, heldDamage) || heldID == BTWItems.brownMushroom.itemID || + heldID == BTWItems.redMushroom.itemID) { + potTile.placeItemInPot(heldID, heldDamage); + + //Decrements stack, unless in creative + if (!player.capabilities.isCreativeMode && --handItemStack.stackSize <= 0) { + player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack) null); + } + + return true; + } + else { + return false; + } + } + + @Override + public boolean canGroundCoverRestOnBlock(World var1, int var2, int var3, int var4) { + return var1.doesBlockHaveSolidTopSurface(var2, var3 - 1, var4); + } + + @Override + public float groundCoverRestingOnVisualOffset(IBlockAccess var1, int var2, int var3, int var4) { + return -1.0F; + } + + //----------- Client Side Functionality -----------// + + @Environment(EnvType.CLIENT) + @Override + public boolean renderBlock(RenderBlocks render, int x, int y, int z) { + render.setRenderBounds(this.getBlockBoundsFromPoolBasedOnState(render.blockAccess, x, y, z)); + + Tessellator tess = Tessellator.instance; + tess.setBrightness(this.getMixedBrightnessForBlock(render.blockAccess, x, y, z)); + float var6 = 1.0F; + int var7 = this.colorMultiplier(render.blockAccess, x, y, z); + Icon var8 = render.getBlockIconFromSide(this, 0); + float var9 = (float) (var7 >> 16 & 255) / 255.0F; + float var10 = (float) (var7 >> 8 & 255) / 255.0F; + float var11 = (float) (var7 & 255) / 255.0F; + tess.setColorOpaque_F(var6 * var9, var6 * var10, var6 * var11); + float var12 = 0.1865F; + render.renderFaceXPos(this, (double) ((float) x - 0.5F + var12), (double) y, (double) z, var8); + render.renderFaceXNeg(this, (double) ((float) x + 0.5F - var12), (double) y, (double) z, var8); + render.renderFaceZPos(this, (double) x, (double) y, (double) ((float) z - 0.5F + var12), var8); + render.renderFaceZNeg(this, (double) x, (double) y, (double) ((float) z + 0.5F - var12), var8); + render.renderFaceYPos(this, (double) x, (double) ((float) y - 0.5F + var12 + 0.1875F), (double) z, render.getBlockIcon(Block.dirt)); + + super.renderBlock(render, x, y, z); + + //Renders the pot's contents + FlowerPotTileEntity potTile = (FlowerPotTileEntity) render.blockAccess.getBlockTileEntity(x, y, z); + int storedBlockID = potTile.getStoredBlockID(); + int storedBlockMetadata = potTile.getStoredBlockMetadata(); + tess.setColorOpaque_F(1.0F, 1.0F, 1.0F); + +// System.out.println("isValid: " + potTile.isValidItemForPot(storedBlockID, storedBlockMetadata)); + + //Cactus renders differently than everything else + if (storedBlockID == Block.cactus.blockID) { + render.setRenderAllFaces(true); + + render.setRenderBounds(.375, .375, .375, .625, 1.0, .625); + render.renderStandardBlock(Block.cactus, x, y, z); + + render.setRenderAllFaces(false); + render.setRenderBounds(0, 0, 0, 1, 1, 1); + } + //Renders other blocks as crossed squares. Double checks validity + else if (potTile.isValidItemForPot(storedBlockID, storedBlockMetadata)) { + Block storedBlock = Block.blocksList[storedBlockID]; + + SCRenderUtils.renderCrossedSquares(render, storedBlock, storedBlockMetadata, x, y, z, 0, 4/16F, 0, 0.75F, false); +// DecoRenderUtils.drawCrossedSquares(render, storedBlock, storedBlockMetadata, potTile.xCoord, potTile.yCoord + .25, potTile.zCoord, 1.0F, 1); + } + else { + return false; + } + + return true; + } + + @Environment(EnvType.CLIENT) + @Override + public boolean shouldSideBeRendered(IBlockAccess var1, int var2, int var3, int var4, int var5) { + return var5 == 0 ? !var1.isBlockOpaqueCube(var2, var3, var4) : true; + } + + @Environment(EnvType.CLIENT) + @Override + public int idPicked(World world, int x, int y, int z) { + FlowerPotTileEntity potTile = (FlowerPotTileEntity) world.getBlockTileEntity(x, y, z); + int blockInPotID = potTile.getStoredBlockID(); + + if (blockInPotID == Block.mushroomBrown.blockID) { + return BTWItems.brownMushroom.itemID; + } + else if (blockInPotID == Block.mushroomRed.blockID) { + return BTWItems.redMushroom.itemID; + } + else { + return blockInPotID == 0 ? Item.flowerPot.itemID : blockInPotID; + } + } + + @Environment(EnvType.CLIENT) + @Override + public int getDamageValue(World world, int x, int y, int z) { + FlowerPotTileEntity potTile = (FlowerPotTileEntity) world.getBlockTileEntity(x, y, z); + int blockInPotMeta = potTile.getStoredBlockMetadata(); + return blockInPotMeta; + } +} \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/GrownPaneBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/GrownPaneBlock.java new file mode 100644 index 0000000..51c8c14 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/GrownPaneBlock.java @@ -0,0 +1,151 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.BTWBlocks; +import btw.block.blocks.PaneBlock; +import btw.block.util.Flammability; +import btw.client.render.util.RenderUtils; +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import btw.item.BTWItems; +import net.minecraft.src.*; + +import java.util.Random; + +public class GrownPaneBlock extends PaneBlock { + + private int returnItemID; + private int returnMetadata; + + public static final int VINES = 0; + + public GrownPaneBlock(int blockID, String name, String textureName, String sideTextureName, int returnItemID, int returnMetadata) { + super( blockID, textureName, sideTextureName, + Material.wood, false ); + + setHardness( 0.5F ); + setAxesEffectiveOn(); + + setBuoyant(); + + setFireProperties(Flammability.PLANKS); + + setLightOpacity( 2 ); + Block.useNeighborBrightness[blockID] = true; + + setStepSound( Block.soundWoodFootstep ); + + setUnlocalizedName( name ); + this.returnItemID = returnItemID; + this.returnMetadata = returnMetadata; + } + + @Override + public int idPicked(World par1World, int par2, int par3, int par4) { + return returnItemID; + } + + @Override + public int idDropped(int par1, Random par2Random, int par3) { + return returnItemID; + } + + @Override + public int damageDropped(int par1) { + return returnMetadata; + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int iFacing, float fXClick, float fYClick, float fZClick ) + { + ItemStack heldStack = player.getHeldItem(); + + if (heldStack == null) + { + world.setBlockAndMetadataWithNotify(x,y,z, returnItemID, returnMetadata); + + dropItemsIndividually(world, x, y, z, Block.vine.blockID, + 1, 0, 1); + + return true; + } + else { + if (heldStack.itemID == Block.plantYellow.blockID){ + if (heldStack.getItemDamage() == 0) + { + world.setBlockAndMetadataWithNotify(x,y,z, this.blockID, 1); + } + else world.setBlockAndMetadataWithNotify(x,y,z, this.blockID, 2); + } + else if (heldStack.itemID == Block.plantRed.blockID){ + world.setBlockAndMetadataWithNotify(x,y,z, this.blockID, 3); + } + } + + return super.onBlockActivated(world, x, y, z, player, iFacing, fXClick, fYClick, fZClick); + } + + @Override + public boolean doesBlockBreakSaw(World world, int i, int j, int k ) + { + return false; + } + + @Override + public boolean dropComponentItemsOnBadBreak(World world, int i, int j, int k, + int iMetadata, float fChanceOfDrop) + { + dropItemsIndividually(world, i, j, k, Item.stick.itemID, + 2, 0, fChanceOfDrop); + + dropItemsIndividually(world, i, j, k, BTWItems.sawDust.itemID, + 2, 0, fChanceOfDrop); + + dropItemsIndividually(world, i, j, k, Block.vine.blockID, + 1, 0, 1); + + return true; + } + + private Icon[] overlay = new Icon[16]; + private boolean secondPass; + @Override + public Icon getIcon(int par1, int par2) { + if (secondPass && par2 > 0) + { + return overlay[par2]; + } + return super.getIcon(par1, par2); + } + + @Override + public void registerIcons(IconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + overlay[1] = par1IconRegister.registerIcon("vine_rose"); + overlay[2] = par1IconRegister.registerIcon("vine_yellow"); + overlay[3] = par1IconRegister.registerIcon("vine_dandilion"); + } + + @Override + public boolean renderBlock(RenderBlocks renderer, int x, int y, int z) { + boolean north = canConnectToBlockToFacing(renderer.blockAccess, x, y, z, 2); + boolean south = canConnectToBlockToFacing(renderer.blockAccess, x, y, z, 3); + boolean east = canConnectToBlockToFacing(renderer.blockAccess, x, y, z, 4); + boolean west = canConnectToBlockToFacing(renderer.blockAccess, x, y, z, 5); + + renderer.renderCrossedSquares(Block.vine, x, y, z); + + return super.renderBlock(renderer, x, y, z); + } + + @Override + public void renderBlockSecondPass(RenderBlocks renderer, int x, int y, int z, boolean bFirstPassResult) { + secondPass = true; + if (renderer.blockAccess.getBlockMetadata(x,y,z) > 0) + { + renderer.setOverrideBlockTexture(overlay[renderer.blockAccess.getBlockMetadata(x,y,z)]); + renderer.renderCrossedSquares(this,x,y,z); + renderer.clearOverrideBlockTexture(); + } + secondPass = false; + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/HollowLogBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/HollowLogBlock.java new file mode 100644 index 0000000..3e1f514 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/HollowLogBlock.java @@ -0,0 +1,426 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.blocks.FenceBlock; +import btw.block.blocks.PlanksBlock; +import btw.block.model.BlockModel; +import btw.block.model.FenceModel; +import btw.block.util.RayTraceUtils; +import btw.client.render.util.RenderUtils; +import btw.community.sockthing.sockscrops.block.models.HollowLogModel; +import btw.community.sockthing.sockscrops.interfaces.BlockInterface; +import btw.entity.mob.ChickenEntity; +import btw.item.BTWItems; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.src.*; + +import java.util.List; +import java.util.Random; + +public class HollowLogBlock extends BaseLogBlock implements BlockInterface { + + protected static final HollowLogModel model = new HollowLogModel(); + public static final String[] treeTypes = new String[] {"oak", "spruce", "birch", "jungle"}; + public static final String[] treeTypes2 = new String[] {"blood"}; + + public static final String[] decoTreeTypes = new String[] {"darkOak", "acacia", "mahogany", "mangrove"}; + public static final String[] decoTreeTypes2 = new String[] {"hazel", "fir", "aspen", "willow"}; + public static final String[] decoTreeTypes3 = new String[] {"cherry", "redwood"}; + public static final String[] treeTextureTop = new String[] {"hollow_log_oak_top", "hollow_log_spruce_top", "hollow_log_birch_top", "hollow_log_jungle_top"}; + public static final String[] treeTextureInner = new String[] {"fcBlockLogStrippedOak_side", "fcBlockLogStrippedSpruce_side", "fcBlockLogStrippedBirch_side", "fcBlockLogStrippedJungle_side"}; + public static final String[] treeTextureSide = new String[] {"tree_side", "tree_spruce", "tree_birch", "tree_jungle"}; + + public static final String[] treeTextureTop2 = new String[] {"hollow_log_blood_top"}; + public static final String[] treeTextureInner2 = new String[] {"hollow_log_blood_inner"}; + public static final String[] treeTextureSide2 = new String[] {"fcBlockBloodWood_side"}; + + private final String name; + private final String[] topTextures; + private final String[] innerTextures; + private final String[] sideTextures; + + private final float hardnessModifier = 1F; + + public HollowLogBlock(int blockID, String name, String[] topTextures, String[] innerTextures, String[] sideTextures) { + super(blockID); + + setHardness(1.25F * this.hardnessModifier); // vanilla 2 + setResistance(3.33F * this.hardnessModifier); // odd value to match vanilla resistance set through hardness of 2 + + setCreativeTab(CreativeTabs.tabDecorations); + setUnlocalizedName(name); + this.name = name; + this.topTextures = topTextures; + this.innerTextures = innerTextures; + this.sideTextures = sideTextures; + + } + + @Override + public int getFurnaceBurnTime(int iItemDamage) { + return PlanksBlock.getFurnaceBurnTimeByWoodType(iItemDamage); //quarter of regular logs + } + + + @Environment(EnvType.CLIENT) + public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) + { + for (int i = 0; i < topTextures.length; i++) { + par3List.add(new ItemStack(par1, 1, i)); + } + } + + + @Override + public boolean canBeReplacedByLeaves(int blockID) { + return false; + } + + @Override + public int idDropped(int par1, Random par2Random, int par3) { + return this.blockID; + } + + @Override + public boolean dropComponentItemsOnBadBreak( World world, int i, int j, int k, int iMetadata, float fChanceOfDrop ) + { + dropItemsIndividually( world, i, j, k, BTWItems.sawDust.itemID, 1, 0, fChanceOfDrop ); + dropItemsIndividually( world, i, j, k, BTWItems.bark.itemID, 1, iMetadata & 3, fChanceOfDrop ); + + return true; + } + + @Override + public void addCollisionBoxesToList(World world, int i, int j, int k, AxisAlignedBB boundingBox, List list, Entity entity) { +// if (entity instanceof ChickenEntity || (entity instanceof EntityAgeable && ((EntityAgeable)entity).isChild() )) +// { +// BlockModel tempModel = new BlockModel(); +// tempModel.addBox(0,0,0,1,1,1); +// tempModel.addIntersectingBoxesToCollisionList(world, i, j, k, boundingBox, list); +// } +// else { +// BlockModel tempModel = assembleTemporaryModel(world, i,j,k); +// tempModel.addIntersectingBoxesToCollisionList(world, i, j, k, boundingBox, list); +// } + + BlockModel tempModel = assembleTemporaryModel(world, i,j,k); + tempModel.addIntersectingBoxesToCollisionList(world, i, j, k, boundingBox, list); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean isNormalCube(IBlockAccess blockAccess, int i, int j, int k) { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public MovingObjectPosition collisionRayTrace( World world, int i, int j, int k, Vec3 startRay, Vec3 endRay ) + { + RayTraceUtils rayTrace = new RayTraceUtils( world, i, j, k, startRay, endRay ); + + BlockModel transformedModel = assembleTemporaryModel(world, i,j,k); + + transformedModel.addToRayTrace(rayTrace); + + return rayTrace.getFirstIntersection(); + } + + protected BlockModel assembleTemporaryModel(IBlockAccess blockAccess, int i, int j, int k) { +// BlockModel tempModel = model.makeTemporaryCopy(); +// +// for (int iTempFacing = 2; iTempFacing <= 5; iTempFacing++) { +// BlockModel tempSupportsModel = model.side.makeTemporaryCopy(); +// +// tempSupportsModel.rotateAroundYToFacing(iTempFacing); +// +// tempSupportsModel.makeTemporaryCopyOfPrimitiveList(tempModel); +// } + + BlockModel tempModel = model.makeTemporaryCopy(); + + int meta = blockAccess.getBlockMetadata(i,j,k); + int facing = meta >> 2 & 3; + + if (facing == 1) { + tempModel.tiltToFacingAlongY(4); + } + else if (facing == 2 ) { + tempModel.tiltToFacingAlongY(2); + } + + return tempModel; + } + + protected BlockModel assembleTemporaryModelForRender(IBlockAccess blockAccess, int i, int j, int k) { + BlockModel tempModel = model.makeTemporaryCopy(); + + int meta = blockAccess.getBlockMetadata(i,j,k); + int facing = meta >> 2 & 3; + + if (facing == 1) { + tempModel.tiltToFacingAlongY(1); + } + else if (facing == 2 ) { + tempModel.tiltToFacingAlongY(2); + } + + return tempModel; + } + + @Override + public AxisAlignedBB getBlockBoundsFromPoolBasedOnState(IBlockAccess blockAccess, int i, int j, int k) { + AxisAlignedBB fenceBox = AxisAlignedBB.getAABBPool().getAABB(0D, 0D, 0D, 1D, 1D, 1D); + + return fenceBox; + } + + @Override + public boolean hasLargeCenterHardPointToFacing(IBlockAccess blockAccess, int i, int j, int k, int side) + { + int meta = blockAccess.getBlockMetadata(i,j,k); + int rot = meta & 12; + int type = meta & 3; + + + return (rot == 0 && (side == 1 || side == 0)) ? false : + (rot == 4 && (side == 5 || side == 4)) ? false : + (rot == 8 && (side == 2 || side == 3)) ? false : + true; + } + + @Override + public boolean canToolsStickInBlock(IBlockAccess blockAccess, int i, int j, int k) { + return super.canToolsStickInBlock(blockAccess, i, j, k); + } + + @Override + public boolean renderBlock( RenderBlocks renderer, int i, int j, int k ) + { + int meta = renderer.blockAccess.getBlockMetadata(i, j, k); + int type = meta & 3; + int rot = meta & 12; + + renderer.setRenderBounds( 0D, 0D, 0D, 1D, 1D, 1D ); + renderer.renderBlockLog( this, i, j, k ); + + // INSIDE + if (rot == 0) + { + renderer.renderFaceXPos(this, i - 14/16D, j, k, tree_inner[type]); + renderer.renderFaceXNeg(this, i + 14/16D, j, k, tree_inner[type]); + renderer.renderFaceZPos(this, i, j, k - 14/16D, tree_inner[type]); + renderer.renderFaceZNeg(this, i, j, k + 14/16D, tree_inner[type]); + } + else if (rot == 4) + { + renderer.setUVRotateTop(1); + renderer.setUVRotateEast(1); + renderer.setUVRotateWest(1); + renderer.setUVRotateBottom(1); + + renderer.renderFaceZPos(this, i, j, k - 14/16D, tree_inner[type]); + renderer.renderFaceZNeg(this, i, j, k + 14/16D, tree_inner[type]); + renderer.renderFaceYPos(this, i, j - 14/16D, k, tree_inner[type]); + renderer.renderFaceYNeg(this, i, j + 14/16D, k, tree_inner[type]); + } + else if (rot == 8) + { + renderer.setUVRotateSouth(1); + renderer.setUVRotateNorth(1); + + renderer.renderFaceXPos(this, i - 14/16D, j, k, tree_inner[type]); + renderer.renderFaceXNeg(this, i + 14/16D, j, k, tree_inner[type]); + renderer.renderFaceYPos(this, i, j - 14/16D, k, tree_inner[type]); + renderer.renderFaceYNeg(this, i, j + 14/16D, k, tree_inner[type]); + } + + renderer.setUVRotateTop(0); + renderer.setUVRotateEast(0); + renderer.setUVRotateWest(0); + renderer.setUVRotateBottom(0); + renderer.setUVRotateSouth(0); + renderer.setUVRotateNorth(0); + + + return true; + } + + @Override + public void renderBlockAsItem(RenderBlocks renderer, int iItemDamage, float fBrightness) { + + super.renderBlockAsItem(renderer, iItemDamage, fBrightness); + + int i = 0; + int j; + int k; + + int meta = iItemDamage; + int type = meta & 3; + int rot = meta & 12; + // INSIDE + + if (rot == 0) + { + renderer.setRenderBounds( + 1.001/16F, 0.001F, 1.001/16F, + 1.999/16F, 0.999F, 14.999/16F ); + RenderUtils.renderInvBlockWithTexture( renderer, this, -0.5F, -0.5F, -0.5F, tree_inner[type] ); + + renderer.setRenderBounds( + 14/16F, 0.001F, 1.001/16F, + 14.999/16F, 0.999F, 14.999/16F ); + RenderUtils.renderInvBlockWithTexture( renderer, this, -0.5F, -0.5F, -0.5F, tree_inner[type] ); + + renderer.setRenderBounds( + 1.001/16F, 0.001F, 1.001/16F, + 14.999/16F, 0.999F, 1.999/16F ); + RenderUtils.renderInvBlockWithTexture( renderer, this, -0.5F, -0.5F, -0.5F, tree_inner[type] ); + + renderer.setRenderBounds( + 1.001/16F, 0.001F, 14/16F, + 14.999/16F, 0.999F, 14.999/16F ); + RenderUtils.renderInvBlockWithTexture( renderer, this, -0.5F, -0.5F, -0.5F, tree_inner[type] ); + } + + + renderer.setUVRotateTop(0); + renderer.setUVRotateEast(0); + renderer.setUVRotateWest(0); + renderer.setUVRotateBottom(0); + renderer.setUVRotateSouth(0); + renderer.setUVRotateNorth(0); + + + + } + + + @Environment(EnvType.CLIENT) + private Icon[] tree_top; + + @Environment(EnvType.CLIENT) + private Icon[] tree_inner; + @Environment(EnvType.CLIENT) + private Icon[] tree_side; + + @Override + public void registerIcons(IconRegister register) + { + this.tree_top = new Icon[topTextures.length]; + + for (int i = 0; i < topTextures.length; ++i) + { + this.tree_top[i] = register.registerIcon(topTextures[i]); + } + + this.tree_inner = new Icon[innerTextures.length]; + + for (int i = 0; i < innerTextures.length; ++i) + { + this.tree_inner[i] = register.registerIcon(innerTextures[i]); + } + + this.tree_side = new Icon[sideTextures.length]; + + for (int i = 0; i < sideTextures.length; ++i) + { + this.tree_side[i] = register.registerIcon(sideTextures[i]); + } + } + + public Icon getIcon(int side, int meta) + { + int rot = meta & 12; + int type = meta & 3; + + return (rot == 0 && (side == 1 || side == 0) ? this.tree_top[type] : + (rot == 4 && (side == 5 || side == 4) ? this.tree_top[type] : + (rot == 8 && (side == 2 || side == 3) ? this.tree_top[type] : + this.tree_side[type]))); + } + +// @Override +// @Environment(EnvType.CLIENT) +// public boolean shouldSideBeRendered(IBlockAccess blockAccess, int iNeighborI, int iNeighborJ, int iNeighborK, int iSide) { +// return currentBlockRenderer.shouldSideBeRenderedBasedOnCurrentBounds(iNeighborI, iNeighborJ, iNeighborK, iSide); +// } +// +// @Override +// @Environment(EnvType.CLIENT) +// public boolean renderBlock(RenderBlocks renderBlocks, int i, int j, int k) { +// renderBlocks.clearUVRotation(); +// +// BlockModel tempModel = assembleTemporaryModel(renderBlocks.blockAccess, i, j, k); +// +// return tempModel.renderAsBlock(renderBlocks, this, i, j, k); +// } +// +// @Override +// @Environment(EnvType.CLIENT) +// public void renderBlockAsItem(RenderBlocks renderBlocks, int iItemDamage, float fBrightness) { +// model.renderAsItemBlock(renderBlocks, this, iItemDamage); +// } + + @Override + @Environment(EnvType.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, MovingObjectPosition rayTraceHit) { + AxisAlignedBB tempBox = model.boxBoundsCenter.makeTemporaryCopy(); + + return tempBox.offset(rayTraceHit.blockX, rayTraceHit.blockY, rayTraceHit.blockZ); + } + +// @Override +// @Environment(EnvType.CLIENT) +// public Icon getIcon(int side, int metadata) { +// int facing = metadata >> 2 & 3; +// +// if ((metadata & 12) == 12) { +// if (side > 1) { +// return trunkIconArray[metadata & 3]; +// } +// else { +// return trunkTopIconArray[metadata & 3]; +// } +// } +// else { +// if (facing == 0 && (side == 0 || side == 1)) { +// return topIconArray[metadata & 3]; +// } +// else if (facing == 1 && (side == 4 || side == 5)) { +// return topIconArray[metadata & 3]; +// } +// else if (facing == 2 && (side == 2 || side == 3)) { +// return topIconArray[metadata & 3]; +// } +// } +// +// return super.getIcon(side, metadata); +// } +// + +// +// @Override +// @Environment(EnvType.CLIENT) +// public void registerIcons(IconRegister iconRegister) { +// topIconArray = new Icon[trunkTextureTypes.length]; +// trunkIconArray = new Icon[trunkTextureTypes.length]; +// trunkTopIconArray = new Icon[trunkTextureTypes.length]; +// +// for (int i = 0; i < trunkIconArray.length; i++) { +// topIconArray[i] = iconRegister.registerIcon(topTextureTypes[i]); +// trunkIconArray[i] = iconRegister.registerIcon(trunkTextureTypes[i]); +// trunkTopIconArray[i] = iconRegister.registerIcon(trunkTopTextureTypes[i]); +// } +// +// super.registerIcons(iconRegister); +// } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/LargeFlowerpotBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/LargeFlowerpotBlock.java new file mode 100644 index 0000000..15905b3 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/LargeFlowerpotBlock.java @@ -0,0 +1,668 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.blocks.*; +import btw.block.model.BlockModel; +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.block.models.LargeFlowerpotModel; +import btw.community.sockthing.sockscrops.block.tileentities.LargeFlowerPotTileEntity; +import btw.community.sockthing.sockscrops.item.SCItems; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import btw.item.BTWItems; +import btw.item.util.ItemUtils; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.src.*; + +import java.util.Random; + +public class LargeFlowerpotBlock extends BlockContainer { + + protected static final LargeFlowerpotModel model = new LargeFlowerpotModel(); + protected static final double HEIGHT = (6 / 16D ); + protected static final double WIDTH = (6 / 16D ); + protected static final double HALF_WIDTH = (WIDTH / 2D ); + protected static final double DEPTH = (6 / 2D ); + + public LargeFlowerpotBlock(int blockID, String name) { + super(blockID, Material.circuits); + + setUnlocalizedName(name); + } + + @Override + public TileEntity createNewTileEntity(World var1) { + return new LargeFlowerPotTileEntity(); + } + + public int idDropped(int par1, Random par2Random, int par3) + { + return SCItems.largeFlowerpot.itemID; + } + + @Override + public int idPicked(World par1World, int par2, int par3, int par4) { + return SCItems.largeFlowerpot.itemID; + } + + @Override + public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int side, float clickX, float clickY, float clickZ ) + { + ItemStack heldStack = player.inventory.getCurrentItem(); + TileEntity tileEntity = world.getBlockTileEntity(i,j,k); + LargeFlowerPotTileEntity potTile = (LargeFlowerPotTileEntity) tileEntity; + + int slot = getTargetedSlot(world, i, j, k, clickX, clickZ); + + if (heldStack != null){ + if (potTile.getStackInSlot(slot) == null && potTile.isValidStack(heldStack)){ + ItemStack stackToPlace = heldStack.copy(); + stackToPlace.stackSize = 1; + + potTile.setStackInSlot(heldStack, slot); + + heldStack.stackSize--; + return true; + } + } + else { + + if (potTile.getStackInSlot(slot) != null) + { + if (!world.isRemote) ItemUtils.ejectStackFromBlockTowardsFacing(world, i, j, k, potTile.getStackInSlot(slot), side); + potTile.setStackInSlot(null, slot); + return true; + } + } + + return false; + } + + private int getTargetedSlot(World world, int i, int j, int k, float clickX, float clickZ) { + int meta = world.getBlockMetadata(i, j, k); + + if ( isRotated(meta) ) { + if (clickZ < 6/16F){ + return 0; + } + else if (clickZ > 10/16F){ + return 2; + } + else { + return 1; + } + } + else { + if (clickX < 6/16F){ + return 0; + } + else if (clickX > 10/16F){ + return 2; + } + else { + return 1; + } + } + } + + @Override + public int onBlockPlaced(World world, int x, int y, int z, int facing, float clickX, float clickY, float clickZ, int metadata) { + if (facing > 1) return facing; + return 0; + } + + @Override + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving player, ItemStack heldStack){ + int rotation = ((MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3)) % 2; + int metadata = world.getBlockMetadata(i,j,k); + if (metadata < 2) + { + world.setBlockMetadata(i,j,k, rotation); + } + +// System.out.println("meta: " + world.getBlockMetadata(i,j,k)); + } + + public boolean isOpaqueCube() + { + return false; + } + + public boolean renderAsNormalBlock() + { + return false; + } + + private boolean isValidBlock(World world, int x, int y, int z) + { + Block blockBelow = Block.blocksList[world.getBlockId(x,y,z)]; + if (blockBelow != null) + { + if (blockBelow instanceof MouldingBlock ) + { + int metaBelow = world.getBlockMetadata(x,y,z); + if (metaBelow >=8 && metaBelow <= 11) return true; + else return false; + } + else if (blockBelow instanceof SidingAndCornerBlock) + { + int metaBelow = world.getBlockMetadata(x,y,z); + if (metaBelow == 4 || metaBelow == 6 || metaBelow == 8 || metaBelow == 10) return true; + else return false; + } + else if (blockBelow instanceof StairsBlock) + { + int metaBelow = world.getBlockMetadata(x,y,z); + if (metaBelow >= 0 && metaBelow <= 3) return true; + else return false; + } + } + + + return false; + } + + public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) + { + return super.canPlaceBlockAt(par1World, par2, par3, par4) && (isValidBlock(par1World, par2, par3 - 1, par4) || par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4)); + } + + + @Override + public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { + dropContents(par1World, par2, par3, par4); + super.breakBlock(par1World, par2, par3, par4, par5, par6); + } + + public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) + { + if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && !isValidBlock(par1World, par2, par3 - 1, par4)) + { + this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); + + dropContents(par1World, par2, par3, par4); + + par1World.setBlockToAir(par2, par3, par4); + } + } + + private void dropContents(World world, int i, int j, int k) { + TileEntity tileEntity = world.getBlockTileEntity(i,j,k); + LargeFlowerPotTileEntity potTile = (LargeFlowerPotTileEntity) tileEntity; + + ItemStack[] contents = potTile.getContents(); + + for (int slot = 0; slot < 3; slot++) + { + if (contents[slot] != null) + { + if (!world.isRemote) + { + this.dropBlockAsItem_do(world, i, j, k, contents[slot]); + } + + potTile.setStackInSlot(null, slot); + } + } + } + + @Override + public boolean canGroundCoverRestOnBlock(World world, int i, int j, int k) + { + return world.doesBlockHaveSolidTopSurface( i, j - 1, k ); + } + + @Override + public float groundCoverRestingOnVisualOffset(IBlockAccess blockAccess, int i, int j, int k) + { + return -1F; + } + + public boolean isRotated(int meta) { + return meta == 1 || meta == 4 || meta == 5; + } + + protected BlockModel rotateModel(IBlockAccess blockAccess, int i, int j, int k, BlockModel tempModel) { + + int meta = blockAccess.getBlockMetadata(i,j,k); + + if (isRotated( meta )) { + tempModel.rotateAroundYToFacing(4); + } + + if (meta == 2) tempModel.translate(0,0,4/16D); + if (meta == 3) tempModel.translate(0,0,-4/16D); + if (meta == 4) tempModel.translate(4/16D,0,0); + if (meta == 5) tempModel.translate(-4/16D,0,0); + + return tempModel; + } + + @Override + public AxisAlignedBB getBlockBoundsFromPoolBasedOnState(IBlockAccess blockAccess, int i, int j, int k) { + AxisAlignedBB tempBounds = model.bounds.makeTemporaryCopy(); + rotateBounds(blockAccess, i, j, k, tempBounds); + return tempBounds; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) { + AxisAlignedBB tempBounds = model.bounds.makeTemporaryCopy(); + rotateBounds(world, i, j, k, tempBounds); + return tempBounds; + } + + private AxisAlignedBB rotateBounds(IBlockAccess blockAccess, int i, int j, int k, AxisAlignedBB tempBounds) { + int meta = blockAccess.getBlockMetadata(i, j, k); + + if (isRotated( meta )) { + tempBounds.rotateAroundYToFacing(4); + } + + if (meta == 2) tempBounds.translate(0,0,4/16D); + if (meta == 3) tempBounds.translate(0,0,-4/16D); + if (meta == 4) tempBounds.translate(4/16D,0,0); + if (meta == 5) tempBounds.translate(-4/16D,0,0); + + return tempBounds; + } + + + + //----------- Client Side Functionality -----------// + + + public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { + if (multiPass) { + double var1 = 0.5D; + double var3 = 1.0D; + return ColorizerGrass.getGrassColor(var1, var3); + } else { + return super.colorMultiplier(par1IBlockAccess, par2, par3, par4); + } + } + + @Override + public Icon getIcon(int side, int metadata) { + if (dirtPass) + { + return blockIcon = dirt; + } + return blockIcon = pot; + } + + private Icon pot; + private Icon dirt; + + private boolean multiPass; + private boolean dirtPass; + + @Override + public void registerIcons(IconRegister register) { + pot = register.registerIcon("large_flowerpot"); + dirt = register.registerIcon("dirt"); + } + + @Override + @Environment(EnvType.CLIENT) + public boolean renderBlock(RenderBlocks renderer, int i, int j, int k) + { + + BlockModel potModel = rotateModel(renderer.blockAccess, i, j, k, model.makeTemporaryCopy()); + potModel.renderAsBlock(renderer, this, i, j, k); + + dirtPass = true; + BlockModel dirt = rotateModel(renderer.blockAccess, i, j, k, model.dirt.makeTemporaryCopy()); + dirt.renderAsBlock(renderer, this, i, j, k); + dirtPass = false; + + return true; + } + + @Override + public void renderBlockSecondPass(RenderBlocks renderer, int i, int j, int k, boolean bFirstPassResult) { + + TileEntity tileEntity = renderer.blockAccess.getBlockTileEntity(i,j,k); + LargeFlowerPotTileEntity potTile = (LargeFlowerPotTileEntity) tileEntity; + + ItemStack[] contents = potTile.getContents(); + + for (int slot = 0; slot < 3; slot++) + { + if (contents[slot] != null) + { + renderSlotContents(renderer, i,j,k, slot, contents[slot]); + } + } + } + + private void renderSlotContents(RenderBlocks renderer, int i, int j, int k, int slot, ItemStack stack) { + + if (stack != null){ + if (shouldRenderSpecial(stack)){ + renderSpecial(renderer,i,j,k,slot,stack); + } + else { + renderPlant(renderer, i, j, k, slot, 0F, getBlock(stack), getMetadata(stack, false)); + } + } + } + + private void renderSpecial(RenderBlocks renderer, int i, int j, int k, int slot, ItemStack stack) { + if (stack.itemID == Block.cactus.blockID) + { + renderCactus(renderer, i, j, k, renderer.blockAccess.getBlockMetadata(i,j,k), slot); + } +// else if (getIsDoubleTall(stack)){ +// renderPlant(renderer, i, j, k, slot,0F, getBlock(stack), getMetadata(stack, false)); +// renderPlant(renderer, i, j, k, slot, 12/16F, getBlock(stack), getMetadata(stack, true)); +// +// if (stack.itemID == SCItems.sunflower.itemID){ +// renderSunflowerFace(renderer, i, j, k, slot); +// } +// +// } + } + + private void renderSunflowerFace(RenderBlocks renderer, int i, int j, int k, int slot) { + float xShift = 0; + float zShift = 0; + int rotationAngleX = 0; + int potMeta = renderer.blockAccess.getBlockMetadata(i, j, k); + + if (potMeta == 2) { + zShift -= 4/16F; + rotationAngleX = 90; + } + if (potMeta == 3) { + zShift += 4/16F; + rotationAngleX = -90; + } + if (potMeta == 4) { + xShift -= 4/16F; + rotationAngleX = 180; + } + if (potMeta == 5) { + xShift += 4/16F; + rotationAngleX = 0; + } + + + if (isRotated(potMeta)){ + if (slot == 0){ + zShift += 4/16F; + } + else if (slot == 2){ + zShift -= 4/16F; + } + } + else { + if (slot == 0){ + xShift += 4/16F; + } + else if (slot == 2){ + xShift -= 4/16F; + } + } + + SCRenderUtils.renderHorizonzalPaneSunflower(renderer, this, i, j, k, + xShift + -1/16D, 1F + 1/32F, zShift, + rotationAngleX, 0, -45, + DoubleTallPlantBlock.getSunflowerFace(0), DoubleTallPlantBlock.getSunflowerFace(1), + false, false, 0.0D); + } + + private boolean shouldRenderSpecial(ItemStack stack) { + if (getIsDoubleTall(stack)) return true; + if (stack.itemID == Block.cactus.blockID) return true; + return false; + } + + private void renderCactus(RenderBlocks render, int x, int y, int z, int meta, int slot) { + render.setRenderAllFaces(true); + + float minX = 6/16F + 1/32F; + float maxX = 10/16F - 1/32F; + + float minY = 4/16F; + float maxY = 16/16F; + + float minZ = 6/16F + 1/32F; + float maxZ = 10/16F - 1/32F; + + if (slot == 0) + { + maxY = 14/16F; + } + else if (slot == 1) + { + maxY = 16/16F; + } + else if (slot == 2) + { + maxY = 15/16F; + } + + double xShift = 0D; + double zShift = 0D; + + + if (meta == 0) + { + if (slot == 0) + { + xShift = -4/16D; + zShift = 0; + } + else if (slot == 1) + { + xShift = 0; + zShift = 0; + } + else if (slot == 2) + { + xShift = 4/16D; + zShift = 0; + } + } + else if (meta == 1) + { + if (slot == 0) + { + xShift = 0; + zShift = -4/16D; + } + else if (slot == 1) + { + xShift = 0; + zShift = 0; + } + else if (slot == 2) + { + xShift = 0; + zShift = 4/16D; + } + } + else if (meta == 2) + { + if (slot == 0) + { + xShift = -4/16D; + zShift = +5/16D; + } + else if (slot == 1) + { + xShift = 0; + zShift = +5/16D; + } + else if (slot == 2) + { + xShift = 4/16D; + zShift = 5/16D; + } + } + else if (meta == 3) + { + if (slot == 0) + { + xShift = -4/16D; + zShift = -5/16D; + } + else if (slot == 1) + { + xShift = 0; + zShift = -5/16D; + } + else if (slot == 2) + { + xShift = 4/16D; + zShift = -5/16D; + } + } + else if (meta == 4) + { + if (slot == 0) + { + xShift = 5/16D; + zShift = -4/16D; + } + else if (slot == 1) + { + xShift = 5/15D; + zShift = 0; + } + else if (slot == 2) + { + xShift = 5/16D; + zShift = 4/16D; + } + } + else if (meta == 5) + { + if (slot == 0) + { + xShift = -5/16D; + zShift = -4/16D; + } + else if (slot == 1) + { + xShift = -5/15D; + zShift = 0; + } + else if (slot == 2) + { + xShift = -5/16D; + zShift = 4/16D; + } + } + + render.setRenderBounds(minX + xShift, minY, minZ + zShift, maxX + xShift, maxY, maxZ + zShift); + render.renderStandardBlock(Block.cactus, x, y, z); + + render.setRenderAllFaces(false); + render.setRenderBounds(0, 0, 0, 1, 1, 1); + } + + private boolean getIsDoubleTall(ItemStack stack) { + if (stack == null) return false; + +// if (stack.itemID == SCBlocks.doubleTallPlant.blockID) return true; +// if (stack.itemID == SCItems.sunflower.itemID) return true; + + return false; + } + + private int getMetadata(ItemStack stack, boolean isTopBlock) { + + if (stack == null) return 0; + + if (stack.itemID == Block.tallGrass.blockID) return 1; +// else if (stack.itemID == SCBlocks.doubleTallPlant.blockID && stack.getItemDamage() == DoubleTallPlantBlock.GRASS){ +// if (isTopBlock) return DoubleTallPlantBlock.GRASS + 8; +// else return DoubleTallPlantBlock.GRASS; +// } +// else if (stack.itemID == SCBlocks.doubleTallPlant.blockID && stack.getItemDamage() == DoubleTallPlantBlock.FERN){ +// if (isTopBlock) return DoubleTallPlantBlock.FERN + 8; +// else return DoubleTallPlantBlock.FERN; +// } +// else if (stack.itemID == SCItems.sunflower.itemID) { +// if (isTopBlock) return DoubleTallPlantBlock.SUNFLOWER + 8; +// else return DoubleTallPlantBlock.SUNFLOWER; +// } + else if (stack.itemID == SCItems.blueberryRoots.itemID) return 5; + else if (stack.itemID == SCItems.sweetberryRoots.itemID) return 5; + + return stack.getItemDamage(); + } + + private Block getBlock(ItemStack stack) { + if (stack.itemID == BTWItems.brownMushroom.itemID) return Block.mushroomBrown; + else if (stack.itemID == BTWItems.redMushroom.itemID) return Block.mushroomRed; + else if (stack.itemID == SCItems.sunflower.itemID) return SCBlocks.doubleTallPlant; + else if (stack.itemID == SCItems.blueberryRoots.itemID) return SCBlocks.blueberryBush; + else if (stack.itemID == SCItems.sweetberryRoots.itemID) return SCBlocks.sweetberryBush; + else { + Block block = Block.blocksList[stack.itemID]; + if (block != null) return block; + } + + + return null; + } + + private void renderPlant(RenderBlocks renderer, int i, int j, int k, int slot, float yShift, Block block, int metadata) { + + float xShift = 0; + float zShift = 0; + + int potMeta = renderer.blockAccess.getBlockMetadata(i,j,k); + + if (potMeta == 2) zShift += 4/16F; + if (potMeta == 3) zShift -= 4/16F; + if (potMeta == 4) xShift += 4/16F; + if (potMeta == 5) xShift -= 4/16F; + + + if (isRotated(potMeta)){ + if (slot == 0){ + zShift -= 4/16F; + } + else if (slot == 2){ + zShift += 4/16F; + } + } + else { + if (slot == 0){ + xShift -= 4/16F; + } + else if (slot == 2){ + xShift += 4/16F; + } + } + +// renderer.setOverrideBlockTexture(icon); + SCRenderUtils.renderCrossedSquares(renderer, block, metadata, i, j, k, + xShift, 5/16F + yShift, zShift, + 0.75F, + false); +// renderer.clearOverrideBlockTexture(); + } + + @Override + @Environment(EnvType.CLIENT) + public boolean shouldSideBeRendered( IBlockAccess blockAccess, int i, int j, int k, int iSide ) + { + if ( iSide == 0 ) + { + return !blockAccess.isBlockOpaqueCube(i, j, k); + } + + return true; + } + + @Override + public void renderBlockAsItem(RenderBlocks renderBlocks, int iItemDamage, float fBrightness) { + model.renderAsItemBlock(renderBlocks, this, iItemDamage); + } + + +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/MossBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/MossBlock.java new file mode 100644 index 0000000..908737a --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/MossBlock.java @@ -0,0 +1,20 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.util.Flammability; +import net.minecraft.src.Block; +import net.minecraft.src.CreativeTabs; +import net.minecraft.src.Material; +import net.minecraft.src.StepSound; + +public class MossBlock extends Block { + public MossBlock(int blockID, String name) { + super(blockID, Material.plants); + + setHardness(0.1F); + + setUnlocalizedName(name); + setFireProperties( Flammability.LEAVES ); + setStepSound(soundGrassFootstep); + setCreativeTab(CreativeTabs.tabDecorations); + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/MossCarpetBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/MossCarpetBlock.java new file mode 100644 index 0000000..eb1e84d --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/MossCarpetBlock.java @@ -0,0 +1,240 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.blocks.GroundCoverBlock; +import btw.block.util.Flammability; +import btw.community.sockthing.sockscrops.block.SCBlocks; +import net.minecraft.src.*; + +import java.util.Random; + +public class MossCarpetBlock extends GroundCoverBlock { + + public MossCarpetBlock(int blockID) + { + super(blockID, Material.plants); + setFireProperties( Flammability.LEAVES ); + setStepSound(soundGrassFootstep); + setUnlocalizedName("SCBlockMossCarpet"); + + setTickRandomly(true); + } + + @Override + public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) { + super.dropBlockAsItemWithChance(par1World, par2, par3, par4, par5, par6, par7); + } + + @Override + public void updateTick(World world, int x, int y, int z, Random rand) { + //condition for leaves to drip: if (world.isRainingAtPos(i, j + 1, k) && !world.doesBlockHaveSolidTopSurface(i, j - 1, k) && rand.nextInt(15) == 1) { + //condition for water source to drip: if (par5Random.nextInt(10) == 0 && par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && !par1World.getBlockMaterial(par2, par3 - 2, par4).blocksMovement() + //and the BlockFluid is Material.water + + boolean hasLeaves = Block.blocksList[world.getBlockId(x,y + 2,z)] instanceof BlockLeavesBase; + boolean canLeavesDrip = world.isRainingAtPos(x, y + 4, z) && !world.doesBlockHaveSolidTopSurface(x, y + 2, z); + boolean hasWaterSource = Block.blocksList[world.getBlockId(x,y + 3,z)] instanceof BlockFluid && world.getBlockMaterial(x,y + 3,z) == Material.water; + boolean canWaterDrip = world.doesBlockHaveSolidTopSurface(x, y + 2, z) && !world.getBlockMaterial(x, y + 1, z).blocksMovement(); + +// System.out.println("hasLeaves: " + hasLeaves ); +// System.out.println("canLeavesDrip: " + canLeavesDrip ); +// System.out.println("hasWaterSource: " + hasWaterSource ); +// System.out.println("canWaterDrip: " + canWaterDrip ); + + if (world.isAirBlock (x,y + 1,z) && ((hasLeaves && canLeavesDrip) || (hasWaterSource && canWaterDrip))){ +// System.out.println("Attempting to spread"); + attemptToSpreadMoss(world, x, y, z, rand); + } + } + + private float getSpreadChance() { + return 0.5F; //0.04F; + } + + protected boolean canSpreadToOrFromLocation(World world, int x, int y, int z) + { + return world.getFullBlockLightValue( x, y, z ) > 0 && !world.canBlockSeeTheSky(x,y,z); + } + + private boolean hasAdjacentMoss(World world, int x, int y, int z) { + for (int i = -1; i < 1; i++) { + for (int k = -1; k < 1; k++) { + if ( world.getBlockId(x + i, y, z + k) == this.blockID + || world.getBlockId(x + i, y - 1, z + k) == this.blockID + || world.getBlockId(x + i, y + 1, z + k) == this.blockID) + { + return true; + } + } + } + + return false; + } + + protected void attemptToSpreadMoss(World world, int i, int j, int k, Random rand) + { + // basically a copy/paste of the BlockMushroom updateTick cleaned up and with additional requirements that brown mushrooms can only grow in complete darkness + + if ( rand.nextFloat() <= getSpreadChance() && canSpreadToOrFromLocation(world, i, j, k) ) + { +// System.out.println("spreading"); + + int iHorizontalSpreadRange = 4; + int iNeighboringMushroomsCountdown = 9; + + for ( int iTempI = i - iHorizontalSpreadRange; iTempI <= i + iHorizontalSpreadRange; ++iTempI ) + { + for ( int iTempK = k - iHorizontalSpreadRange; iTempK <= k + iHorizontalSpreadRange; ++iTempK ) + { + for ( int iTempJ = j - 1; iTempJ <= j + 1; ++iTempJ ) + { + if ( world.getBlockId( iTempI, iTempJ, iTempK ) == blockID ) + { + --iNeighboringMushroomsCountdown; + + if (iNeighboringMushroomsCountdown <= 0) + { + return; + } + } + } + } + } + + int iSpreadI = i + rand.nextInt(5) - 2; + int iSpreadK = j + rand.nextInt(2) - rand.nextInt(2); + int iSpreadJ = k + rand.nextInt(5) - 2; + +// for ( int iTempCount = 0; iTempCount < 4; ++iTempCount ) +// { +// if (world.isAirBlock( iSpreadI, iSpreadK, iSpreadJ ) && canBlockStay(world, iSpreadI, iSpreadK, iSpreadJ ) && +// canSpreadToOrFromLocation(world, iSpreadI, iSpreadK, iSpreadJ) ) +// { +// i = iSpreadI; +// j = iSpreadK; +// k = iSpreadJ; +// } +// +// iSpreadI = i + rand.nextInt(3) - 1; +// iSpreadK = j + rand.nextInt(2) - rand.nextInt(2); +// iSpreadJ = k + rand.nextInt(3) - 1; +// } + + if ( world.isAirBlock( iSpreadI, iSpreadK, iSpreadJ ) && canBlockStay( world, iSpreadI, iSpreadK, iSpreadJ ) && + canSpreadToOrFromLocation(world, iSpreadI, iSpreadK, iSpreadJ) ) + { + world.setBlock( iSpreadI, iSpreadK, iSpreadJ, blockID ); +// System.out.println("spread moss"); + } + } + } + + + public boolean canBlockStay(World par1World, int par2, int par3, int par4) + { + return canPlaceBlockAt(par1World, par2, par3, par4); + } + + @Override + public boolean canPlaceBlockAt(World world, int i, int j, int k ) + { + int iBlockBelowID = world.getBlockId( i, j - 1, k ); + Block blockBelow = Block.blocksList[iBlockBelowID]; + + if ( blockBelow != null ) + { + return blockBelow.canGroundCoverRestOnBlock( world, i, j - 1, k ) || blockBelow.hasLargeCenterHardPointToFacing(world, i, j -1, k, 1); + } + + return false; + } + +// @Override +// public int colorMultiplier(IBlockAccess blockAccess, int x, int y, int z) +// { +//// int var5 = 0; +//// int var6 = 0; +//// int var7 = 0; +//// +//// for (int var8 = -1; var8 <= 1; ++var8) +//// { +//// for (int var9 = -1; var9 <= 1; ++var9) +//// { +//// int var10 = blockAccess.getBiomeGenForCoords(x + var9, z + var8).getBiomeGrassColor(); +//// var5 += (var10 & 16711680) >> 16; +//// var6 += (var10 & 65280) >> 8; +//// var7 += var10 & 255; +//// } +//// } +//// +//// return (var5 / 9 & 255) << 16 | (var6 / 9 & 255) << 8 | var7 / 9 & 255; +// +// double var1 = 1.0D; +// double var3 = 0.5D; +// //return 16777215; +// return ColorizerGrass.getGrassColor(var1, var3); +// } +// +// @Override +// public int getRenderColor(int par1) +// { +// double var1 = 1.0D; +// double var3 = 0.5D; +// return ColorizerGrass.getGrassColor(var1, var3); +// } + + private Icon mossSide; + + public static boolean secondPass; + @Override + public void registerIcons( IconRegister register ) + { + blockIcon = register.registerIcon( "moss" ); + mossSide = register.registerIcon("moss_carpet_side"); + } + + @Override + public boolean shouldSideBeRendered(IBlockAccess blockAccess, int neighborI, int neighborJ, int neighborK, int side) + { + if (secondPass) + { + if (side == 0) return false; + if (side > 1 && blockAccess.getBlockId(neighborI, neighborJ, neighborK) == SCBlocks.hollowLog.blockID) return false; + } + return true; + } + + @Override + public void renderBlockSecondPass(RenderBlocks renderBlocks, int i, int j, int k, boolean firstPassResult) + { + secondPass = true; + + float visualOffset = 0F; + + int iBlockBelowID = renderBlocks.blockAccess.getBlockId( i, j - 1, k ); + Block blockBelow = Block.blocksList[iBlockBelowID]; + + if (blockBelow != null) { + visualOffset = blockBelow.groundCoverRestingOnVisualOffset(renderBlocks.blockAccess, i, j - 1, k); + + if (visualOffset < 0.0F) + { + j -= 1; + + visualOffset += 1F; + } + + } + + renderBlocks.setOverrideBlockTexture(mossSide); + renderBlocks.setRenderBounds( + 0 - 1/1024D, 0 + visualOffset, 0 - 1/1024D, + 1 + 1/1024D, 1 + visualOffset, 1 + 1/1024D + ); + renderBlocks.renderStandardBlock(this, i, j - 1, k); + + renderBlocks.clearOverrideBlockTexture(); + + secondPass = false; + } + +} \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/MultiFlowerBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/MultiFlowerBlock.java new file mode 100644 index 0000000..7e663ef --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/MultiFlowerBlock.java @@ -0,0 +1,166 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.blocks.FlowerBlock; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import net.minecraft.src.*; + +import java.util.Random; + +public class MultiFlowerBlock extends FlowerBlock { + + public MultiFlowerBlock(int blockID, String name) { + super(blockID); + initBlockBounds(0.5F - 7/16D, 0.0F, 0.5F - 7/16D, 0.5F + 7/16D, 3/16D, 0.5F + 7/16D); + setUnlocalizedName(name); + setCreativeTab(CreativeTabs.tabDecorations); + } + + @Override + public int idDropped(int par1, Random par2Random, int par3) { + return this.blockID; + } + + @Override + public int damageDropped(int par1) { + return 0; + } + + @Override + public void breakBlock(World world, int x, int y, int z, int iBlockID, int iMetadata) { + if (world.getBlockId(x,y + 1,z) == Block.snow.blockID) world.setBlockToAir(x,y + 1,z); + super.breakBlock(world, x, y, z, iBlockID, iMetadata); +// int numberDropped = getStage(iMetadata); +// for (int i = 0; i < numberDropped; i++) { +// dropBlockAsItem(world, x,y,z, iMetadata, 0); +// } + } + + public static int getDirection(int metadata) + { + return metadata & 3; + } + + public static int getStage(int metadata) { + return (metadata >> 2) & 3; // This shifts right by 2 bits and extracts the next 2 bits + } + + public static int setDirection(int metadata, int direction) { + // Ensure direction is within valid range (0 to 3) + direction = direction & 3; // Mask the input direction to use only 2 bits + // Clear the first 2 bits (direction bits) and set the new direction + return (metadata & ~3) | direction; + } + + // Method to set the stage (using the next 2 bits) + public static int setStage(int metadata, int stage) { + // Ensure stage is within valid range (0 to 3) + stage = stage & 3; // Mask the input stage to use only 2 bits + // Clear the 2 bits at position 2 and 3 (stage bits) and set the new stage + return (metadata & ~(3 << 2)) | (stage << 2); + } + + @Override + public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int iFacing, float fXClick, float fYClick, float fZClick) { + ItemStack heldStack = player.getHeldItem(); + if (heldStack != null && heldStack.itemID == this.blockID || Block.blocksList[heldStack.itemID] instanceof MultiFlowerBlock) + { + int meta = world.getBlockMetadata(i,j,k); + int stage = getStage(meta); + + if (stage < 3) { + world.setBlockMetadataWithNotify(i,j,k, setStage(meta, stage + 1)); +// heldStack.stackSize--; + return true; + } + + } + + return false; + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving player, ItemStack stack) { + int playerRot = ((MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4; + + world.setBlockMetadataWithNotify(x,y,z, setDirection(0, playerRot)); + } + + @Override + public boolean canPlaceBlockAt(World world, int i, int j, int k) { + return super.canPlaceBlockAt(world, i, j, k); + } + + @Override + public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { + + if (grassPass) + { + return par1IBlockAccess.getBiomeGenForCoords(par2, par4).getBiomeGrassColor(); + } + + return super.colorMultiplier(par1IBlockAccess, par2, par3, par4); + } + + private Icon[] flower = new Icon[4]; + private static Icon[] stalk = new Icon[4]; + private static Icon[] stalkFlower = new Icon[2]; + + protected boolean grassPass; + + @Override + public Icon getIcon(int side, int meta) { + int dir = getDirection(meta); + return flower[dir]; + } + + @Override + public void registerIcons(IconRegister register) { + for (int i = 0; i < flower.length; i++) { + flower[i] = register.registerIcon("pink_petals_"+i); + } + + for (int i = 0; i < flower.length; i++) { + stalk[i] = register.registerIcon("petals_stalk"); + } + + stalkFlower[0] = register.registerIcon("petals_stalk"); + stalkFlower[1] = register.registerIcon("petals_stalk"); + + this.blockIcon = flower[0]; + } + + @Override + public boolean renderBlock(RenderBlocks renderer, int x, int y, int z) { + int meta = renderer.blockAccess.getBlockMetadata(x,y,z); + int stage = MultiFlowerBlock.getStage(meta); + int dir = MultiFlowerBlock.getDirection(meta); + + SCRenderUtils.renderMultiFlowerBlock(renderer, this, x, y, z, flower); + + grassPass = true; + int[] numberOfStalks = { + 3, 1, 3, 1 + }; + double[][][] shifts = { + { + {3/32D, 3/32D}, {13/32D, 5/32D}, {8/32D, 12/32D}, // (xShift, zShift) for stage >= 0 + }, + { + {7/32D, -9/32D}, // (xShift, zShift) for stage >= 1 + }, + { + {-3/32D, -3/32D}, {-13/32D, -5/32D}, {-7/32D, -13/32D}, // (xShift, zShift) for stage >= 2 + }, + { + {-7/32D, 7/32D} // (xShift, zShift) for stage >= 3 + } + }; + SCRenderUtils.renderStalks(renderer, this, x, y, z, + stage, dir, + numberOfStalks, shifts, + stalk); + grassPass = false; + + return true; + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/PackedBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/PackedBlock.java new file mode 100644 index 0000000..3564152 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/PackedBlock.java @@ -0,0 +1,54 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.blocks.PillarBlock; +import btw.block.util.Flammability; +import net.minecraft.src.CreativeTabs; +import net.minecraft.src.ItemStack; +import net.minecraft.src.Material; + +import java.util.List; + +public class PackedBlock extends PillarBlock { + + + public static String[] types = new String[] { "sugarcane", "shafts" }; + + public PackedBlock(int id, Material material, String name) { + super(id, material, getTopTextureNames(name), getSideTextureNames(name)); + + setHardness( 0.5F ); + + setAxesEffectiveOn(); + + setBuoyant(); + + setFireProperties( Flammability.PLANKS ); + setCreativeTab(CreativeTabs.tabBlock); + setStepSound(soundGrassFootstep); + setUnlocalizedName(name); + } + + public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { + + for (int i = 0; i < types.length; i++) { + par3List.add(new ItemStack(par1, 1, i)); + } + + } + + private static String[] getSideTextureNames(String name) { + String[] sideNames = new String[types.length]; + for (int i = 0; i < types.length; i++) { + sideNames[i] = name + "_" + types[i] + "_side"; + } + return sideNames; + } + + private static String[] getTopTextureNames(String name) { + String[] topNames = new String[types.length]; + for (int i = 0; i < types.length; i++) { + topNames[i] = name + "_" + types[i] + "_top"; + } + return topNames; + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/PlanterGrassBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/PlanterGrassBlock.java index 6a1a3cf..ef4301c 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/PlanterGrassBlock.java +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/PlanterGrassBlock.java @@ -26,6 +26,8 @@ public PlanterGrassBlock(int blockID, String name) { super(blockID, name); } + + protected float getPlantGrowthChance(int metadata) { int nutritionLevel = NutritionUtils.getPlanterNutritionLevel(metadata); switch (nutritionLevel) { @@ -198,16 +200,19 @@ private void growPlantsAbovePlanter(World world, int x, int y, int z, Random ran } else world.setBlockWithNotify(x, y + 1, z, Block.plantYellow.blockID); } else if (plantType < 8) { if (rand.nextInt(4) == 0) { - world.setBlockAndMetadataWithNotify(x, y + 1, z, Block.tallGrass.blockID, 2); //Fern + if (rand.nextInt(4) == 0) { + world.setBlockAndMetadataWithNotify(x, y + 1, z, SCBlocks.shortGrass.blockID, 1); //Short Grass + } + else world.setBlockAndMetadataWithNotify(x, y + 1, z, Block.tallGrass.blockID, 2); //Fern } else world.setBlockAndMetadataWithNotify(x, y + 1, z, Block.tallGrass.blockID, 1); //Grass } else { if (world.isAirBlock(x, y + 2, z)) { if (rand.nextInt(2) == 0) { - world.setBlockAndMetadataWithNotify(x, y + 1, z, SCBlocks.doubleTallGrass.blockID, DoubleTallGrassBlock.FERN); - world.setBlockAndMetadataWithNotify(x, y + 2, z, SCBlocks.doubleTallGrass.blockID, DoubleTallGrassBlock.setTopBlock(DoubleTallGrassBlock.FERN)); + world.setBlockAndMetadataWithNotify(x, y + 1, z, SCBlocks.doubleTallPlant.blockID, DoubleTallPlantBlock.FERN); + world.setBlockAndMetadataWithNotify(x, y + 2, z, SCBlocks.doubleTallPlant.blockID, DoubleTallPlantBlock.setTopBlock(DoubleTallPlantBlock.FERN)); } else { - world.setBlockAndMetadataWithNotify(x, y + 1, z, SCBlocks.doubleTallGrass.blockID, DoubleTallGrassBlock.GRASS); - world.setBlockAndMetadataWithNotify(x, y + 2, z, SCBlocks.doubleTallGrass.blockID, DoubleTallGrassBlock.setTopBlock(DoubleTallGrassBlock.GRASS)); + world.setBlockAndMetadataWithNotify(x, y + 1, z, SCBlocks.doubleTallPlant.blockID, DoubleTallPlantBlock.GRASS); + world.setBlockAndMetadataWithNotify(x, y + 2, z, SCBlocks.doubleTallPlant.blockID, DoubleTallPlantBlock.setTopBlock(DoubleTallPlantBlock.GRASS)); } } } diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/ShortGrassBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/ShortGrassBlock.java new file mode 100644 index 0000000..ec52729 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/ShortGrassBlock.java @@ -0,0 +1,112 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.BTWBlocks; +import btw.block.blocks.TallGrassBlock; +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import btw.item.items.ShearsItem; +import com.prupe.mcpatcher.cc.ColorizeBlock; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.src.*; + +import java.util.List; + +public class ShortGrassBlock extends TallGrassBlock { + + private static final String[] grassTypes = new String[] {"deadbush", "short_grass", "fern"}; + private static final double HALF_WIDTH = 0.4F; + + public ShortGrassBlock(int iBlockID, String name) { + super(iBlockID); + + initBlockBounds(0.5D - HALF_WIDTH, 0D, 0.5D - HALF_WIDTH, + 0.5D + HALF_WIDTH, 0.5D, 0.5D + HALF_WIDTH); + + setUnlocalizedName(name); + } + + public void getSubBlocks(int blockID, CreativeTabs tabs, List list) + { + list.add(new ItemStack(blockID, 1, 1)); + + /* + for (int var4 = 1; var4 < 3; ++var4) + { + par3List.add(new ItemStack(par1, 1, var4)); + } + */ + } + + @Override + public boolean canBlockStay(World world, int i, int j, int k) { + return world.getBlockId(i,j + 1,k) == SCBlocks.mossCarpet.blockID || super.canBlockStay(world, i, j, k); + } + + @Override + public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) + { + if (!par1World.isRemote && par2EntityPlayer.getCurrentEquippedItem() != null && par2EntityPlayer.getCurrentEquippedItem().getItem() instanceof ShearsItem) + { + par2EntityPlayer.addStat(StatList.mineBlockStatArray[this.blockID], 1); + this.dropBlockAsItem_do(par1World, par3, par4, par5, new ItemStack(SCBlocks.shortGrass, 1, par6)); + } + else + { + super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); + } + } + + @Override + @Environment(EnvType.CLIENT) + public int getRenderColor(int par1) + { + double var1 = 0.5D; + double var3 = 1.0D; + return ColorizerGrass.getGrassColor(var1, var3); + } + + @Environment(EnvType.CLIENT) + private Icon[] iconArray; + + @Override + @Environment(EnvType.CLIENT) + public Icon getIcon(int par1, int par2) + { + if (par2 >= this.iconArray.length) + { + par2 = 0; + } + + return this.iconArray[par2]; + } + + @Override + @Environment(EnvType.CLIENT) + public void registerIcons(IconRegister par1IconRegister) + { + this.iconArray = new Icon[grassTypes.length]; + + for (int var2 = 0; var2 < this.iconArray.length; ++var2) + { + this.iconArray[var2] = par1IconRegister.registerIcon(grassTypes[var2]); + } + } + + @Override + @Environment(EnvType.CLIENT) + public boolean renderBlock(RenderBlocks renderer, int i, int j, int k) { + renderer.setRenderBounds(getBlockBoundsFromPoolBasedOnState( + renderer.blockAccess, i, j, k) ); + + SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i,j,k, + this.iconArray[renderer.blockAccess.getBlockMetadata(i,j,k)], + true, + true); + //renderer.renderCrossedSquares( this, i, j, k ); + + BTWBlocks.weeds.renderWeeds(this, renderer, i, j, k); + + return true; + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/SideShroomBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/SideShroomBlock.java new file mode 100644 index 0000000..898ff4c --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/SideShroomBlock.java @@ -0,0 +1,402 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.blocks.FlowerBlock; +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import btw.crafting.util.FurnaceBurnTime; +import net.minecraft.src.*; + +import java.util.List; + +public class SideShroomBlock extends FlowerBlock { + + public static final String[] MUSHROOM_TYPES = {"white", "black", "brown", "red" }; + public SideShroomBlock(int blockID, String name) { + super(blockID); + + setFurnaceBurnTime( FurnaceBurnTime.KINDLING ); + + setCreativeTab(CreativeTabs.tabDecorations); + setUnlocalizedName(name); + } + + @Override + public int damageDropped(int meta) { + if (getType(meta) == 1) + { + return 4; + } + if (getType(meta) == 2) + { + return 8; + } + if (getType(meta) == 3) + { + return 12; + } + else return 0; + } + + + @Override + //Copied from BlockButton + public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side) + { + int blockID = 0; + if (side == 2){ + blockID = world.getBlockId(x,y,z + 1); + } + else if (side == 3){ + blockID = world.getBlockId(x,y,z -1); + } + else if (side == 4){ + blockID = world.getBlockId(x + 1,y,z); + } + else if (side == 5){ + blockID = world.getBlockId(x - 1,y,z); + } + + Block block = Block.blocksList[blockID]; + if ( blockID != 0 && block.hasLargeCenterHardPointToFacing(world, x,y,z, side)) + { + return true; + } +// else return false; + return side == 2 && world.isBlockNormalCube(x, y, z + 1) ? true : (side == 3 && world.isBlockNormalCube(x, y, z - 1) ? true : (side == 4 && world.isBlockNormalCube(x + 1, y, z) ? true : side == 5 && world.isBlockNormalCube(x - 1, y, z))); + } + + //Copied from BlockButton + public boolean canPlaceBlockAt(World world, int x, int y, int z) + { + int meta = world.getBlockMetadata(x,y,z); + int dir = getDirection(meta); + if ((world.getBlockId(x - 1, y, z) == SCBlocks.hollowLog.blockID && dir == WEST ) + || (world.getBlockId(x + 1, y, z) == SCBlocks.hollowLog.blockID && dir == EAST ) + || (world.getBlockId(x, y, z - 1) == SCBlocks.hollowLog.blockID && dir == NORTH) + || (world.getBlockId(x, y, z + 1) == SCBlocks.hollowLog.blockID && dir == SOUTH)){ + return true; + } + return world.isBlockNormalCube(x - 1, y, z) ? true : (world.isBlockNormalCube(x + 1, y, z) ? true : (world.isBlockNormalCube(x, y, z - 1) ? true : world.isBlockNormalCube(x, y, z + 1))); + } + + @Override + public boolean canBlockStay( World world, int i, int j, int k ) + { + return canPlaceBlockAt(world, i, j, k); + } + + public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) + { + par3List.add(new ItemStack(par1, 1, 0)); + par3List.add(new ItemStack(par1, 1, 4)); + par3List.add(new ItemStack(par1, 1, 8)); + par3List.add(new ItemStack(par1, 1, 12)); + } + //Direction + private final int SOUTH = 0; + private final int WEST = 1; + private final int NORTH = 2; + private final int EAST = 3; + + @Override + public int onBlockPlaced( World world, int i, int j, int k, int targetFace, float fClickX, float fClickY, float fClickZ, int iMetadata ) + { + //System.out.println("TargetFace: " + targetFace); + + if (targetFace > 1) + { + if (targetFace == 2) + return SOUTH; + else if (targetFace == 3) + return NORTH; + else if (targetFace == 4) + return EAST; + else + return WEST; + } + else + { + return iMetadata; + } + } + + @Override + public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving player, ItemStack stack) { + + //int playerRotation = ((MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) + 2) % 4; + int itemDamage = stack.getItemDamage(); + int meta = world.getBlockMetadata(i, j, k); +// System.out.println(playerRotation); + + world.setBlockAndMetadata(i, j, k, this.blockID, meta + (itemDamage) ); + } + + //Copied from BlockButton and modified + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, int neighbour) { + boolean shouldDrop = false; + int meta = world.getBlockMetadata(x, y, z); + int dir = getDirection(meta); + Block blockw = Block.blocksList[world.getBlockId(x-1,y,z)]; + Block blocke = Block.blocksList[world.getBlockId(x+1,y,z)]; + Block blockn = Block.blocksList[world.getBlockId(x,y,z-1)]; + Block blocks = Block.blocksList[world.getBlockId(x,y,z+1)]; + + if ((!world.isBlockNormalCube(x - 1, y, z) && !(blockw instanceof HollowLogBlock)) && dir == WEST) + { + shouldDrop = true; + } + + if ((!world.isBlockNormalCube(x + 1, y, z) && !(blocke instanceof HollowLogBlock)) && dir == EAST) + { + shouldDrop = true; + } + + if ((!world.isBlockNormalCube(x, y, z - 1) && !(blockn instanceof HollowLogBlock)) && dir == NORTH) + { + shouldDrop = true; + } + + if ((!world.isBlockNormalCube(x, y, z + 1) && !(blocks instanceof HollowLogBlock)) && dir == SOUTH) + { + shouldDrop = true; + } + + if (shouldDrop) + { + this.dropBlockAsItem(world, x, y, z, damageDropped(world.getBlockMetadata(x,y,z)), 0); + world.setBlockToAir(x, y, z); + } + } + + private int getDirection(int meta) { + return meta & 3; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public Icon getIcon(int side, int metadata) { + return blockIcon = bottom[getType(metadata)]; + } + + private Icon[] top = new Icon[4]; + private Icon[] middle = new Icon[4]; + private Icon[] bottom = new Icon[4]; + + @Override + public void registerIcons(IconRegister register) { + for (int i = 0; i < top.length; i++) { + top[i] = register.registerIcon("sideshroom_" + MUSHROOM_TYPES[i] + "_0"); + middle[i] = register.registerIcon("sideshroom_" + MUSHROOM_TYPES[i] + "_1"); + bottom[i] = register.registerIcon("sideshroom_" + MUSHROOM_TYPES[i] + "_2"); + } + } + + @Override + public AxisAlignedBB getBlockBoundsFromPoolBasedOnState(IBlockAccess blockAccess, int i, int j, int k) { + + float centerX = 8/16F; + float centerY = 8/16F; + float centerZ = 8/16F; + + float width = 14/16F; + float height = 8/16F; + float depth = 6/16F; + + int meta = blockAccess.getBlockMetadata(i, j, k); + int dir = getDirection(meta); + + if (dir == NORTH ) + { + centerZ = centerZ - 5/16F; + } + else if (dir == SOUTH) + { + centerZ = centerZ + 5/16F; + } + else if (dir == EAST) + { + width = 6/16F; + depth = 14/16F; + + centerX = centerX + 5/16F; + } + else if (dir == WEST) + { + width = 6/16F; + depth = 14/16F; + + centerX = centerX - 5/16F; + } + + + AxisAlignedBB box = new AxisAlignedBB( + centerX - width/2, centerY - height/2, centerZ - depth/2, + centerX + width/2, centerY + height/2, centerZ + depth/2 + ); + + return box; + } + +// private final int SOUTH = 0; +// private final int WEST = 1; +// private final int NORTH = 2; +// private final int EAST = 3; + + @Override + public boolean renderBlock(RenderBlocks renderer, int x, int y, int z) { + + int meta = renderer.blockAccess.getBlockMetadata(x, y, z); + int blockID = renderer.blockAccess.getBlockId(x, y, z); + Block block = Block.blocksList[blockID]; + + Tessellator tess = Tessellator.instance; + tess.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z)); + float brightness = 1.0F; + int colorMultiplier = block.colorMultiplier(renderer.blockAccess, x, y, z); + float r = (float)(colorMultiplier >> 16 & 255) / 255.0F; + float g = (float)(colorMultiplier >> 8 & 255) / 255.0F; + float b = (float)(colorMultiplier & 255) / 255.0F; + tess.setColorOpaque_F(brightness * r, brightness * g, brightness * b); + + renderer.setRenderBounds(0,0,0,1,1,1); + + int dir = getDirection(meta); + +// if (dir == EAST) +// { +// renderer.setUVRotateTop(2); +// renderer.setUVRotateBottom(1); +// } +// else if (dir == WEST) +// { +// renderer.setUVRotateTop(1); +// renderer.setUVRotateBottom(2); +// } +// else if (dir == NORTH) +// { +// renderer.setUVRotateTop(3); +// renderer.setUVRotateBottom(3); +// } + + long hash = (long) (x * 3129871L) ^ (long) z * 116129781L ^ (long)y; + hash = hash * hash * 42317861L + hash * 11L; + + // Generate values for numberOfMushrooms and random mushroom types + int numberOfMushrooms = (int) (Math.abs(hash) % 3); + int randMushroom1 = (int) (Math.abs(hash >> 2) % 3); + int randMushroom2 = (int) (Math.abs(hash >> 4) % 3); + int randMushroom3 = (int) (Math.abs(hash >> 6) % 3); + + Icon[][][] mushroom = new Icon[3][][]; + mushroom[0] = new Icon[][]{top, middle, bottom}; + mushroom[1] = new Icon[][]{middle, bottom, top}; + mushroom[2] = new Icon[][]{bottom, top, middle}; + + if (numberOfMushrooms == 0) + { + renderMushroomLayer(renderer, this, x, y, z,0, meta, mushroom[0][randMushroom1]); + } + + if (numberOfMushrooms == 1) + { + // Check and ensure that randMushroom2 and randMushroom3 are not the same + if (randMushroom2 == randMushroom3) { + randMushroom3 = (randMushroom3 + 1) % 3; // Increment and wrap to ensure it's different + } + + renderMushroomLayer(renderer, this, x, y, z,-3/16F, meta, mushroom[1][randMushroom2]); + renderMushroomLayer(renderer, this, x, y, z,3/16F, meta, mushroom[1][randMushroom3]); + } + + if (numberOfMushrooms == 2) + { + // Ensure randMushroom1 and randMushroom2 are not the same + if (randMushroom1 == randMushroom2) { + randMushroom2 = (randMushroom2 + 1) % 3; // Change randMushroom2 to a different value + } + + // Ensure randMushroom1 and randMushroom3 are not the same + if (randMushroom1 == randMushroom3) { + randMushroom3 = (randMushroom3 + 1) % 3; // Change randMushroom3 to a different value + } + + // Ensure randMushroom2 and randMushroom3 are not the same + if (randMushroom2 == randMushroom3) { + randMushroom3 = (randMushroom3 + 1) % 3; // Change randMushroom3 to avoid matching randMushroom2 + } + + renderMushroomLayer(renderer, this, x, y, z, -4/16F, meta, mushroom[2][randMushroom1]); + renderMushroomLayer(renderer, this, x, y, z, 0/16F, meta, mushroom[2][randMushroom2]); + renderMushroomLayer(renderer, this, x, y, z,4/16F, meta, mushroom[2][randMushroom3]); + } + + renderer.clearUVRotation(); + + return true; + } + + private void renderMushroomLayer(RenderBlocks renderer, Block block, int x, int y, int z, float yShift, int metadata, Icon[] icons) { + int meta = renderer.blockAccess.getBlockMetadata(x, y, z); + int dir = getDirection(meta); + + double rotateX = -12.5D; + double rotateY = 0; + double rotateZ = 0; + + double xShift = 0; + double zShift = 0; + + if (dir == EAST) + { + rotateY = 90; + xShift = -1/64D; + } + else if (dir == WEST) + { + rotateY = -90; + xShift = 1/64D; + } + else if (dir == NORTH) + { + rotateY = 180; + zShift = 1/64D; + } + else if (dir == SOUTH) + { + zShift = -1/64D; + } + + SCRenderUtils.renderHorizonzalPaneWithRotation(renderer, block, x,y,z, + xShift, yShift, zShift, + rotateX, rotateY, rotateZ, + icons[getType(meta)], + icons[getType(meta)]); + } + + public static int getType(int meta) { + if (meta < 4) + { + return 0; + } + else if (meta < 8) + { + return 1; + } + else if (meta < 12) + { + return 2; + } + else return 3; + } +} + diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/StrawBaleBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/StrawBaleBlock.java index df4b498..f7ca07b 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/StrawBaleBlock.java +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/StrawBaleBlock.java @@ -1,10 +1,12 @@ package btw.community.sockthing.sockscrops.block.blocks; +import btw.community.sockthing.sockscrops.interfaces.BlockInterface; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.src.IconRegister; +import net.minecraft.src.ItemStack; -public class StrawBaleBlock extends BaleBlock { +public class StrawBaleBlock extends BaleBlock implements BlockInterface { public StrawBaleBlock(int blockID, String name) { super(blockID, name); } diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/SunflowerBaseBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/SunflowerBaseBlock.java new file mode 100644 index 0000000..5df200a --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/SunflowerBaseBlock.java @@ -0,0 +1,271 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.blocks.CropsBlock; +import btw.block.blocks.WeedsBlock; +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.item.SCItems; +import btw.community.sockthing.sockscrops.item.items.KnifeItem; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import btw.item.items.ShearsItem; +import btw.item.util.ItemUtils; +import net.minecraft.src.*; + +import java.util.Random; + +public abstract class SunflowerBaseBlock extends CropsBlock { + protected String name; + + public SunflowerBaseBlock(int iBlockID, String name) { + super(iBlockID); + setUnlocalizedName(name); + + this.name = name; + } + + @Override + public int idDropped(int iMetadata, Random rand, int iFortuneModifier) { + + return 0; + } + + + protected boolean canGrowOnBlock(World world, int i, int j, int k ) + { + Block blockOn = Block.blocksList[world.getBlockId( i, j, k )]; + + if (isTopBlock()) + { + return blockOn != null && blockOn instanceof SunflowerBaseBlock; + } + + return blockOn != null && blockOn.canDomesticatedCropsGrowOnBlock( world, i, j, k ); + } + + @Override + public void harvestBlock(World world, EntityPlayer player, int i, int j, int k, int iMetadata ) + { + super.harvestBlock( world, player, i, j, k, iMetadata ); + + if( !world.isRemote ) + { + if ( world.getBlockId( i, j - 1, k ) == SCBlocks.sunflowerCrop.blockID ) + { + if (isFullyGrown(iMetadata)) dropSunflower(world, player, i, j, k); + world.setBlockToAir(i, j - 1, k); + } + + //TODO: No idea why the below doesn't trigger + if (world.getBlockId( i, j + 1, k ) == SCBlocks.sunflowerTopCrop.blockID){ + int metaAbove = world.getBlockMetadata(i,j + 1,k); + if (getGrowthLevel( metaAbove ) >= getMaxGrowthStage()){ + dropSunflower(world, player, i, j, k); + } + } + } + } + + static void dropSunflower(World world, EntityPlayer player, int i, int j, int k) { + ItemStack equippedItem = player.getCurrentEquippedItem(); + if ( equippedItem!= null && (equippedItem.getItem() instanceof ShearsItem || equippedItem.getItem() instanceof KnifeItem)) + { + ItemUtils.dropSingleItemAsIfBlockHarvested(world, i, j, k, SCItems.sunflower.itemID, 0); + player.getCurrentEquippedItem().damageItem(1, player); + } + } + + protected abstract boolean isTopBlock(); + + protected abstract int getMaxGrowthStage(); + + protected void incrementGrowthLevel(World world, int i, int j, int k ) + { + int iGrowthLevel = getGrowthLevel( world, i, j, k ) + 1; + + setGrowthLevel( world, i, j, k, iGrowthLevel ); + + if ( isFullyGrown( world, i, j, k ) ) + { + Block blockBelow = Block.blocksList[world.getBlockId( i, j - 1, k )]; + + if ( blockBelow != null ) + { + blockBelow.notifyOfFullStagePlantGrowthOn( world, i, j - 1, k, this ); + + if (!isTopBlock()) + { + int meta = updateRotationForTime(world); + world.setBlockAndMetadata(i, j + 1, k, SCBlocks.sunflowerTopCrop.blockID, meta); + } + } + } + } + + public static int updateRotationForTime( World world ) + { + int timeOfDay = (int)( world.worldInfo.getWorldTime() % 24000L ); + + boolean isMorning = timeOfDay >= 0 && timeOfDay < 3000; + boolean isPreNoon = timeOfDay >= 3000 && timeOfDay < 6000; + boolean isAfterNoon = timeOfDay >= 6000 && timeOfDay < 9000; + boolean isEvening = timeOfDay >= 9000 && timeOfDay < 12000; + + boolean earlyNight = timeOfDay >= 12000 && timeOfDay < 15000; + boolean preMoon = timeOfDay >= 15000 && timeOfDay < 18000; + boolean afterMoon = timeOfDay >= 18000 && timeOfDay < 21000; + boolean lateNight = timeOfDay >= 21000 && timeOfDay < 24000; + + int rotation = 0; + + if (isMorning) rotation = 0; + else if (isPreNoon) rotation = 1; + else if (isAfterNoon) rotation = 2; + else if (isEvening) rotation = 3; + else if (earlyNight) rotation = 3; + else if (preMoon) rotation = 2; + else if (afterMoon) rotation = 1; + else if (lateNight) rotation = 0; + + return rotation; + } + + @Override + public boolean isBlockHydratedForPlantGrowthOn(World world, int i, int j, int k) { + return !isTopBlock(); + } + + protected int getGrowthLevel(IBlockAccess blockAccess, int i, int j, int k ) + { + return getGrowthLevel( blockAccess.getBlockMetadata( i, j, k ) ); + } + + protected int getGrowthLevel( int meta ) + { + return meta & 7; + } + + protected void setGrowthLevel( World world, int i, int j, int k, int iLevel ) + { + int iMetadata = world.getBlockMetadata( i, j, k ) & (~7); // filter out old level + + world.setBlockMetadataWithNotify( i, j, k, iMetadata | iLevel ); + + } + + protected void setGrowthLevelNoNotify( World world, int i, int j, int k, int iLevel ) + { + int iMetadata = world.getBlockMetadata( i, j, k ) & (~7); // filter out old level + + world.setBlockMetadata( i, j, k, iMetadata | iLevel ); + } + + protected boolean isFullyGrown( World world, int i, int j, int k ) + { + return isFullyGrown( world.getBlockMetadata( i, j, k ) ); + } + + protected boolean isFullyGrown( int iMetadata ) + { + return getGrowthLevel( iMetadata ) >= getMaxGrowthStage(); + } + + @Override + public AxisAlignedBB getBlockBoundsFromPoolBasedOnState( + IBlockAccess blockAccess, int i, int j, int k ) + { + float dVerticalOffset = 0; + Block blockBelow = Block.blocksList[blockAccess.getBlockId( i, j - 1, k )]; + +// if ( blockBelow != null ) +// { +// dVerticalOffset = blockBelow.GroundCoverRestingOnVisualOffset( +// blockAccess, i, j - 1, k ); +// } + + int iMetadata = blockAccess.getBlockMetadata( i, j, k ); + + if ( isFullyGrown( iMetadata ) ) + { + return AxisAlignedBB.getAABBPool().getAABB( + 0.5D - BOUNDS_HALF_WIDTH, 0D + dVerticalOffset, 0.5D - BOUNDS_HALF_WIDTH, + 0.5D + BOUNDS_HALF_WIDTH, 1D + dVerticalOffset, 0.5D + BOUNDS_HALF_WIDTH ); + } + else + { + int iGrowthLevel = getGrowthLevel( iMetadata ); + double dBoundsHeight = ( 1 + iGrowthLevel ) / 8D; + + int iWeedsGrowthLevel = getWeedsGrowthLevel( blockAccess, i, j, k ); + + if ( iWeedsGrowthLevel > 0 ) + { + dBoundsHeight = Math.max( dBoundsHeight, + WeedsBlock.getWeedsBoundsHeight( iWeedsGrowthLevel ) ); + } + + return AxisAlignedBB.getAABBPool().getAABB( + 0.5D - BOUNDS_HALF_WIDTH, 0F + dVerticalOffset, 0.5D - BOUNDS_HALF_WIDTH, + 0.5D + BOUNDS_HALF_WIDTH, dBoundsHeight + dVerticalOffset, + 0.5D + BOUNDS_HALF_WIDTH ); + } + } + + protected Icon crop[] = new Icon[4]; + protected Icon front[] = new Icon[4]; + protected Icon back[] = new Icon[4]; + + @Override + public void registerIcons(IconRegister register) + { + for (int i = 0; i < crop.length; i++) { + crop[i] = register.registerIcon(name + "_" + i); + + front[i] = register.registerIcon("sunflower_front_" + i); + back[i] = register.registerIcon("sunflower_back_" + i); + } + + blockIcon = crop[3]; + } + +// @Override +// public boolean renderBlock(RenderBlocks renderer, int i, int j, int k) +// { +// int meta = renderer.blockAccess.getBlockMetadata(i, j, k); +// +// renderStem(renderer, i, j, k, meta); +// +// if (isTopBlock()) +// { +// renderFlower(renderer, i, j, k, meta); +// } +// +// return true; +// } + +// private double getRotation(int meta) { +// int rotation = meta & 3; +// +// if (rotation == 0) return -30; +// else if (rotation == 1) return -60; +// else if (rotation == 2) return 60; +// else return 30; +// } +// +// private void renderFlower(RenderBlocks renderer, int i, int j, int k, int meta) +// { +// float flowerHeight = -4/16F + (1/16F * getGrowthLevel(meta) ); +// int growthLevel = getGrowthLevel(meta); +// +// SCRenderUtils.renderHorizonzalPaneSunflower(renderer, this, i,j,k, +// -1/16D, 2/16D + flowerHeight, 0, +// 0, 0, getRotation(meta), +// front[getGrowthLevel(meta)], back[getGrowthLevel(meta)], +// false, false, 0.0D); +// } +// +// protected void renderStem(RenderBlocks renderer, int i, int j, int k, int meta) +// { +// int growthLevel = getGrowthLevel(meta); +// +// SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i, j, k, crop[growthLevel], false); +// } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/SunflowerCropBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/SunflowerCropBlock.java new file mode 100644 index 0000000..37f1f3c --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/SunflowerCropBlock.java @@ -0,0 +1,60 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import net.minecraft.src.*; + +public class SunflowerCropBlock extends SunflowerBaseBlock { + public SunflowerCropBlock(int iBlockID, String name) { + super(iBlockID, name); + } + + @Override + protected int getMaxGrowthStage() { + return 3; + } + + @Override + protected int getCropItemID() { + return 0; + } + + @Override + protected int getSeedItemID() { + return 0; + } + + @Override + protected boolean isTopBlock() { + + return false; + } + + private Icon stem; + + @Override + public void registerIcons(IconRegister register) + { + super.registerIcons(register); + + stem = register.registerIcon(name + "_4"); + } + + @Override + public boolean renderBlock(RenderBlocks renderer, int i, int j, int k) + { + int meta = renderer.blockAccess.getBlockMetadata(i, j, k); + renderStem(renderer, i, j, k, meta); + + return true; + } + + protected void renderStem(RenderBlocks renderer, int i, int j, int k, int meta) { + + if (renderer.blockAccess.getBlockId(i, j + 1, k) == SCBlocks.sunflowerTopCrop.blockID) + { + SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i, j, k, stem, false); + } + else SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i, j, k, crop[meta], false); + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/SunflowerCropTopBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/SunflowerCropTopBlock.java new file mode 100644 index 0000000..6d00e2b --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/SunflowerCropTopBlock.java @@ -0,0 +1,194 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.item.SCItems; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import net.minecraft.src.Block; +import net.minecraft.src.IBlockAccess; +import net.minecraft.src.RenderBlocks; +import net.minecraft.src.World; + +import java.util.Random; + +public class SunflowerCropTopBlock extends SunflowerBaseBlock { + public SunflowerCropTopBlock(int iBlockID, String name) { + super(iBlockID, name); + } + + @Override + public void updateTick(World world, int i, int j, int k, Random rand ) + { + int meta = world.getBlockMetadata(i, j, k); + int rotation = damageToData(meta)[0]; + int growthLevel = damageToData(meta)[1]; + + //System.out.println("Rot: " + rotation + " - GrowthLevel: " + growthLevel); + + if ( updateIfBlockStays( world, i, j, k ) ) + { + // no plants can grow in the end + + if ( world.provider.dimensionId != 1 && !isFullyGrown( world, i, j, k ) ) + { + setFlowerRotation(world, i, j, k); + + AttemptToGrow( world, i, j, k, rand ); + } + } + } + + protected void setFlowerRotation(World world, int i, int j, int k) + { + int meta = world.getBlockMetadata(i, j, k); + int rotation = updateRotationForTime(world); + int growthLevel = damageToData(meta)[1]; + + int newMeta = dataToDamage(rotation, growthLevel); + + world.setBlockMetadataWithNotify(i, j, k, newMeta); + } + + protected void AttemptToGrow(World world, int x, int y, int z, Random rand) { + if (getWeedsGrowthLevel(world, x, y, z) == 0 && canGrowAtCurrentLightLevel(world, x, y, z)) { + Block blockBelow = Block.blocksList[world.getBlockId(x, y - 1, z)]; + + if (blockBelow != null && blockBelow.isBlockHydratedForPlantGrowthOn(world, x, y - 1, z)) { + float fGrowthChance = getBaseGrowthChance(world, x, y, z) * + blockBelow.getPlantGrowthOnMultiplier(world, x, y - 2, z, this); + + if (rand.nextFloat() <= fGrowthChance) { + IncrementGrowthLevel(world, x, y, z); + } + } + } + } + + protected void IncrementGrowthLevel( World world, int i, int j, int k ) + { + int meta = world.getBlockMetadata(i, j, k); + int rotation = updateRotationForTime(world); + int growthLevel = damageToData(meta)[1]; + + int newMeta = dataToDamage(rotation, growthLevel + 1); + + world.setBlockMetadataWithNotify( i, j, k, newMeta); + } + + @Override + public int getWeedsGrowthLevel(IBlockAccess blockAccess, int i, int j, int k ) + { + int iBlockBelowID = blockAccess.getBlockId( i, j - 2, k ); + Block blockBelow = Block.blocksList[iBlockBelowID]; + + if ( blockBelow != null && iBlockBelowID != blockID ) + { + return blockBelow.getWeedsGrowthLevel( blockAccess, i, j - 2, k ); + } + + return 0; + } + + + + @Override + protected int getMaxGrowthStage() { + return 3; + } + + @Override + protected int getCropItemID() { + return SCItems.sunflower.itemID; + } + + @Override + protected int getSeedItemID() { + return 0; + } + + @Override + protected boolean isTopBlock() { + return true; + } + + protected int getGrowthLevel( int meta ) + { + return damageToData(meta)[1]; + +// return meta & 7; + } + + protected void setGrowthLevel( World world, int i, int j, int k, int iLevel ) + { + int iMetadata = world.getBlockMetadata( i, j, k ); + + world.setBlockMetadataWithNotify( i, j, k, iMetadata + 4); + } + + protected boolean isFullyGrown( World world, int i, int j, int k ) + { + return isFullyGrown( world.getBlockMetadata( i, j, k ) ); + } + + protected boolean isFullyGrown( int iMetadata ) + { + return getGrowthLevel( iMetadata ) >= getMaxGrowthStage(); + } + + public static int dataToDamage(int rotation, int growthLevel) + { + return rotation | growthLevel << 2; + } + + protected static int[] damageToData(int damage) + { + int rotation = damage & 3; + int growthLevel = (damage >> 2) & 3; + + return new int[] { rotation, growthLevel }; + } + + @Override + public boolean renderBlock(RenderBlocks renderer, int i, int j, int k) + { + int meta = renderer.blockAccess.getBlockMetadata(i, j, k); + + renderStem(renderer, i, j, k, meta); + + renderFlower(renderer, i, j, k, meta); + + return true; + } + + protected void renderStem(RenderBlocks renderer, int i, int j, int k, int meta) + { + int growthLevel = damageToData(meta)[1]; + + SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i, j, k, crop[growthLevel], false); + } + + private double getRotation(int meta) { + int rotation = damageToData(meta)[0]; + + if (rotation == 0) return -60; + else if (rotation == 1) return -30; + else if (rotation == 2) return 30; + else return 60; + } + + private void renderFlower(RenderBlocks renderer, int i, int j, int k, int meta) + { + int rotation = damageToData(meta)[0]; + int growthLevel = damageToData(meta)[1]; + float flowerHeight = - (3 - growthLevel) * 2/16F; + + double xShift = -1/16D; + + if (getRotation(meta) > 0) xShift = 1/16D; + + SCRenderUtils.renderHorizonzalPaneSunflower(renderer, this, i,j,k, + xShift, 2/16D + flowerHeight, 0, + 0, 0, getRotation(meta), + front[growthLevel], back[growthLevel], + false, false, 0.0D); + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/TallPlantBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/TallPlantBlock.java new file mode 100644 index 0000000..add043d --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/TallPlantBlock.java @@ -0,0 +1,213 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import btw.block.blocks.FlowerBlock; +import btw.item.util.ItemUtils; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.src.*; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +public class TallPlantBlock extends FlowerBlock { + private String baseTexture; + private String[] names; + + public TallPlantBlock(int blockID, String baseTexture, String[] names) { + super(blockID); + this.setUnlocalizedName(baseTexture); + this.baseTexture = baseTexture; + this.names = names; + } + + @Override + public int idDropped(int metadata, Random rand, int fortuneModifier) { + if (isTopBlock(metadata)) { + return this.blockID; + } + else { + return 0; + } + } + + @Override + public int damageDropped(int metadata) { + return metadata & 7; + } + + @Override + public AxisAlignedBB getBlockBoundsFromPoolBasedOnState(IBlockAccess blockAccess, int x, int y, int z) { + int metadata = blockAccess.getBlockMetadata(x, y, z); + float minHeight; + float maxHeight; + + if (this.isTopBlock(metadata)) { + minHeight = -1F; + maxHeight = this.getHeight(); + } + else { + minHeight = 0F; + maxHeight = 1 + this.getHeight(); + } + + return AxisAlignedBB.getBoundingBox(0.5F - this.getHalfWidth(), minHeight, 0.5F - this.getHalfWidth(), + 0.5F + this.getHalfWidth(), maxHeight, 0.5F + this.getHalfWidth()); + } + + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving player, ItemStack itemStack) { + if (world.getBlockId(x, y + 1, z) == 0) { + world.setBlockAndMetadataWithNotify(x, y + 1, z, this.blockID, this.setTopBlock(world.getBlockMetadata(x, y, z), true)); + } + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, int neighbourID) { + int metadata = world.getBlockMetadata(x, y, z); + + if (isTopBlock(metadata)) { + if (world.getBlockId(x, y - 1, z) != this.blockID) { + world.setBlockToAir(x, y, z); + int idDropped = this.idDropped(metadata, world.rand, 1); + + if (idDropped != 0) { + ItemUtils.dropSingleItemAsIfBlockHarvested(world, x, y, z, idDropped, this.damageDropped(metadata)); + } + } + } + else { + if (world.getBlockId(x, y + 1, z) != this.blockID) { + world.setBlockToAir(x, y, z); + } + } + + super.onNeighborBlockChange(world, x, y, z, neighbourID); + } + + @Override + public boolean canPlaceBlockAt(World world, int x, int y, int z) { + return super.canPlaceBlockAt(world, x, y, z) && world.getBlockId(x, y + 1, z) == 0; + } + + @Override + public boolean canBlockStay(World world, int x, int y, int z) { + int metadata = world.getBlockMetadata(x, y, z); + + if (isTopBlock(metadata)) { + return world.getBlockId(x, y - 1, z) == this.blockID; + } + else { + return super.canBlockStay(world, x, y, z) && world.getBlockId(x, y + 1, z) == this.blockID; + } + } + + @Override + protected boolean canGrowOnBlock(World world, int x, int y, int z) { + int metadata = world.getBlockMetadata(x, y, z); + + if (isTopBlock(metadata)) { + return world.getBlockId(x, y - 1, z) == this.blockID; + } + else { + return super.canGrowOnBlock(world, x, y, z); + } + } + + //------------- Class Specific Methods ------------// + + public String[] getNames() { + return names; + } + + public ArrayList getSpawnableList() { + ArrayList spawnableList = new ArrayList<>(); + + for (int i = 0; i < this.names.length; i++) { + spawnableList.add(i); + } + + return spawnableList; + } + + public float getHalfWidth() { + return 0.4F; + } + + public float getHeight() { + return 0.8F; + } + + public boolean isTopBlock(IBlockAccess blockAccess, int x, int y, int z) { + return isTopBlock(blockAccess.getBlockMetadata(x, y, z)); + } + + public boolean isTopBlock(int metadata) { + return (metadata & 8) != 0; + } + + public void setTopBlock(World world, int x, int y, int z, boolean isTop) { + int metadata = world.getBlockMetadata(x, y, z); + world.setBlockMetadata(x, y, z, this.setTopBlock(metadata, isTop)); + } + + public int setTopBlock(int metadata, boolean isTop) { + if (isTop) { + return metadata | 8; + } + else { + return metadata & 7; + } + } + + //----------- Client Side Functionality -----------// + + @Environment(EnvType.CLIENT) + private Icon[] upperIcons; + @Environment(EnvType.CLIENT) + private Icon[] lowerIcons; + + @Environment(EnvType.CLIENT) + @Override + public Icon getIcon(int side, int metadata) { + if (isTopBlock(metadata)) { + return upperIcons[metadata & 7]; + } + else { + return lowerIcons[metadata & 7]; + } + } + + @Environment(EnvType.CLIENT) + @Override + public Icon getBlockTexture(IBlockAccess blockAccess, int x, int y, int z, int side) { + int metadata = blockAccess.getBlockMetadata(x, y, z); + + if (isTopBlock(metadata)) { + return upperIcons[metadata & 7]; + } + else { + return lowerIcons[metadata & 7]; + } + } + + @Environment(EnvType.CLIENT) + @Override + public void registerIcons(IconRegister register) { + upperIcons = new Icon[names.length]; + lowerIcons = new Icon[names.length]; + + for (int i = 0; i < names.length; i++) { + upperIcons[i] = register.registerIcon(baseTexture + "_" + names[i] + "_top"); + lowerIcons[i] = register.registerIcon(baseTexture + "_" + names[i] + "_bottom"); + } + } + + @Environment(EnvType.CLIENT) + @Override + public void getSubBlocks(int blockID, CreativeTabs creativeTabs, List list) { + for (int i = 0; i < names.length; i++) { + list.add(new ItemStack(blockID, 1, i)); + } + } +} \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/blocks/WaterPlantBlock.java b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/WaterPlantBlock.java new file mode 100644 index 0000000..3e374ee --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/blocks/WaterPlantBlock.java @@ -0,0 +1,102 @@ +package btw.community.sockthing.sockscrops.block.blocks; + +import java.util.List; + +import btw.block.blocks.LilyPadBlock; +import btw.community.sockthing.sockscrops.utils.SCRenderUtils; +import net.minecraft.src.*; + +public class WaterPlantBlock extends LilyPadBlock { + + public static String[] types = {"tall_grass", "short_grass"}; + + public static final int TALL_GRASS = 0; + public static final int SHORT_GRASS = 1; + + public WaterPlantBlock(int iBlockID, String name) { + super(iBlockID); + setHardness(0.0F); + setStepSound(soundGrassFootstep); + setUnlocalizedName(name); + } + + @Override + public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { + for (int i = 0; i < types.length; i++) { + par3List.add(new ItemStack(par1, 1, i)); + } + } + + @Override + public boolean canPlaceBlockAt(World world, int i, int j, int k) { + int targetBlock = world.getBlockId(i, j, k); + int targetBlockBelow = world.getBlockId(i, j - 1, k); + int targetBlockBelowThat = world.getBlockId(i, j - 2, k); + return targetBlockBelow == Block.waterStill.blockID && (targetBlockBelowThat == Block.dirt.blockID || targetBlockBelowThat == Block.sand.blockID) && (targetBlock == 0); + } + + private boolean secondRenderpass = false; + + private Icon[] icon = new Icon[8]; + private Icon[] roots = new Icon[8]; + + @Override + public void registerIcons(IconRegister register) { + icon[0] = register.registerIcon("tallgrass"); + icon[1] = register.registerIcon("short_grass"); + roots[0] = register.registerIcon("tall_plant_grass_bottom"); + } + + @Override + public Icon getIcon(int side, int meta) { + return blockIcon = icon[meta]; + } + + /** + * Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called + * when first determining what to render. + */ + public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) + { + return par1IBlockAccess.getBiomeGenForCoords(par2, par4).getBiomeGrassColor(); + } + + @Override + public int getRenderColor(int par1) + { + double var1 = 0.5D; + double var3 = 1.0D; + return ColorizerGrass.getGrassColor(var1, var3); + } + + @Override + public boolean renderBlock(RenderBlocks renderer, int i, int j, int k ) + { + SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i, j - 1, k, roots[0], true, true, 4/16D); + renderer.clearOverrideBlockTexture(); + + return true; + } + + @Override + public void renderBlockSecondPass(RenderBlocks renderer, int i, int j, int k, boolean bFirstPassResult) + { + int meta = renderer.blockAccess.getBlockMetadata(i, j, k); + + secondRenderpass = true; + + SCRenderUtils.renderCrossedSquaresWithTexture(renderer, this, i, j, k, icon[meta], true, true, 4/16D); + + secondRenderpass = false; + } + + @Override + public void renderBlockAsItem(RenderBlocks renderBlocks, int damage, float fBrightness) + { + renderBlocks.setOverrideBlockTexture(icon[damage]); + renderBlocks.renderBlockAsItemVanilla(this, damage, fBrightness); + renderBlocks.clearOverrideBlockTexture(); + + } + +} \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/models/HollowLogModel.java b/src/main/java/btw/community/sockthing/sockscrops/block/models/HollowLogModel.java new file mode 100644 index 0000000..a5fea90 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/models/HollowLogModel.java @@ -0,0 +1,99 @@ +package btw.community.sockthing.sockscrops.block.models; + +import btw.block.model.BlockModel; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.src.AxisAlignedBB; +import net.minecraft.src.Block; +import net.minecraft.src.RenderBlocks; + +public class HollowLogModel extends BlockModel { + protected static final double WALL_THICKNESS = ( 2D / 16D ); + protected static final double ZFIX = ( 1 / 1024D); + public BlockModel modelItem; + public BlockModel side; + + public AxisAlignedBB boxBoundsCenter; + public AxisAlignedBB[] modelBounds; + + @Override + protected void initModel() { + // north + addBox(0D, 0D, 0D, + WALL_THICKNESS, 1D, 1D); + + addBox(1D - WALL_THICKNESS, 0D, 0D, + 1D, 1D, 1D); + + addBox(WALL_THICKNESS, 0D, 0D, + 1D - WALL_THICKNESS, 1D, WALL_THICKNESS); + + addBox(WALL_THICKNESS, 0D, 1D - WALL_THICKNESS, + 1D - WALL_THICKNESS, 1D, 1D); + + modelBounds = new AxisAlignedBB[4]; + + side = new BlockModel(); + side.addBox(0D, 0D, ZFIX, + WALL_THICKNESS, 1D, 1D - ZFIX); + + // north + modelBounds[0] = new AxisAlignedBB(0D, 0D, 0D, + WALL_THICKNESS, 1D, 1D); + +// // south +// addBox(0D, 0D, 1D - WALL_THICKNESS, +// 1D, 1D, 1D); +// +// // west +// addBox(0D , 0D, WALL_THICKNESS, +// WALL_THICKNESS , 1D, 1D - WALL_THICKNESS); +// +// // west +// addBox(1D - WALL_THICKNESS , 0D, WALL_THICKNESS, +// 1D , 1D, 1D - WALL_THICKNESS); + + + modelItem = new BlockModel(); + // north + modelItem.addBox(0D, 0D, 0D, + 1D, 1D, WALL_THICKNESS); + + // south + modelItem.addBox(0D, 0D, 1D - WALL_THICKNESS, + 1D, 1D, 1D); + + // west + modelItem.addBox(0D , 0D, WALL_THICKNESS, + WALL_THICKNESS , 1D, 1D - WALL_THICKNESS); + + // west + modelItem.addBox(1D - WALL_THICKNESS , 0D, WALL_THICKNESS, + 1D , 1D, 1D - WALL_THICKNESS); + // collision volumes + boxBoundsCenter = new AxisAlignedBB( + 0D, 0D, 0D, + 1D, 1D, 1D); + + +// +// // south +// modelBounds[1] = new AxisAlignedBB(0D, 0D, 1D - WALL_THICKNESS, +// 1D, 1D, 1D); +// +// // west +// modelBounds[2] = new AxisAlignedBB(0D , 0D, WALL_THICKNESS, +// WALL_THICKNESS , 1D, 1D - WALL_THICKNESS); +// +// // west +// modelBounds[3] = new AxisAlignedBB(1D - WALL_THICKNESS , 0D, WALL_THICKNESS, +// 1D , 1D, 1D - WALL_THICKNESS); + } + + @Override + @Environment(EnvType.CLIENT) + public void renderAsItemBlock(RenderBlocks renderBlocks, Block block, int iItemDamage) + { + modelItem.renderAsItemBlock(renderBlocks, block, iItemDamage); + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/models/LargeFlowerpotModel.java b/src/main/java/btw/community/sockthing/sockscrops/block/models/LargeFlowerpotModel.java new file mode 100644 index 0000000..3d14ba9 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/models/LargeFlowerpotModel.java @@ -0,0 +1,54 @@ +package btw.community.sockthing.sockscrops.block.models; + +import btw.block.model.BlockModel; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.src.AxisAlignedBB; +import net.minecraft.src.Block; +import net.minecraft.src.BlockLeavesBase; +import net.minecraft.src.RenderBlocks; + +public class LargeFlowerpotModel extends BlockModel { + public BlockModel modelItem; + public BlockModel dirt; + + private final double CENTER = 0.5D; + private final double HEIGHT = 6/16D; + public AxisAlignedBB bounds; + + @Override + protected void initModel() { + + addBox(CENTER - 7/16D, 0D, CENTER - 3/16D, + CENTER + 7/16D, HEIGHT, CENTER - 2/16D); + + addBox(CENTER - 7/16D, 0D, CENTER + 2/16D, + CENTER + 7/16D, HEIGHT, CENTER + 3/16D); + + addBox(CENTER - 7/16D, 0D, CENTER - 2/16D, + CENTER - 6/16D, HEIGHT, CENTER + 2/16D); + + addBox(CENTER + 6/16D, 0D, CENTER - 2/16D, + CENTER + 7/16D, HEIGHT, CENTER + 2/16D); + + addBox(CENTER - 6/16D, 0D, CENTER - 2/16D, + CENTER + 6/16D, 1/16D, CENTER + 2/16D); + + dirt = new BlockModel(); + + dirt.addBox(CENTER - 6/16D, 1/16D, CENTER - 2/16D, + CENTER + 6/16D, 5/16D, CENTER + 2/16D); + + bounds = new AxisAlignedBB( + CENTER - 7/16D, 0/16D, CENTER - 3/16D, + CENTER + 7/16D, 6/16D, CENTER + 3/16D + ); + } + + @Override + @Environment(EnvType.CLIENT) + public void renderAsItemBlock(RenderBlocks renderBlocks, Block block, int iItemDamage) + { + modelItem.renderAsItemBlock(renderBlocks, block, iItemDamage); + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/tileentities/FlowerPotTileEntity.java b/src/main/java/btw/community/sockthing/sockscrops/block/tileentities/FlowerPotTileEntity.java new file mode 100644 index 0000000..24caef6 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/tileentities/FlowerPotTileEntity.java @@ -0,0 +1,184 @@ +package btw.community.sockthing.sockscrops.block.tileentities; + +import btw.block.BTWBlocks; +import btw.block.tileentity.TileEntityDataPacketHandler; +import btw.client.fx.BTWEffectManager; +import btw.community.sockthing.sockscrops.SocksCropsAddon; +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.item.SCItems; +import btw.item.BTWItems; +import btw.item.util.ItemUtils; +import deco.block.DecoBlockIDs; +import deco.block.DecoBlocks; +import net.minecraft.src.*; + +import java.util.HashSet; +import java.util.Set; + +public class FlowerPotTileEntity extends TileEntity implements TileEntityDataPacketHandler { + private boolean hasItem = false; + public static Set validItemList = new HashSet(); + + private int currentBlockID; + private int currentBlockMetadata; + + /** + * Writes a tile entity to NBT. + */ + public void writeToNBT(NBTTagCompound nbtTagCompound) + { + super.writeToNBT(nbtTagCompound); + nbtTagCompound.setInteger("StoredID", this.currentBlockID); + nbtTagCompound.setInteger("StoredMetadata", this.currentBlockMetadata); + } + + /** + * Reads a tile entity from NBT. + */ + public void readFromNBT(NBTTagCompound nbtTagCompound) + { + super.readFromNBT(nbtTagCompound); + this.currentBlockID = nbtTagCompound.getInteger("StoredID"); + this.currentBlockMetadata = nbtTagCompound.getInteger("StoredMetadata"); + } + + /** + * Overriden in a sign to provide the text. + */ + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbtTagCompound = new NBTTagCompound(); + nbtTagCompound.setInteger("StoredID", this.currentBlockID); + nbtTagCompound.setInteger("StoredMetadata", this.currentBlockMetadata); + return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 1, nbtTagCompound); + } + + @Override + public void readNBTFromPacket(NBTTagCompound nbtTagCompound) { + this.currentBlockID = nbtTagCompound.getInteger("StoredID"); + this.currentBlockMetadata = nbtTagCompound.getInteger("StoredMetadata"); + if (currentBlockID != 0) hasItem = true; + this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord); + } + + public int getStoredBlockID() { + return currentBlockID; + } + + public int getStoredBlockMetadata() { + return currentBlockMetadata; + } + + public boolean hasItem() { + return hasItem; + } + + public boolean isValidItemForPot(int id, int meta) { + //Special case for blood wood sapling + if (id == BTWBlocks.aestheticVegetation.blockID) + return meta == 2; + if (id == SCItems.blueberryRoots.itemID || id == SCItems.sweetberryRoots.itemID) return true; + return validItemList.contains(id); + } + + public void placeItemInPot(int itemID, int metadata) { + hasItem = true; + + currentBlockID = itemID; + currentBlockMetadata = metadata; + + if (itemID == BTWItems.brownMushroom.itemID) + currentBlockID = Block.mushroomBrown.blockID; + else if (itemID == BTWItems.redMushroom.itemID) + currentBlockID = Block.mushroomRed.blockID; + else if (itemID == SCItems.blueberryRoots.itemID){ + currentBlockID = SCBlocks.blueberryBush.blockID; + currentBlockMetadata = 5; + } + else if (itemID == SCItems.sweetberryRoots.itemID){ + currentBlockID = SCBlocks.sweetberryBush.blockID; + currentBlockMetadata = 5; + } + + this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord); + + this.worldObj.playSound(this.xCoord, this.yCoord, this.zCoord, "step.grass", 1.0F, 1.0F); + } + + //Removes item and gives it to the player + public void retrieveItemFromPot(EntityPlayer player, int side) { + if (currentBlockID == 0) + return; + else if (currentBlockID == SCBlocks.blueberryBush.blockID){ + currentBlockID = SCItems.blueberryRoots.itemID; + currentBlockMetadata = 0; + } + else if (currentBlockID == SCBlocks.sweetberryBush.blockID){ + currentBlockID = SCItems.sweetberryRoots.itemID; + currentBlockMetadata = 0; + } + + if (!worldObj.isRemote) ItemUtils.ejectStackFromBlockTowardsFacing(worldObj, xCoord, yCoord, zCoord, new ItemStack(Item.itemsList[currentBlockID], 1, currentBlockMetadata), side); +// if (!player.capabilities.isCreativeMode) ItemUtils.givePlayerStackOrEjectFavorEmptyHand(player, new ItemStack(Item.itemsList[currentBlockID], 1, currentBlockMetadata), this.xCoord, this.yCoord, this.zCoord); + + + hasItem = false; + currentBlockID = 0; + + this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord); + + if (!this.worldObj.isRemote) + this.worldObj.playAuxSFX(BTWEffectManager.ITEM_COLLECTION_POP_EFFECT_ID, this.xCoord, this.yCoord, this.zCoord, 0); + } + + static { + validItemList.add(Block.plantRed.blockID); + validItemList.add(Block.plantYellow.blockID); + validItemList.add(Block.mushroomBrown.blockID); + validItemList.add(Block.mushroomRed.blockID); + validItemList.add(Block.cactus.blockID); + validItemList.add(Block.sapling.blockID); + validItemList.add(Block.tallGrass.blockID); + validItemList.add(BTWBlocks.aestheticVegetation.blockID); + validItemList.add(BTWBlocks.oakSapling.blockID); + validItemList.add(BTWBlocks.spruceSapling.blockID); + validItemList.add(BTWBlocks.birchSapling.blockID); + validItemList.add(BTWBlocks.jungleSapling.blockID); + validItemList.add(Block.deadBush.blockID); + + validItemList.add(SCBlocks.shortGrass.blockID); +// validItemList.add(SCBlocks.doubleTallPlant.blockID); +// validItemList.add(SCBlocks.doubleTallPlant.blockID); +// validItemList.add(SCItems.sunflower.itemID, 0); + validItemList.add(SCBlocks.blueberryBush.blockID); + validItemList.add(SCBlocks.sweetberryBush.blockID); + + if (SocksCropsAddon.isDecoInstalled()){ + validItemList.add(DecoBlockIDs.FLOWER_ID); + validItemList.add(DecoBlockIDs.FLOWER_2_ID); + validItemList.add(DecoBlockIDs.TULIP_ID); + validItemList.add(DecoBlockIDs.LEGACY_AUTUMN_SAPLING_ID); + validItemList.add(DecoBlockIDs.LEGACY_CHERRY_SAPLING_ID); + validItemList.add(DecoBlockIDs.LEGACY_ACACIA_SAPLING_ID); + validItemList.add(DecoBlockIDs.LEGACY_MAHOGANY_SAPLING_ID); + validItemList.add(DecoBlockIDs.LEGACY_MANGROVE_SAPLING_ID); + validItemList.add(DecoBlockIDs.LEGACY_HAZEL_SAPLING_ID); + validItemList.add(DecoBlockIDs.LEGACY_FIR_SAPLING_ID); + + validItemList.add(DecoBlockIDs.RED_AUTUMN_SAPLING_ID); + validItemList.add(DecoBlockIDs.ORANGE_AUTUMN_SAPLING_ID); + validItemList.add(DecoBlockIDs.YELLOW_AUTUMN_SAPLING_ID); + validItemList.add(DecoBlockIDs.ACACIA_SAPLING_ID); + validItemList.add(DecoBlockIDs.CHERRY_SAPLING_ID); + validItemList.add(DecoBlockIDs.MAHOGANY_SAPLING_ID); + validItemList.add(DecoBlockIDs.MANGROVE_SAPLING_ID); + validItemList.add(DecoBlockIDs.HAZEL_SAPLING_ID); + validItemList.add(DecoBlockIDs.FIR_SAPLING_ID); + validItemList.add(DecoBlockIDs.REDWOOD_SAPLING_ID); + validItemList.add(DecoBlockIDs.DARK_OAK_SAPLING_ID); + validItemList.add(DecoBlockIDs.WILLOW_SAPLING_ID); + validItemList.add(DecoBlockIDs.ASPEN_SAPLING_ID); + } + + } +} \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/tileentities/HayDryingTileEntity.java b/src/main/java/btw/community/sockthing/sockscrops/block/tileentities/HayDryingTileEntity.java index 6bba64c..a46162f 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/block/tileentities/HayDryingTileEntity.java +++ b/src/main/java/btw/community/sockthing/sockscrops/block/tileentities/HayDryingTileEntity.java @@ -54,6 +54,33 @@ public void updateEntity() { } } } + + + int sizeXZ=8; + int sizeY=8; + + for ( int iTempI = xCoord - sizeXZ; iTempI <= xCoord + sizeXZ; iTempI++ ) + { + for ( int iTempJ = yCoord - sizeY; iTempJ <= yCoord + sizeY; iTempJ++ ) + { + for ( int iTempK = zCoord - sizeXZ; iTempK <= zCoord + sizeXZ; iTempK++ ) + { + int blockID =worldObj.getBlockId(iTempI, iTempJ, iTempK); + if (blockID==0) + { + if(worldObj.rand.nextInt(200)==0) + { + worldObj.spawnParticle("reddust", iTempI+0.5D, iTempJ+0.5D, iTempK+0.5D, 0, 0, 0); + } + } + + else if( !worldObj.isUpdateScheduledForBlock(iTempI, iTempJ, iTempK, blockID)) + { + worldObj.scheduleBlockUpdate(iTempI, iTempJ, iTempK, blockID, 10); + } + } + } + } } @Override diff --git a/src/main/java/btw/community/sockthing/sockscrops/block/tileentities/LargeFlowerPotTileEntity.java b/src/main/java/btw/community/sockthing/sockscrops/block/tileentities/LargeFlowerPotTileEntity.java new file mode 100644 index 0000000..64c0962 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/block/tileentities/LargeFlowerPotTileEntity.java @@ -0,0 +1,199 @@ +package btw.community.sockthing.sockscrops.block.tileentities; + +import btw.block.BTWBlocks; +import btw.block.blocks.AestheticVegetationBlock; +import btw.block.tileentity.TileEntityDataPacketHandler; +import btw.community.sockthing.sockscrops.SocksCropsAddon; +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.block.blocks.DoubleTallPlantBlock; +import btw.community.sockthing.sockscrops.item.SCItems; +import btw.item.BTWItems; +import deco.block.DecoBlockIDs; +import net.minecraft.src.*; + +import java.util.ArrayList; +import java.util.List; + +public class LargeFlowerPotTileEntity extends TileEntity implements TileEntityDataPacketHandler { + + private ItemStack[] contents = new ItemStack[3]; + + public LargeFlowerPotTileEntity() { + super(); + } + + public ItemStack[] getContents() { + return contents; + } + + public ItemStack getStackInSlot(int slot){ + if (slot > 2) return null; + return contents[slot]; + } + + public void setStackInSlot(ItemStack stack, int slot){ + if (stack == null) contents[slot] = null; + else { + contents[slot] = new ItemStack(stack.itemID, 1, stack.getItemDamage()); + } + worldObj.markBlockRangeForRenderUpdate(xCoord,yCoord,zCoord,xCoord,yCoord,zCoord); + } + + @Override + public void writeToNBT(NBTTagCompound tag) { + + super.writeToNBT(tag); + + NBTTagList tagList = new NBTTagList(); + + for (int iTempIndex = 0; iTempIndex < contents.length; iTempIndex++ ) + { + if (contents[iTempIndex] != null ) + { + NBTTagCompound tempTag = new NBTTagCompound(); + + tempTag.setByte( "Slot", (byte)iTempIndex ); + + contents[iTempIndex].writeToNBT(tempTag); + + tagList.appendTag( tempTag ); + } + } + + tag.setTag( "Items", tagList ); + } + + @Override + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT( tag ); + + NBTTagList tagList = tag.getTagList( "Items" ); + + contents = new ItemStack[3]; + + for ( int iTempIndex = 0; iTempIndex < tagList.tagCount(); iTempIndex++ ) + { + NBTTagCompound tempTag = (NBTTagCompound)tagList.tagAt( iTempIndex ); + + int tempSlot = tempTag.getByte( "Slot" ) & 0xff; + + if ( tempSlot >= 0 && tempSlot < contents.length ) + { + contents[tempSlot] = ItemStack.loadItemStackFromNBT(tempTag); + } + } + } + + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tag = new NBTTagCompound(); + + this.writeToNBT(tag); + + return new Packet132TileEntityData(xCoord, yCoord, zCoord, 1, tag); + } + + @Override + public void readNBTFromPacket(NBTTagCompound tag) { + this.readFromNBT(tag); + // force a visual update for the block since the above variables affect it + + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); + } + + private static ArrayList validPlants = new ArrayList<>(); + + public boolean isValidStack(ItemStack heldStack) { + + +// return validPlants.contains(new ItemStack(heldStack.itemID, 1, heldStack.getItemDamage())); + for(ItemStack stack : validPlants) + { +// System.out.println("hand ID: " + heldStack.itemID); +// System.out.println("list ID: " + stack.itemID); +// System.out.println("hand meta: " + heldStack.getItemDamage()); +// System.out.println("list meta: " + stack.getItemDamage()); + if (heldStack.isItemEqual(stack)) return true; + } + + return false; + } + + public static void addValidPlant(int itemID, int damage){ + validPlants.add(new ItemStack(itemID, 1, damage)); + } + + public static void addValidPlant(int itemID){ + addValidPlant(itemID, 0); + } + + static { + addValidPlant(Block.tallGrass.blockID, 1); + addValidPlant(Block.tallGrass.blockID, 2); + addValidPlant(Block.deadBush.blockID, 0); + addValidPlant(BTWItems.brownMushroom.itemID, 0); + addValidPlant(BTWItems.redMushroom.itemID, 0); + addValidPlant(Block.plantRed.blockID, 0); + addValidPlant(Block.plantYellow.blockID, 0); + addValidPlant(Block.plantYellow.blockID, 1); + addValidPlant(Block.cactus.blockID, 0); + addValidPlant(BTWBlocks.oakSapling.blockID, 0); + addValidPlant(BTWBlocks.oakSapling.blockID, 7); + addValidPlant(BTWBlocks.spruceSapling.blockID, 0); + addValidPlant(BTWBlocks.spruceSapling.blockID, 7); + addValidPlant(BTWBlocks.birchSapling.blockID, 0); + addValidPlant(BTWBlocks.birchSapling.blockID, 7); + addValidPlant(BTWBlocks.jungleSapling.blockID, 0); + addValidPlant(BTWBlocks.jungleSapling.blockID, 7); + addValidPlant(BTWBlocks.aestheticVegetation.blockID, AestheticVegetationBlock.SUBTYPE_BLOOD_WOOD_SAPLING); + + addValidPlant(SCBlocks.shortGrass.blockID, 1); +// addValidPlant(SCBlocks.doubleTallPlant.blockID, DoubleTallPlantBlock.GRASS); +// addValidPlant(SCBlocks.doubleTallPlant.blockID, DoubleTallPlantBlock.FERN); +// addValidPlant(SCItems.sunflower.itemID, 0); + addValidPlant(SCItems.blueberryRoots.itemID, 0); + addValidPlant(SCItems.sweetberryRoots.itemID, 0); + + if (SocksCropsAddon.isDecoInstalled()){ + addValidPlant(DecoBlockIDs.FLOWER_ID); + addValidPlant(DecoBlockIDs.FLOWER_2_ID); + addValidPlant(DecoBlockIDs.TULIP_ID); + addValidPlant(DecoBlockIDs.LEGACY_AUTUMN_SAPLING_ID); + addValidPlant(DecoBlockIDs.LEGACY_CHERRY_SAPLING_ID); + addValidPlant(DecoBlockIDs.LEGACY_ACACIA_SAPLING_ID); + addValidPlant(DecoBlockIDs.LEGACY_MAHOGANY_SAPLING_ID); + addValidPlant(DecoBlockIDs.LEGACY_MANGROVE_SAPLING_ID); + addValidPlant(DecoBlockIDs.LEGACY_HAZEL_SAPLING_ID); + addValidPlant(DecoBlockIDs.LEGACY_FIR_SAPLING_ID); + + addValidPlant(DecoBlockIDs.RED_AUTUMN_SAPLING_ID); + addValidPlant(DecoBlockIDs.RED_AUTUMN_SAPLING_ID, 7); + addValidPlant(DecoBlockIDs.ORANGE_AUTUMN_SAPLING_ID); + addValidPlant(DecoBlockIDs.ORANGE_AUTUMN_SAPLING_ID, 7); + addValidPlant(DecoBlockIDs.YELLOW_AUTUMN_SAPLING_ID); + addValidPlant(DecoBlockIDs.YELLOW_AUTUMN_SAPLING_ID, 7); + addValidPlant(DecoBlockIDs.ACACIA_SAPLING_ID); + addValidPlant(DecoBlockIDs.ACACIA_SAPLING_ID, 7); + addValidPlant(DecoBlockIDs.CHERRY_SAPLING_ID); + addValidPlant(DecoBlockIDs.CHERRY_SAPLING_ID, 7); + addValidPlant(DecoBlockIDs.MAHOGANY_SAPLING_ID); + addValidPlant(DecoBlockIDs.MAHOGANY_SAPLING_ID, 7); + addValidPlant(DecoBlockIDs.MANGROVE_SAPLING_ID); + addValidPlant(DecoBlockIDs.MANGROVE_SAPLING_ID, 7); + addValidPlant(DecoBlockIDs.HAZEL_SAPLING_ID); + addValidPlant(DecoBlockIDs.HAZEL_SAPLING_ID, 7); + addValidPlant(DecoBlockIDs.FIR_SAPLING_ID); + addValidPlant(DecoBlockIDs.FIR_SAPLING_ID, 7); + addValidPlant(DecoBlockIDs.REDWOOD_SAPLING_ID); + addValidPlant(DecoBlockIDs.REDWOOD_SAPLING_ID, 7); + addValidPlant(DecoBlockIDs.DARK_OAK_SAPLING_ID); + addValidPlant(DecoBlockIDs.DARK_OAK_SAPLING_ID, 7); + addValidPlant(DecoBlockIDs.WILLOW_SAPLING_ID); + addValidPlant(DecoBlockIDs.WILLOW_SAPLING_ID, 7); + addValidPlant(DecoBlockIDs.ASPEN_SAPLING_ID); + addValidPlant(DecoBlockIDs.ASPEN_SAPLING_ID, 7); + } + + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/interfaces/BlockInterface.java b/src/main/java/btw/community/sockthing/sockscrops/interfaces/BlockInterface.java index 5026778..4970f3e 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/interfaces/BlockInterface.java +++ b/src/main/java/btw/community/sockthing/sockscrops/interfaces/BlockInterface.java @@ -1,9 +1,11 @@ package btw.community.sockthing.sockscrops.interfaces; +import net.minecraft.src.Block; import net.minecraft.src.ItemStack; public interface BlockInterface { + public boolean[] replaceableByLeavesLookup = new boolean[4096]; /** * Used to allow Blocks to be placed in a specific armorSlot * @param armorType 0: Helmet, 1: Chest, 2: Legs, 3: boots @@ -27,4 +29,12 @@ default String getBlurOverlay(ItemStack itemStack) { default boolean showBlurOverlayWithGuiDisabled(ItemStack itemStack) { return false; } + + /** + * If leaves can replace this Block. Used when generating leaves for trees on world gen and tree growth + */ + default boolean canBeReplacedByLeaves(int blockID) + { + return !Block.opaqueCubeLookup[blockID]; + } } diff --git a/src/main/java/btw/community/sockthing/sockscrops/item/SCFoodContainerItem.java b/src/main/java/btw/community/sockthing/sockscrops/item/SCFoodContainerItem.java new file mode 100644 index 0000000..028231b --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/item/SCFoodContainerItem.java @@ -0,0 +1,32 @@ +package btw.community.sockthing.sockscrops.item; + +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.Item; +import net.minecraft.src.ItemStack; +import net.minecraft.src.World; + +public class SCFoodContainerItem extends SCFoodItem +{ + private Item ejectedItem; + + public SCFoodContainerItem(int iItemID, Item ejectedItem, int iHungerHealed, float fSaturationModifier, boolean bWolfMeat, String sItemName ) + { + super( iItemID, iHungerHealed, fSaturationModifier, bWolfMeat, sItemName ); + this.ejectedItem = ejectedItem; + } + + @Override + public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player ) + { + super.onEaten( stack, world, player ); + + ItemStack bowlStack = new ItemStack( ejectedItem ); + + if ( !player.inventory.addItemStackToInventory( bowlStack ) ) + { + player.dropPlayerItem( bowlStack ); + } + + return stack; + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/item/SCFoodItem.java b/src/main/java/btw/community/sockthing/sockscrops/item/SCFoodItem.java new file mode 100644 index 0000000..64e968d --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/item/SCFoodItem.java @@ -0,0 +1,58 @@ +package btw.community.sockthing.sockscrops.item; + +import btw.item.items.FoodItem; +import net.minecraft.src.CreativeTabs; +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.ItemStack; +import net.minecraft.src.World; + +public class SCFoodItem extends FoodItem { + + //all SC Foods have High Res food values + static public final float CAKE_SATURATION_MODIFIER = 4.0F; + static public final float PIE_SATURATION_MODIFIER = 2.5F; + static public final float COOKIE_SATURATION_MODIFIER = 1F; + static public final float FATTY_SATURATION_MODIFIER = 0.5F; + static public final float PROTEIN_SATURATION_MODIFIER = 0.25F; + static public final float VEGS_SATURATION_MODIFIER = 0.0F; + static public final float BREAD_SATURATION_MODIFIER = 0.0F; + static public final float SWEET_SATURATION_MODIFIER = 0.125F; + + //3 == 1, 6 == 2, 9 == 3, etc.. + public static final int BERRY_HUNGER_HEALED = 4; + public static final float BERRY_SATURATION_MODIFIER = SWEET_SATURATION_MODIFIER; + static public final int BERRY_BOWL_HUNGER_HEALED = 8; + static public final float BERRY_BOWL_SATURATION_MODIFIER = SWEET_SATURATION_MODIFIER * 2; + + + public SCFoodItem(int iItemID, int iHungerHealed, float fSaturationModifier, boolean bWolfMeat, String sItemName) { + super(iItemID, iHungerHealed, fSaturationModifier, bWolfMeat, sItemName); + + setCreativeTab(CreativeTabs.tabFood); + } + + public SCFoodItem(int iItemID, int iHungerHealed, float fSaturationModifier, boolean bWolfMeat, String sItemName, boolean doZombiesConsume) { + super(iItemID, iHungerHealed, fSaturationModifier, bWolfMeat, sItemName, doZombiesConsume); + setCreativeTab(CreativeTabs.tabFood); + } + + public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + --par1ItemStack.stackSize; + par3EntityPlayer.getFoodStats().addStats(GetHungerRestored(par1ItemStack), getSaturationModifier(par1ItemStack)); + par2World.playSoundAtEntity(par3EntityPlayer, "random.burp", 0.5F, par2World.rand.nextFloat() * 0.1F + 0.9F); + this.onFoodEaten(par1ItemStack, par2World, par3EntityPlayer); + return par1ItemStack; + } + + public float getSaturationModifier(ItemStack stack) + { + return getSaturationModifier(); + }; + + public int GetHungerRestored(ItemStack stack) + { + return getHealAmount(); + }; + +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/item/SCItemIDs.java b/src/main/java/btw/community/sockthing/sockscrops/item/SCItemIDs.java index 4789e30..a9364f1 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/item/SCItemIDs.java +++ b/src/main/java/btw/community/sockthing/sockscrops/item/SCItemIDs.java @@ -1,11 +1,25 @@ package btw.community.sockthing.sockscrops.item; public class SCItemIDs { + //----------- Tools -----------// + public static final int IRON_KNIFE_ID = 31000; + public static final int GOLD_KNIFE_ID = 31001; + public static final int DIAMOND_KNIFE_ID = 31002; + public static final int STEEL_KNIFE_ID = 31003; + + //----------- Crops -----------// + public static final int SWEETBERRY_ID = 31050; + public static final int SWEETBERRY_ROOTS_ID = 31051; + public static final int BLUEBERRY_ID = 31052; + public static final int BLUEBERRY_ROOTS_ID = 31053; + public static final int BERRY_BOWL_ID = 31054; + public static final int SUNFLOWER_ID = 31060; + public static final int SUNFLOWER_SEEDS_ID = 31061; + + //----------- Misc -----------// + public static final int CUTTINGS_ID = 31100; + public static final int MOSS_BALL_ID = 31101; + public static final int LARGE_FLOWERPOT_ID = 31150; - public static int IRON_KNIFE_ID = 31000; - public static int GOLD_KNIFE_ID = 31001; - public static int DIAMOND_KNIFE_ID = 31002; - public static int STEEL_KNIFE_ID = 31003; - public static int CUTTINGS_ID = 31223; } diff --git a/src/main/java/btw/community/sockthing/sockscrops/item/SCItems.java b/src/main/java/btw/community/sockthing/sockscrops/item/SCItems.java index cea5178..6d094d1 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/item/SCItems.java +++ b/src/main/java/btw/community/sockthing/sockscrops/item/SCItems.java @@ -1,10 +1,15 @@ package btw.community.sockthing.sockscrops.item; +import btw.community.sockthing.sockscrops.SocksCropsAddon; +import btw.community.sockthing.sockscrops.block.SCBlockIDs; import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.block.blocks.DoubleTallPlantBlock; import btw.community.sockthing.sockscrops.item.items.KnifeItem; -import btw.community.sockthing.sockscrops.item.items.SCItemCuttings; +import btw.community.sockthing.sockscrops.item.items.CuttingsItem; import btw.item.BTWItems; import btw.item.items.PlaceAsBlockItem; +import btw.item.items.SeedItem; +import net.minecraft.src.CreativeTabs; import net.minecraft.src.EnumToolMaterial; import net.minecraft.src.Item; @@ -14,11 +19,73 @@ public class SCItems { public static Item diamondKnife; public static Item steelKnife; + public static Item sweetberry; + public static Item sweetberryRoots; + + public static Item blueberry; + public static Item blueberryRoots; + public static Item cuttings; + public static Item sunflower; + public static Item sunflowerSeeds; + + public static Item mossBall; + public static Item flowerPot; + public static Item largeFlowerpot; + + public static Item berryBowl; public static void initItems() { initKnives(); + intiBerries(); initHay(); + initSunflower(); + initMoss(); + initFlowerpot(); + } + + private static void initFlowerpot() { + largeFlowerpot = new PlaceAsBlockItem(SCItemIDs.LARGE_FLOWERPOT_ID - 256, SCBlockIDs.LARGE_FLOWERPOT_ID, 0, "large_flowerpot") + .setCreativeTab(CreativeTabs.tabDecorations); + + Item.flowerPot.setCreativeTab(null); + flowerPot = new PlaceAsBlockItem(SCBlockIDs.FLOWERPOT_ID - 256, SCBlockIDs.FLOWERPOT_ID, 0, "flowerPot") + .setCreativeTab(CreativeTabs.tabDecorations); + } + + private static void initMoss() { + mossBall = new Item(SCItemIDs.MOSS_BALL_ID - 256).setUnlocalizedName("moss_ball").setCreativeTab(CreativeTabs.tabMaterials); + } + + private static void initSunflower() { + sunflower = new PlaceAsBlockItem(SCItemIDs.SUNFLOWER_ID - 256, SCBlockIDs.DOUBLE_TALL_FLOWER_ID, DoubleTallPlantBlock.SUNFLOWER,"sunflower") + .setCreativeTab(CreativeTabs.tabDecorations) + .setFilterableProperties(Item.FILTERABLE_FINE); + + + sunflowerSeeds = new SeedItem(SCItemIDs.SUNFLOWER_SEEDS_ID - 256, SCBlockIDs.SUNFLOWER_CROP_ID) + .setUnlocalizedName("sunflower_seeds") + .setFilterableProperties(Item.FILTERABLE_FINE); + } + + private static void intiBerries() { + sweetberryRoots = new SeedItem(SCItemIDs.SWEETBERRY_ROOTS_ID - 256, SCBlockIDs.SWEETBERRY_BUSH_ID) + .setUnlocalizedName("sweetberry_roots") + .setCreativeTab(CreativeTabs.tabDecorations); + + sweetberry = new SCFoodItem(SCItemIDs.SWEETBERRY_ID - 256, SCFoodItem.BERRY_HUNGER_HEALED, + SCFoodItem.BERRY_SATURATION_MODIFIER, false, "sweetberry"); + + blueberryRoots = new SeedItem(SCItemIDs.BLUEBERRY_ROOTS_ID - 256, SCBlockIDs.BLUEBERRY_BUSH_ID) + .setUnlocalizedName("blueberry_roots") + .setCreativeTab(CreativeTabs.tabDecorations); + + blueberry = new SCFoodItem(SCItemIDs.BLUEBERRY_ID - 256, SCFoodItem.BERRY_HUNGER_HEALED, SCFoodItem.BERRY_SATURATION_MODIFIER, + false, "blueberry"); + + berryBowl = new SCFoodContainerItem(SCItemIDs.BERRY_BOWL_ID - 256, Item.bowlEmpty, + SCFoodItem.BERRY_BOWL_HUNGER_HEALED, SCFoodItem.BERRY_BOWL_SATURATION_MODIFIER, false, + "fruit_bowl_berries"); } private static void initKnives() { @@ -32,6 +99,6 @@ private static void initHay() { //BTW Overide BTWItems.straw = new PlaceAsBlockItem(BTWItems.straw.itemID - 256, SCBlocks.driedHay.blockID, 0, "fcItemStraw"); - cuttings = new SCItemCuttings(SCItemIDs.CUTTINGS_ID - 256, SCBlocks.dryingHay.blockID, "cuttings_item"); + cuttings = new CuttingsItem(SCItemIDs.CUTTINGS_ID - 256, SCBlocks.dryingHay.blockID, "cuttings_item"); } } diff --git a/src/main/java/btw/community/sockthing/sockscrops/item/items/SCItemCuttings.java b/src/main/java/btw/community/sockthing/sockscrops/item/items/CuttingsItem.java similarity index 82% rename from src/main/java/btw/community/sockthing/sockscrops/item/items/SCItemCuttings.java rename to src/main/java/btw/community/sockthing/sockscrops/item/items/CuttingsItem.java index 2c25ff9..8693a4d 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/item/items/SCItemCuttings.java +++ b/src/main/java/btw/community/sockthing/sockscrops/item/items/CuttingsItem.java @@ -4,8 +4,8 @@ import btw.item.items.PlaceAsBlockItem; import net.minecraft.src.CreativeTabs; -public class SCItemCuttings extends PlaceAsBlockItem { - public SCItemCuttings(int itemID, int blockToPlace, String name) { +public class CuttingsItem extends PlaceAsBlockItem { + public CuttingsItem(int itemID, int blockToPlace, String name) { super(itemID, blockToPlace); setBuoyant(); diff --git a/src/main/java/btw/community/sockthing/sockscrops/item/items/DoubleTallWaterPlantItem.java b/src/main/java/btw/community/sockthing/sockscrops/item/items/DoubleTallWaterPlantItem.java new file mode 100644 index 0000000..e20c073 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/item/items/DoubleTallWaterPlantItem.java @@ -0,0 +1,61 @@ +package btw.community.sockthing.sockscrops.item.items; + +import net.minecraft.src.*; + +public class DoubleTallWaterPlantItem extends ItemMultiTextureTile { + private Block lily; + + public DoubleTallWaterPlantItem(int var1, Block block, String[] array) { + super(var1, block, array); + this.lily = block; + } + + + /** + * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer + */ + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + MovingObjectPosition var4 = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (var4 == null) + { + return par1ItemStack; + } + else + { + if (var4.typeOfHit == EnumMovingObjectType.TILE) + { + int var5 = var4.blockX; + int var6 = var4.blockY; + int var7 = var4.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, var5, var6, var7)) + { + return par1ItemStack; + } + + if (!par3EntityPlayer.canPlayerEdit(var5, var6, var7, var4.sideHit, par1ItemStack)) + { + return par1ItemStack; + } + + if (par2World.getBlockMaterial(var5, var6, var7) == Material.water && par2World.getBlockMetadata(var5, var6, var7) == 0 && par2World.isAirBlock(var5, var6 + 1, var7)) + { + if (Block.blocksList[par2World.getBlockId(var5, var6 - 1, var7) ].isBlockSolid(par2World,var5,var6 - 1,var7,1)) + { + par2World.setBlockAndMetadata(var5, var6 + 1, var7, lily.blockID, par1ItemStack.getItemDamage()); + par2World.setBlockAndMetadata(var5, var6 + 2, var7, lily.blockID, par1ItemStack.getItemDamage() + 8); + + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + } + } + + return par1ItemStack; + } + } +} \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/item/items/FlowerLilyItem.java b/src/main/java/btw/community/sockthing/sockscrops/item/items/FlowerLilyItem.java new file mode 100644 index 0000000..7bcee03 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/item/items/FlowerLilyItem.java @@ -0,0 +1,56 @@ +package btw.community.sockthing.sockscrops.item.items; + +import net.minecraft.src.*; + +public class FlowerLilyItem extends ItemMultiTextureTile { + private Block lily; + + public FlowerLilyItem(int var1, Block block, String[] array) { + super(var1, block, array); + this.lily = block; + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer + */ + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + MovingObjectPosition var4 = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (var4 == null) + { + return par1ItemStack; + } + else + { + if (var4.typeOfHit == EnumMovingObjectType.TILE) + { + int var5 = var4.blockX; + int var6 = var4.blockY; + int var7 = var4.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, var5, var6, var7)) + { + return par1ItemStack; + } + + if (!par3EntityPlayer.canPlayerEdit(var5, var6, var7, var4.sideHit, par1ItemStack)) + { + return par1ItemStack; + } + + if (par2World.getBlockMaterial(var5, var6, var7) == Material.water && par2World.getBlockMetadata(var5, var6, var7) == 0 && par2World.isAirBlock(var5, var6 + 1, var7)) + { + par2World.setBlockAndMetadata(var5, var6 + 1, var7, lily.blockID, par1ItemStack.getItemDamage()); + + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + } + + return par1ItemStack; + } + } +} \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/item/items/KnifeItem.java b/src/main/java/btw/community/sockthing/sockscrops/item/items/KnifeItem.java index 5f650ed..335ad65 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/item/items/KnifeItem.java +++ b/src/main/java/btw/community/sockthing/sockscrops/item/items/KnifeItem.java @@ -1,15 +1,27 @@ package btw.community.sockthing.sockscrops.item.items; +import btw.block.BTWBlocks; import btw.item.items.ToolItem; import net.minecraft.src.*; public class KnifeItem extends ToolItem { + private int weaponDamage; + public KnifeItem(int itemID, EnumToolMaterial material, String name) { - super(itemID, 3, material); + super(itemID, 2, material); + +// weaponDamage = toolMaterial.getDamageVsEntity(); + setUnlocalizedName(name); } +// @Override +// public int getDamageVsEntity( Entity entity ) +// { +// return weaponDamage; +// } + @Override public float getStrVsBlock(ItemStack toolStack, World world, Block block, int x, int y, int z) { int toolLevel = toolMaterial.getHarvestLevel(); @@ -37,6 +49,8 @@ public boolean isEfficientVsBlock(ItemStack toolStack, World world, Block block, return false; } + if ( block.blockID == Block.web.blockID || block.blockID == BTWBlocks.web.blockID) return true; + return super.isEfficientVsBlock(toolStack, world, block, x, y, z); } @@ -69,7 +83,7 @@ public void onBrokenInCrafting(EntityPlayer player) { @Override public boolean canToolStickInBlock(ItemStack stack, Block block, World world, int x, int y, int z) { - return block.areShovelsEffectiveOn(); + return block.areShovelsEffectiveOn() || block.areAxesEffectiveOn(); } private static void PlayChopSoundOnPlayer(EntityPlayer player) { @@ -87,5 +101,22 @@ private static void PlayBreakSoundOnPlayer(EntityPlayer player) { player.playSound("random.break", 0.8F, 0.8F + player.worldObj.rand.nextFloat() * 0.4F); } + @Override + public float getVisualVerticalOffsetAsBlock() + { + return 11/16F; + } + + @Override + public float getBlockBoundingBoxHeight() + { + return 10/16F; + } + + public float getBlockBoundingBoxWidth() + { + return 12/16F; + } + } diff --git a/src/main/java/btw/community/sockthing/sockscrops/item/items/SideShroomItemBlock.java b/src/main/java/btw/community/sockthing/sockscrops/item/items/SideShroomItemBlock.java new file mode 100644 index 0000000..001f06e --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/item/items/SideShroomItemBlock.java @@ -0,0 +1,49 @@ +package btw.community.sockthing.sockscrops.item.items; + +import btw.community.sockthing.sockscrops.block.blocks.SideShroomBlock; +import btw.crafting.util.FurnaceBurnTime; +import btw.item.items.PlaceAsBlockItem; +import net.minecraft.src.*; + +public class SideShroomItemBlock extends ItemMultiTextureTile { + + public SideShroomItemBlock(int par1, Block par2Block, String[] names) { + super(par1, par2Block, names); + hasSubtypes = true; + + setBuoyant(); + setBellowsBlowDistance( 2 ); + setfurnaceburntime( FurnaceBurnTime.SMALL_FUEL ); + setFilterableProperties( FILTERABLE_SMALL | FILTERABLE_THIN ); + } + + public static String[] names = { + "white","white","white","white", + "black","black","black","black", + "brown","brown","brown","brown", + "red","red","red","red" + }; + + private String[] types = {"white", "black", "brown", "red" }; + + private Icon[] shroom = new Icon[4]; + + @Override + public Icon getIconFromDamage(int par1) { + if (par1 <= 3) + return shroom[0]; + else if (par1 < 8) + return shroom[1]; + else if (par1 < 12) + return shroom[2]; + else return shroom[3]; + } + + @Override + public void registerIcons(IconRegister register) { + for (int i = 0; i < shroom.length; i++) { + shroom[i] = register.registerIcon("sideshroom_" + types[i]); + } + } + +} \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/item/items/WaterPlantItem.java b/src/main/java/btw/community/sockthing/sockscrops/item/items/WaterPlantItem.java new file mode 100644 index 0000000..ef1f044 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/item/items/WaterPlantItem.java @@ -0,0 +1,60 @@ +package btw.community.sockthing.sockscrops.item.items; + +import net.minecraft.src.*; + +public class WaterPlantItem extends ItemMultiTextureTile { + private Block waterPlant; + + public WaterPlantItem(int var1, Block block, String[] array) { + super(var1, block, array); + this.waterPlant = block; + } + + /** + * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer + */ + public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) + { + MovingObjectPosition var4 = this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, true); + + if (var4 == null) + { + return par1ItemStack; + } + else + { + if (var4.typeOfHit == EnumMovingObjectType.TILE) + { + int var5 = var4.blockX; + int var6 = var4.blockY; + int var7 = var4.blockZ; + + if (!par2World.canMineBlock(par3EntityPlayer, var5, var6, var7)) + { + return par1ItemStack; + } + + if (!par3EntityPlayer.canPlayerEdit(var5, var6, var7, var4.sideHit, par1ItemStack)) + { + return par1ItemStack; + } + + if (par2World.getBlockMaterial(var5, var6, var7) == Material.water && par2World.getBlockMetadata(var5, var6, var7) == 0 && par2World.isAirBlock(var5, var6 + 1, var7)) + { + if (Block.blocksList[par2World.getBlockId(var5, var6 - 1, var7) ].isBlockSolid(par2World,var5,var6 - 1,var7,1)) + { + par2World.setBlockAndMetadata(var5, var6 + 1, var7, waterPlant.blockID, par1ItemStack.getItemDamage()); + + if (!par3EntityPlayer.capabilities.isCreativeMode) + { + --par1ItemStack.stackSize; + } + } + + } + } + + return par1ItemStack; + } + } +} \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/mixins/BiomeGenBaseMixin.java b/src/main/java/btw/community/sockthing/sockscrops/mixins/BiomeGenBaseMixin.java new file mode 100644 index 0000000..4173f28 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/mixins/BiomeGenBaseMixin.java @@ -0,0 +1,33 @@ +package btw.community.sockthing.sockscrops.mixins; + +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.world.generators.GrassWorldGen; +import net.minecraft.src.BiomeGenBase; +import net.minecraft.src.Block; +import net.minecraft.src.WorldGenerator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Random; + +@Mixin(BiomeGenBase.class) +public class BiomeGenBaseMixin { + + @Inject(at = @At("HEAD"), method = "getRandomWorldGenForGrass", cancellable = true) + public void getRandomWorldGenForGrass(Random rand, CallbackInfoReturnable cir) + { + cir.setReturnValue( + new GrassWorldGen(new int[][]{ + {Block.tallGrass.blockID, 1}, + {SCBlocks.shortGrass.blockID, 1} + }) + ); + +// if (rand.nextInt(4) == 0){ +// +// } +// else cir.setReturnValue( new WorldGenTallGrass(Block.tallGrass.blockID, 1)); + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/mixins/BiomeGenJungleMixin.java b/src/main/java/btw/community/sockthing/sockscrops/mixins/BiomeGenJungleMixin.java new file mode 100644 index 0000000..5999370 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/mixins/BiomeGenJungleMixin.java @@ -0,0 +1,22 @@ +package btw.community.sockthing.sockscrops.mixins; + +import net.minecraft.src.*; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(BiomeGenJungle.class) +public abstract class BiomeGenJungleMixin extends BiomeGenBase { + + protected BiomeGenJungleMixin(int par1) { + super(par1); + } + +// @Inject(method = "decorate", at = @At(value = "TAIL")) +// public void decorate(World world, Random random, int x, int z, CallbackInfo ci) { +// int xPos = x + random.nextInt(16) + 8; +// int zPos = z + random.nextInt(16) + 8; +// int yPos = world.getHeightValue(xPos, zPos) + 1; +// +// WorldGenerator generator = new FallenLogWorldGen(this); +// generator.generate(world, random, xPos, yPos, zPos); +// } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/mixins/BlockMixin.java b/src/main/java/btw/community/sockthing/sockscrops/mixins/BlockMixin.java index 491ff9e..b371de1 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/mixins/BlockMixin.java +++ b/src/main/java/btw/community/sockthing/sockscrops/mixins/BlockMixin.java @@ -6,15 +6,28 @@ import btw.community.sockthing.sockscrops.interfaces.BlockInterface; import net.minecraft.src.Block; import net.minecraft.src.ItemStack; +import net.minecraft.src.Material; import net.minecraft.src.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import static net.minecraft.src.Block.blocksList; + @Mixin(Block.class) public abstract class BlockMixin implements BlockInterface { + @Inject(method = "", at = @At(value = "TAIL")) + public void init(int par1, Material par2Material, CallbackInfo ci) { + + if (blocksList[par1] == null) + { + replaceableByLeavesLookup[par1] = this.canBeReplacedByLeaves(par1); + } + + } /** * Used to allow Blocks to be placed in a specific armorSlot @@ -49,7 +62,7 @@ public void spreadGrassToBlock(World world, int x, int y, int z, CallbackInfoRet int farmlandID = world.getBlockId(x, y, z); - Block farmland = Block.blocksList[farmlandID]; + Block farmland = blocksList[farmlandID]; if (farmland instanceof FarmlandFullNutritionBlock) { world.setBlockAndMetadataWithNotify(x, y, z, BTWBlocks.looseDirt.blockID, 0); diff --git a/src/main/java/btw/community/sockthing/sockscrops/mixins/FlowerBlockMixin.java b/src/main/java/btw/community/sockthing/sockscrops/mixins/FlowerBlockMixin.java new file mode 100644 index 0000000..91ea010 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/mixins/FlowerBlockMixin.java @@ -0,0 +1,61 @@ +package btw.community.sockthing.sockscrops.mixins; + +import btw.block.blocks.FlowerBlock; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.src.*; +import org.spongepowered.asm.mixin.Mixin; + +import java.util.List; + +@Mixin(FlowerBlock.class) +public abstract class FlowerBlockMixin extends BlockFlower { + private Icon dandilion; + private Icon yellowFlower; + private Icon redFlower; + + protected FlowerBlockMixin(int par1) { + super(par1); + } + + @Environment(EnvType.CLIENT) + public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) + { + if (this.blockID == Block.plantRed.blockID) + { + par3List.add(new ItemStack(par1, 1, 0)); + } + else { + par3List.add(new ItemStack(par1, 1, 0)); + par3List.add(new ItemStack(par1, 1, 1)); + } + } + + @Override + public int damageDropped(int metadata) { + return metadata; + } + + @Override + public void registerIcons(IconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + yellowFlower = par1IconRegister.registerIcon("flower"); + redFlower = par1IconRegister.registerIcon("rose"); + dandilion = par1IconRegister.registerIcon("dandilion_white"); + } + + @Override + @Environment(EnvType.CLIENT) + public Icon getIcon(int side, int metadata) + { + if (this.blockID == Block.plantRed.blockID) + { + return this.blockIcon = redFlower; + } + + if (metadata == 1){ + return this.blockIcon = dandilion; + } + else return this.blockIcon = yellowFlower; + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/mixins/GrateBlockMixin.java b/src/main/java/btw/community/sockthing/sockscrops/mixins/GrateBlockMixin.java new file mode 100644 index 0000000..9f20cbf --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/mixins/GrateBlockMixin.java @@ -0,0 +1,30 @@ +package btw.community.sockthing.sockscrops.mixins; + +import btw.block.blocks.GrateBlock; +import btw.block.blocks.PaneBlock; +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.block.blocks.GrownPaneBlock; +import net.minecraft.src.*; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(GrateBlock.class) +public abstract class GrateBlockMixin extends PaneBlock { + public GrateBlockMixin(int iBlockID, String sTextureName, String sSideTextureName, Material material, boolean bCanDropItself) { + super(iBlockID, sTextureName, sSideTextureName, material, bCanDropItself); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int iFacing, float fXClick, float fYClick, float fZClick ) + { + ItemStack heldStack = player.getHeldItem(); + + if (heldStack != null && heldStack.itemID == Block.vine.blockID) + { + world.setBlockAndMetadataWithNotify(x,y,z, SCBlocks.grownGrate.blockID, GrownPaneBlock.VINES); + heldStack.stackSize--; + return true; + } + + return super.onBlockActivated(world, x, y, z, player, iFacing, fXClick, fYClick, fZClick); + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/mixins/LeavesBlockMixin.java b/src/main/java/btw/community/sockthing/sockscrops/mixins/LeavesBlockMixin.java new file mode 100644 index 0000000..3a4a19a --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/mixins/LeavesBlockMixin.java @@ -0,0 +1,18 @@ +package btw.community.sockthing.sockscrops.mixins; + +import btw.block.blocks.LeavesBlock; +import btw.community.sockthing.sockscrops.interfaces.BlockInterface; +import net.minecraft.src.BlockLeaves; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(LeavesBlock.class) +public abstract class LeavesBlockMixin extends BlockLeaves implements BlockInterface { + protected LeavesBlockMixin(int par1) { + super(par1); + } + + @Override + public boolean canBeReplacedByLeaves(int blockID) { + return true; + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/mixins/PlaceAsBlockItemAccessor.java b/src/main/java/btw/community/sockthing/sockscrops/mixins/PlaceAsBlockItemAccessor.java new file mode 100644 index 0000000..ec6fc5d --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/mixins/PlaceAsBlockItemAccessor.java @@ -0,0 +1,14 @@ +package btw.community.sockthing.sockscrops.mixins; + +import btw.item.items.PlaceAsBlockItem; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin({PlaceAsBlockItem.class}) +public interface PlaceAsBlockItemAccessor { + @Accessor( + value = "blockID", + remap = false + ) + void setBlockID(int var1); +} \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/mixins/WorldGenFlowersMixin.java b/src/main/java/btw/community/sockthing/sockscrops/mixins/WorldGenFlowersMixin.java new file mode 100644 index 0000000..967875a --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/mixins/WorldGenFlowersMixin.java @@ -0,0 +1,47 @@ +package btw.community.sockthing.sockscrops.mixins; + +import btw.community.sockthing.sockscrops.block.blocks.FarmlandBaseBlock; +import net.minecraft.src.Block; +import net.minecraft.src.World; +import net.minecraft.src.WorldGenFlowers; +import net.minecraft.src.WorldGenerator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Random; + +@Mixin(WorldGenFlowers.class) +public abstract class WorldGenFlowersMixin extends WorldGenerator { + + @Shadow private int plantBlockId; + + @Override + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + for (int var6 = 0; var6 < 64; ++var6) + { + int var7 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); + int var8 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); + int var9 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); + + if (par1World.isAirBlock(var7, var8, var9) && (!par1World.provider.hasNoSky || var8 < 127) && + Block.blocksList[this.plantBlockId].canBlockStayDuringGenerate(par1World, var7, var8, var9)) + { + if (this.plantBlockId == Block.plantYellow.blockID){ + if (par2Random.nextFloat() <= 1/8F) { + par1World.setBlock(var7, var8, var9, this.plantBlockId, 1, 2); + } + else par1World.setBlock(var7, var8, var9, this.plantBlockId, 0, 2); + } + else par1World.setBlock(var7, var8, var9, this.plantBlockId, 0, 2); + } + } + + return true; + } + + +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/mixins/WorldGenShrubMixin.java b/src/main/java/btw/community/sockthing/sockscrops/mixins/WorldGenShrubMixin.java new file mode 100644 index 0000000..785f9e9 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/mixins/WorldGenShrubMixin.java @@ -0,0 +1,34 @@ +package btw.community.sockthing.sockscrops.mixins; + +import btw.community.sockthing.sockscrops.block.SCBlockIDs; +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.utils.WorldGenUtils; +import net.minecraft.src.Block; +import net.minecraft.src.World; +import net.minecraft.src.WorldGenShrub; +import net.minecraft.src.WorldGenerator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(WorldGenShrub.class) +public abstract class WorldGenShrubMixin extends WorldGenerator { + @Redirect( + method = "generate", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/src/World;getBlockId(III)I", // Target the getBlockId method + ordinal = 2 + ) + ) + private int redirectGetBlockIdForLeafPlacement(World par1World, int var11, int var8, int var13) { + // Instead of checking Block.opaqueCubeLookup, use the WorldGenUtils method + if (par1World.getBlockId(var11, var8, var13) == SCBlocks.hollowLog.blockID) return Block.wood.blockID; + + if (WorldGenUtils.canLeavesBePlaced(par1World, var11, var8, var13)) { + + return 0; // Simulate an air block if the leaves can be placed + } + return par1World.getBlockId(var11, var8, var13); // Otherwise return the original block ID + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/mixins/WorldGenTreesMixin.java b/src/main/java/btw/community/sockthing/sockscrops/mixins/WorldGenTreesMixin.java new file mode 100644 index 0000000..ae76e0a --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/mixins/WorldGenTreesMixin.java @@ -0,0 +1,34 @@ +package btw.community.sockthing.sockscrops.mixins; + +import btw.community.sockthing.sockscrops.utils.WorldGenUtils; +import net.minecraft.src.World; +import net.minecraft.src.WorldGenTrees; +import net.minecraft.src.WorldGenerator; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.Random; + +@Mixin(WorldGenTrees.class) +public abstract class WorldGenTreesMixin extends WorldGenerator { + @Redirect( + method = "generate", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/src/World;getBlockId(III)I", // Target the getBlockId method + ordinal = 2 + ) + ) + private int redirectGetBlockIdForLeafPlacement(World par1World, int var11, int var8, int var13) { + // Instead of checking Block.opaqueCubeLookup, use the WorldGenUtils method + if (WorldGenUtils.canLeavesBePlaced(par1World, var11, var8, var13)) { + return 0; // Simulate an air block if the leaves can be placed + } + return par1World.getBlockId(var11, var8, var13); // Otherwise return the original block ID + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/mixins/plugins/DecoFlowerPotTileEntityPlugin.java b/src/main/java/btw/community/sockthing/sockscrops/mixins/plugins/DecoFlowerPotTileEntityPlugin.java new file mode 100644 index 0000000..dc1cee1 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/mixins/plugins/DecoFlowerPotTileEntityPlugin.java @@ -0,0 +1,49 @@ +package btw.community.sockthing.sockscrops.mixins.plugins; + +import net.fabricmc.loader.api.FabricLoader; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +public class DecoFlowerPotTileEntityPlugin implements IMixinConfigPlugin { + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + if (mixinClassName.equals("btw.community.sockthing.sockscrops.mixins.DecoFlowerPotTileEntityMixin") && !FabricLoader.getInstance().isModLoaded("decoaddon")) { + return false; + } + return true; + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/recipes/SCRecipes.java b/src/main/java/btw/community/sockthing/sockscrops/recipes/SCRecipes.java index e78d95a..585f8ea 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/recipes/SCRecipes.java +++ b/src/main/java/btw/community/sockthing/sockscrops/recipes/SCRecipes.java @@ -1,11 +1,20 @@ package btw.community.sockthing.sockscrops.recipes; import btw.block.BTWBlocks; +import btw.block.blocks.PlanterBlock; +import btw.block.blocks.TallGrassBlock; +import btw.community.sockthing.sockscrops.SocksCropsAddon; +import btw.community.sockthing.sockscrops.block.SCBlockIDs; import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.block.blocks.PlanterBaseBlock; +import btw.community.sockthing.sockscrops.block.blocks.PlanterGrassBlock; +import btw.community.sockthing.sockscrops.block.tileentities.LargeFlowerPotTileEntity; import btw.community.sockthing.sockscrops.item.SCItems; import btw.community.sockthing.sockscrops.utils.NutritionUtils; import btw.crafting.recipe.RecipeManager; +import btw.inventory.util.InventoryUtils; import btw.item.BTWItems; +import btw.item.util.ItemUtils; import net.minecraft.src.Block; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; @@ -16,6 +25,71 @@ public static void initRecipes() { initKnifeRecipes(); initPlanterRecipes(); initHayRecipes(); + initHollowLogRecipes(); + initMossRecipes(); + initSunflowerRecipes(); + initFlowerpotRecipes(); + + initFoodRecipes(); + } + + private static void initFoodRecipes() { + initBerryRecipes(); + } + + private static void initBerryRecipes() { + RecipeManager.addShapelessRecipe(new ItemStack(SCItems.berryBowl), + new ItemStack[]{ + new ItemStack(Item.bowlEmpty), + new ItemStack(Item.sugar), + new ItemStack(SCItems.sweetberry), + new ItemStack(SCItems.blueberry), + }); + } + + private static void initFlowerpotRecipes() { + + RecipeManager.removeVanillaRecipe(new ItemStack(Item.flowerPot, 1), new Object[] {"# #", " # ", '#', Item.brick}); + RecipeManager.addRecipe(new ItemStack(SCItems.flowerPot, 1), new Object[] {"# #", " # ", '#', Item.brick}); + + RecipeManager.addRecipe(new ItemStack(SCItems.largeFlowerpot, 1), new Object[] { + "B B", + "BBB", + 'B', Item.brick + }); + } + + private static void initMossRecipes() { + + RecipeManager.addRecipe(new ItemStack(SCBlocks.mossCarpet, 1), new Object[] { + "MMM", + 'M', SCItems.mossBall + }); + + RecipeManager.addShapelessRecipe(new ItemStack(SCItems.mossBall, 3), + new ItemStack[]{ + new ItemStack(SCBlocks.mossCarpet) + }); + + RecipeManager.addPistonPackingRecipe(SCBlocks.mossBlock, + new ItemStack(SCItems.mossBall, 8)); + + RecipeManager.addShapelessRecipe(new ItemStack(SCBlocks.mossBlock), + new ItemStack[]{ + new ItemStack(SCItems.mossBall), + new ItemStack(SCItems.mossBall), + new ItemStack(SCItems.mossBall), + new ItemStack(SCItems.mossBall), + new ItemStack(SCItems.mossBall), + new ItemStack(SCItems.mossBall), + new ItemStack(SCItems.mossBall), + new ItemStack(SCItems.mossBall) + }); + + RecipeManager.addShapelessRecipe(new ItemStack(SCItems.mossBall, 8), + new ItemStack[]{ + new ItemStack(SCBlocks.mossBlock) + }); } private static void removeRecipes() { @@ -26,6 +100,16 @@ private static void removeRecipes() { }); } + private static void initSunflowerRecipes() { + RecipeManager.addShapelessRecipe( new ItemStack( SCItems.sunflowerSeeds, 2 ), new Object[] { + new ItemStack( SCItems.sunflower ) + } ); + + RecipeManager.addHopperFilteringRecipe(new ItemStack(SCItems.sunflowerSeeds, 2), + new ItemStack(SCItems.sunflower), + new ItemStack(BTWBlocks.wickerPane)); + } + private static void initKnifeRecipes() { addKnifeRecipe(SCItems.ironKnife, Item.ingotIron, Item.stick, BTWItems.ironNugget, 6); addKnifeRecipe(SCItems.goldKnife, Item.ingotGold, Item.stick, Item.goldNugget, 6); @@ -56,19 +140,55 @@ private static void initPlanterRecipes() { RecipeManager.addShapelessRecipe(new ItemStack(SCBlocks.planterGrass, 1, NutritionUtils.REDUCED_NUTRITION_LEVEL), new Object[]{ new ItemStack(BTWBlocks.planter), - new ItemStack(SCBlocks.grassNutrition, 1, NutritionUtils.REDUCED_NUTRITION_LEVEL) + new ItemStack(SCBlocks.grassNutrition, 1, NutritionUtils.REDUCED_NUTRITION_LEVEL + 1) }); RecipeManager.addShapelessRecipe(new ItemStack(SCBlocks.planterGrass, 1, NutritionUtils.LOW_NUTRITION_LEVEL), new Object[]{ new ItemStack(BTWBlocks.planter), - new ItemStack(SCBlocks.grassNutrition, 1, NutritionUtils.LOW_NUTRITION_LEVEL) + new ItemStack(SCBlocks.grassNutrition, 1, NutritionUtils.LOW_NUTRITION_LEVEL + 1) }); RecipeManager.addShapelessRecipe(new ItemStack(SCBlocks.planterGrass, 1, NutritionUtils.DEPLETED_NUTRITION_LEVEL), new Object[]{ new ItemStack(BTWBlocks.planter), - new ItemStack(SCBlocks.grassNutrition, 1, NutritionUtils.DEPLETED_NUTRITION_LEVEL) + new ItemStack(SCBlocks.grassNutrition, 1, NutritionUtils.DEPLETED_NUTRITION_LEVEL + 1) }); + for (int j = 0; j < 4; j++) { + for (int i = 0; i < 4; i++) { + RecipeManager.addShapelessRecipeWithSecondaryOutputIndicator( + new ItemStack(BTWBlocks.planter ), + getContents(SCBlockIDs.GRASS_PLANTER_ID + j, i), + new Object[] { + new ItemStack( SCBlockIDs.GRASS_PLANTER_ID + j, 1, i) + }); + } + } + + RecipeManager.addShapelessRecipeWithSecondaryOutputIndicator( + new ItemStack(BTWBlocks.planter ), + new ItemStack(BTWBlocks.looseDirt, 1, 0), + new Object[] { + new ItemStack( BTWBlocks.planterWithSoil, 1, 0) + }); + + RecipeManager.addShapelessRecipeWithSecondaryOutputIndicator( + new ItemStack(BTWBlocks.planter ), + new ItemStack(Block.slowSand, 1), + new Object[] { + new ItemStack( BTWBlocks.planter, 1, PlanterBlock.TYPE_SOUL_SAND) + }); + } + + public static ItemStack getContents(int blockID, int metadata){ + if (blockID == SCBlocks.planterGrass.blockID) + { + if (metadata == 0) return new ItemStack(Block.grass); + return new ItemStack(SCBlocks.grassNutrition, 1, metadata * 2); + } + else if (blockID >= SCBlocks.planterFarmland.blockID || blockID <= SCBlocks.planterFarmlandDung.blockID ){ + return new ItemStack(BTWBlocks.looseDirt, 1, metadata); + } + else return null; } private static void initHayRecipes() { @@ -76,9 +196,6 @@ private static void initHayRecipes() { RecipeManager.addPistonPackingRecipe(SCBlocks.hayBale, new ItemStack(SCItems.cuttings, 8)); - RecipeManager.addPistonPackingRecipe(SCBlocks.strawBale, - new ItemStack(BTWItems.straw, 8)); - RecipeManager.addShapelessRecipe(new ItemStack(SCBlocks.hayBale), new ItemStack[]{ new ItemStack(SCItems.cuttings), @@ -91,18 +208,66 @@ private static void initHayRecipes() { new ItemStack(SCItems.cuttings) }); - RecipeManager.addShapelessRecipe(new ItemStack(SCBlocks.strawBale), + if (!SocksCropsAddon.isDecoInstalled()){ + RecipeManager.addPistonPackingRecipe(SCBlocks.strawBale, + new ItemStack(BTWItems.straw, 8)); + + RecipeManager.addShapelessRecipe(new ItemStack(SCBlocks.strawBale), + new ItemStack[]{ + new ItemStack(BTWItems.straw), + new ItemStack(BTWItems.straw), + new ItemStack(BTWItems.straw), + new ItemStack(BTWItems.straw), + new ItemStack(BTWItems.straw), + new ItemStack(BTWItems.straw), + new ItemStack(BTWItems.straw), + new ItemStack(BTWItems.straw) + }); + } + } + + + private static void initHollowLogRecipes() { + for (int i = 0; i < 4; i++) { + RecipeManager.addLogChoppingRecipe(new ItemStack(BTWItems.sawDust, 2), + new ItemStack[]{ + new ItemStack(BTWItems.bark, 1, i), + }, + new ItemStack(SCBlocks.hollowLog, 1, i)); + } + + RecipeManager.addLogChoppingRecipe(new ItemStack(BTWItems.sawDust, 2), new ItemStack[]{ - new ItemStack(BTWItems.straw), - new ItemStack(BTWItems.straw), - new ItemStack(BTWItems.straw), - new ItemStack(BTWItems.straw), - new ItemStack(BTWItems.straw), - new ItemStack(BTWItems.straw), - new ItemStack(BTWItems.straw), - new ItemStack(BTWItems.straw) - }); + new ItemStack(BTWItems.bark, 1, 4), + }, + new ItemStack(SCBlocks.hollowLog2, 1, 0)); + + if(SocksCropsAddon.isDecoInstalled()){ + for (int i = 0; i < 4; i++) { + RecipeManager.addLogChoppingRecipe(new ItemStack(BTWItems.sawDust, 2), + new ItemStack[] { + new ItemStack(BTWItems.bark, 1, i + 5), + }, + new ItemStack(SCBlocks.decoHollowLog, 1, i)); + } + for (int i = 0; i < 4; i++) { + RecipeManager.addLogChoppingRecipe(new ItemStack(BTWItems.sawDust, 2), + new ItemStack[] { + new ItemStack(BTWItems.bark, 1, i + 9), + }, + new ItemStack(SCBlocks.decoHollowLog2, 1, i)); + } + + for (int i = 0; i < 2; i++) { + RecipeManager.addLogChoppingRecipe(new ItemStack(BTWItems.sawDust, 2), + new ItemStack[] { + new ItemStack(BTWItems.bark, 1, i + 13), + }, + new ItemStack(SCBlocks.decoHollowLog3, 1, i)); + } + } } + } diff --git a/src/main/java/btw/community/sockthing/sockscrops/utils/NutritionUtils.java b/src/main/java/btw/community/sockthing/sockscrops/utils/NutritionUtils.java index 9603d29..bdec9c7 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/utils/NutritionUtils.java +++ b/src/main/java/btw/community/sockthing/sockscrops/utils/NutritionUtils.java @@ -81,6 +81,6 @@ public static boolean isValidPlantAbove(World world, int i, int j, int k) { return world.getBlockId(i, j, k) == Block.tallGrass.blockID || world.getBlockId(i, j, k) == Block.plantRed.blockID || world.getBlockId(i, j, k) == Block.plantYellow.blockID - || world.getBlockId(i, j, k) == SCBlocks.doubleTallGrass.blockID; + || world.getBlockId(i, j, k) == SCBlocks.doubleTallPlant.blockID; } } diff --git a/src/main/java/btw/community/sockthing/sockscrops/utils/SCRenderUtils.java b/src/main/java/btw/community/sockthing/sockscrops/utils/SCRenderUtils.java index f4a7442..f129373 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/utils/SCRenderUtils.java +++ b/src/main/java/btw/community/sockthing/sockscrops/utils/SCRenderUtils.java @@ -1,5 +1,7 @@ package btw.community.sockthing.sockscrops.utils; +import btw.block.blocks.GroundCoverBlock; +import btw.community.sockthing.sockscrops.block.blocks.MultiFlowerBlock; import net.minecraft.src.*; import org.lwjgl.opengl.GL11; @@ -14,6 +16,15 @@ public class SCRenderUtils { public static final int JUNGLE_BIOME_COLOR = -11285961; public static final int MUSHROOM_BIOME_COLOR = -11155137; + private static final double renderMinX = 0D; + private static final double renderMaxX = 1D; + private static final double renderMinY = 0D; + private static final double renderMaxY = 1D; + private static final double renderMinZ = 0D; + private static final double renderMaxZ = 1D; + + private static double groundShift = 1/16D + 1/1024D; + public static int color(int baseColor, int r, int g, int b) { for (int var8 = -1; var8 <= 1; ++var8) { @@ -182,7 +193,23 @@ public static void renderGrassBlockAsItem(RenderBlocks renderer, Block block, in } - public static void renderCrossedSquaresWithTexture(RenderBlocks renderBlocks, Block block, int i, int j, int k, Icon texture, boolean randomOffset) { + public static void renderCrossedSquaresWithTexture(RenderBlocks renderBlocks, Block block, int i, int j, int k, Icon texture, boolean randomOffset){ + renderCrossedSquaresWithTexture(renderBlocks, block, i,j,k, 0D, 0D, 0D, texture, randomOffset, false, 0.2D); + } + + public static void renderCrossedSquaresWithTexture(RenderBlocks renderBlocks, Block block, int i, int j, int k, Icon texture, boolean randomOffset, boolean randomHeight){ + renderCrossedSquaresWithTexture(renderBlocks, block, i,j,k, 0D, 0D, 0D, texture, randomOffset, randomHeight, 0.2D); + } + + public static void renderCrossedSquaresWithTexture(RenderBlocks renderBlocks, Block block, int i, int j, int k, Icon texture, boolean randomOffset, boolean randomHeight, double heightVariation){ + renderCrossedSquaresWithTexture(renderBlocks, block, i,j,k, 0D, 0D, 0D, texture, randomOffset, randomHeight, heightVariation); + } + + public static void renderCrossedSquaresWithTexture(RenderBlocks renderBlocks, Block block, int i, int j, int k, double shiftX, double shiftY, double shiftZ, Icon texture, boolean randomOffset){ + renderCrossedSquaresWithTexture(renderBlocks, block, i,j,k, shiftX, shiftY, shiftZ, texture, randomOffset, false, 0.2D); + } + + public static void renderCrossedSquaresWithTexture(RenderBlocks renderBlocks, Block block, int i, int j, int k, double shiftX, double shiftY, double shiftZ, Icon texture, boolean randomOffset, boolean randomHeight, double heightVariation) { boolean bHasOverride = renderBlocks.hasOverrideBlockTexture(); if (!bHasOverride) { @@ -202,31 +229,898 @@ public static void renderCrossedSquaresWithTexture(RenderBlocks renderBlocks, Bl double newY = j; double newZ = k; - double newCenterX = i; - double newCenterZ = k; + double newCenterX = i + shiftX; + double newCenterY = j + shiftY; + double newCenterZ = k + shiftZ; + double c = 0.0D; if (randomOffset) { - long hash = (long) (i * 3129871L) ^ (long) k * 116129781L; // ^ (long)j; + long hash = (long) (i * 3129871L) ^ (long) k * 116129781L; hash = hash * hash * 42317861L + hash * 11L; + newX += ((double) ((float) (hash >> 16 & 15L) / 15.0F) - 0.5D) * 0.5D; - newY += ((double) ((float) (hash >> 20 & 15L) / 15.0F) - 1.0D) * 0.2D; newZ += ((double) ((float) (hash >> 24 & 15L) / 15.0F) - 0.5D) * 0.5D; double centerX = 8 / 16D; double centerZ = 8 / 16D; - double c = 0.0D; - newCenterX = (Math.floor(newX * 16 + c) - c) / 16; newCenterZ = (Math.floor(newZ * 16 + c) - c) / 16; } - renderBlocks.drawCrossedSquares(block, renderBlocks.blockAccess.getBlockMetadata(i, j, k), newCenterX, j, newCenterZ, 1.0F); + if (randomHeight) + { + long hash = (long) (i * 3129871L) ^ (long) k * 116129781L; // ^ (long)j; + hash = hash * hash * 42317861L + hash * 11L; + + newY += ((double) ((float) (hash >> 20 & 15L) / 15.0F) - 1.0D) * heightVariation; + + newCenterY = (Math.floor(newY * 16 + c) - c) / 16; + } + + renderBlocks.drawCrossedSquares(block, renderBlocks.blockAccess.getBlockMetadata(i, j, k), newCenterX, newCenterY, newCenterZ, 1.0F); if (!bHasOverride) { renderBlocks.clearOverrideBlockTexture(); } } + public static void renderVerticalPaneWithRotation(RenderBlocks renderer, Block block, int x, int y, int z, double xShift, double yShift, double zShift, double rotationAngleX, double rotationAngleY, double rotationAngleZ, Icon topIcon, Icon bottomIcon){ + renderFaceZPos(renderer, block, x, y, z - 0.5D, xShift, yShift, zShift, rotationAngleX, rotationAngleY, rotationAngleZ, x+0.5D, y+0.5D, z + 0.5D, topIcon,false, false, 0); + renderFaceZNeg(renderer, block, x, y, z + 0.5D, xShift, yShift, zShift, rotationAngleX, rotationAngleY, rotationAngleZ, x+0.5D, y+0.5D, z + 0.5D, bottomIcon,false, false, 0); + } + public static void renderVerticalPaneWithRotation(RenderBlocks renderer, Block block, int x, int y, int z, double xShift, double yShift, double zShift, double rotationAngleX, double rotationAngleY, double rotationAngleZ, double rotationCenterX, double rotationCenterY, double rotationCenterZ , Icon topIcon, Icon bottomIcon){ + renderFaceZPos(renderer, block, x, y, z - 0.5D, xShift, yShift, zShift, rotationAngleX, rotationAngleY, rotationAngleZ, x+rotationCenterX+0.5D, y+rotationCenterY+0.5D, z + rotationCenterZ + 0.5D, topIcon,false, false, 0); + renderFaceZNeg(renderer, block, x, y,z + 0.5D, xShift, yShift, zShift, rotationAngleX, rotationAngleY, rotationAngleZ, x+rotationCenterX+0.5D, y+rotationCenterY+0.5D, z + rotationCenterZ + 0.5D, bottomIcon,false, false, 0); + } + + public static void renderHorizonzalPaneWithRotation(RenderBlocks renderer, Block block, int x, int y, int z, double xShift, double yShift, double zShift, double rotationAngleX, double rotationAngleY, double rotationAngleZ, Icon topIcon, Icon bottomIcon){ + renderFaceYPos(renderer, block, x - xShift, y - 0.5D + yShift, z - zShift, 0, 0, 0, 0, rotationAngleX, rotationAngleY, rotationAngleZ, topIcon,false, false, 0); + renderFaceYNeg(renderer, block, x - xShift, y + 0.5D + yShift, z - zShift, 0, 0, 0, 0, rotationAngleX, rotationAngleY, rotationAngleZ, bottomIcon,false, false, 0); + } + + public static void renderHorizonzalPaneSunflower(RenderBlocks renderer, Block block, int x, int y, int z, double xShift, double yShift, double zShift, double rotationAngleX, double rotationAngleY, double rotationAngleZ, Icon topIcon, Icon bottomIcon, boolean randomOffset, boolean randomHeight, double heightVariation){ + renderFaceYPos(renderer, block, x - xShift, y - 0.5D + yShift, z - zShift, 0, 0, 0, 0, rotationAngleX, rotationAngleY, rotationAngleZ, topIcon, randomOffset, randomHeight, heightVariation); + renderFaceYNeg(renderer, block, x - xShift, y + 0.5D + yShift, z - zShift, 0, 0, 0, 0, rotationAngleX, rotationAngleY, rotationAngleZ, bottomIcon, randomOffset, randomHeight, heightVariation); + } + + public static void renderHorizonzalPaneWithShift(RenderBlocks renderer, Block block, int x, int y, int z, double xShift, double yShift, double zShift, double nwShift, double neShift, double seShift, double swShift, Icon topIcon, Icon bottomIcon){ + renderFaceYPos(renderer, block, x - xShift, y - yShift, z - zShift, nwShift, neShift, seShift, swShift, 0, 0, 0, topIcon, false, false, 0); + renderFaceYNeg(renderer, block, x - xShift, y + yShift, z - zShift, nwShift, neShift, seShift, swShift, 0, 0, 0, bottomIcon, false, false, 0); + } + + + + private static void renderFaceYPos(RenderBlocks renderer, Block block, double x, double y, double z, double nwShift, double neShift, double seShift, double swShift, double rotationAngleX, double rotationAngleY, double rotationAngleZ, Icon icon, boolean randomOffset, boolean randomHeight, double heightVariation){ + Tessellator tess = Tessellator.instance; + //tess.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, (int)x, (int)y, (int)z)); + float brightness = 1.0F; + int colorMultiplier = block.colorMultiplier(renderer.blockAccess, (int)x, (int)y, (int)z); + float var8 = (float)(colorMultiplier >> 16 & 255) / 255.0F; + float var9 = (float)(colorMultiplier >> 8 & 255) / 255.0F; + float var99 = (float)(colorMultiplier & 255) / 255.0F; + + tess.setColorOpaque_F(brightness * var8, brightness * var9, brightness * var99); + + double renderMinX = 0D; + double renderMaxX = 1D; + double renderMinY = 0D; + double renderMaxY = 1D; + double renderMinZ = 0D; + double renderMaxZ = 1D; + + if (renderer.hasOverrideBlockTexture()) + { + icon = renderer.getOverrideTexture(); + } + + double minU = (double)icon.getInterpolatedU(renderMinX * 16.0D); + double maxU = (double)icon.getInterpolatedU(renderMaxX * 16.0D); + double minV = (double)icon.getInterpolatedV(renderMinZ * 16.0D); + double maxV = (double)icon.getInterpolatedV(renderMaxZ * 16.0D); + + if (renderMinX < 0.0D || renderMaxX > 1.0D) + { + minU = (double)icon.getMinU(); + maxU = (double)icon.getMaxU(); + } + + if (renderMinZ < 0.0D || renderMaxZ > 1.0D) + { + minV = (double)icon.getMinV(); + maxV = (double)icon.getMaxV(); + } + + double newMaxU = maxU; + double newMinU = minU; + double newMinV = minV; + double newMaxV = maxV; + +/* + if (renderer.uvRotateTop == 1) + { + minU = (double)icon.getInterpolatedU(renderMinZ * 16.0D); + minV = (double)icon.getInterpolatedV(16.0D - renderMaxX * 16.0D); + maxU = (double)icon.getInterpolatedU(renderMaxZ * 16.0D); + maxV = (double)icon.getInterpolatedV(16.0D - renderMinX * 16.0D); + newMinV = minV; + newMaxV = maxV; + newMaxU = minU; + newMinU = maxU; + minV = maxV; + maxV = newMinV; + } + else if (renderer.uvRotateTop == 2) + { + minU = (double)icon.getInterpolatedU(16.0D - renderMaxZ * 16.0D); + minV = (double)icon.getInterpolatedV(renderMinX * 16.0D); + maxU = (double)icon.getInterpolatedU(16.0D - renderMinZ * 16.0D); + maxV = (double)icon.getInterpolatedV(renderMaxX * 16.0D); + newMaxU = maxU; + newMinU = minU; + minU = maxU; + maxU = newMinU; + newMinV = maxV; + newMaxV = minV; + } + else if (renderer.uvRotateTop == 3) + { + minU = (double)icon.getInterpolatedU(16.0D - renderMinX * 16.0D); + maxU = (double)icon.getInterpolatedU(16.0D - renderMaxX * 16.0D); + minV = (double)icon.getInterpolatedV(16.0D - renderMinZ * 16.0D); + maxV = (double)icon.getInterpolatedV(16.0D - renderMaxZ * 16.0D); + newMaxU = maxU; + newMinU = minU; + newMinV = minV; + newMaxV = maxV; + } +*/ + + double combinedMinX = x + renderMinX; + double combinedMaxX = x + renderMaxX; + double combinedMaxY = y + renderMaxY; + double combinedMinZ = z + renderMinZ; + double combinedMaxZ = z + renderMaxZ; + + double c = 0.0D; + + double newX = x; + double newY = y; + double newZ = z; + +// if (randomOffset) { +// long hash = (long) (x * 3129871L) ^ (long) z * 116129781L; +// hash = hash * hash * 42317861L + hash * 11L; +// +// newX += ((double) ((float) (hash >> 16 & 15L) / 15.0F) - 0.5D) * 0.5D; +// newZ += ((double) ((float) (hash >> 24 & 15L) / 15.0F) - 0.5D) * 0.5D; +// +// double centerX = 8 / 16D; +// double centerZ = 8 / 16D; +// +// newCenterX = (Math.floor(newX * 16 + c) - c) / 16; +// newCenterZ = (Math.floor(newZ * 16 + c) - c) / 16; +// } + + if (randomHeight) + { + long hash = (long) (x * 3129871L) ^ (long) z * 116129781L; // ^ (long)j; + hash = hash * hash * 42317861L + hash * 11L; + + newY += ((double) ((float) (hash >> 20 & 15L) / 15.0F) - 1.0D) * heightVariation; + newY += 1D; + combinedMaxY = (Math.floor(newY * 16 + c) - c) / 16; + } + + if (rotationAngleX != 0 || rotationAngleY != 0 || rotationAngleZ != 0) + { + // Calculate the centroid of the plane (average of all X and Z coordinates) + double centroidX = (combinedMaxX + combinedMinX) / 2.0; + double centroidZ = (combinedMaxZ + combinedMinZ) / 2.0; + double centroidY = combinedMaxY; // Assuming the Y coordinate is constant in this case + + // Convert angles from degrees to radians + double rotationAngleRadX = Math.toRadians(rotationAngleX); + double rotationAngleRadY = Math.toRadians(rotationAngleY); + double rotationAngleRadZ = Math.toRadians(rotationAngleZ); + + // Precompute cosines and sines for each axis rotation + double cosX = Math.cos(rotationAngleRadX); + double sinX = Math.sin(rotationAngleRadX); + double cosY = Math.cos(rotationAngleRadY); + double sinY = Math.sin(rotationAngleRadY); + double cosZ = Math.cos(rotationAngleRadZ); + double sinZ = Math.sin(rotationAngleRadZ); + + // Rotate each vertex's X, Y, Z coordinates + double[] vertex1 = rotate3D(combinedMaxX, combinedMaxY + seShift, combinedMaxZ, + centroidX, centroidY, centroidZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + double[] vertex2 = rotate3D(combinedMaxX, combinedMaxY + neShift, combinedMinZ, + centroidX, centroidY, centroidZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + double[] vertex3 = rotate3D(combinedMinX, combinedMaxY + nwShift, combinedMinZ, + centroidX, centroidY, centroidZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + double[] vertex4 = rotate3D(combinedMinX, combinedMaxY + swShift, combinedMaxZ, + centroidX, centroidY, centroidZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + + // Replace the original coordinates with the rotated ones in the vertex function + tess.addVertexWithUV(vertex1[0], vertex1[1], vertex1[2], maxU, maxV); + tess.addVertexWithUV(vertex2[0], vertex2[1], vertex2[2], newMaxU, newMinV); + tess.addVertexWithUV(vertex3[0], vertex3[1], vertex3[2], minU, minV); + tess.addVertexWithUV(vertex4[0], vertex4[1], vertex4[2], newMinU, newMaxV); + } + else { + tess.addVertexWithUV(combinedMaxX, combinedMaxY + seShift, combinedMaxZ, maxU, maxV); + tess.addVertexWithUV(combinedMaxX, combinedMaxY + neShift, combinedMinZ, newMaxU, newMinV); + tess.addVertexWithUV(combinedMinX, combinedMaxY + nwShift, combinedMinZ, minU, minV); + tess.addVertexWithUV(combinedMinX, combinedMaxY + swShift, combinedMaxZ, newMinU, newMaxV); + } + } + + private static void renderFaceYNeg(RenderBlocks renderer, Block block, double x, double y, double z, double nwShift, double neShift, double seShift, double swShift, double rotationAngleX, double rotationAngleY, double rotationAngleZ, Icon icon, boolean randomOffset, boolean randomHeight, double heightVariation){ + + Tessellator tess = Tessellator.instance; + //tess.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, (int)x, (int)y, (int)z)); + float brightness = 1.0F; + int colorMultiplier = block.colorMultiplier(renderer.blockAccess, (int)x, (int)y, (int)z); + float red = (float)(colorMultiplier >> 16 & 255) / 255.0F; + float green = (float)(colorMultiplier >> 8 & 255) / 255.0F; + float blue = (float)(colorMultiplier & 255) / 255.0F; + + tess.setColorOpaque_F(brightness * red, brightness * green, brightness * blue); + + if (renderer.hasOverrideBlockTexture()) + { + icon = renderer.getOverrideTexture(); + } + + double minU = (double)icon.getInterpolatedU(renderMinX * 16.0D); + double maxU = (double)icon.getInterpolatedU(renderMaxX * 16.0D); + double minV = (double)icon.getInterpolatedV(renderMinZ * 16.0D); + double maxV = (double)icon.getInterpolatedV(renderMaxZ * 16.0D); + + if (renderMinX < 0.0D || renderMaxX > 1.0D) + { + minU = (double)icon.getMinU(); + maxU = (double)icon.getMaxU(); + } + + if (renderMinZ < 0.0D || renderMaxZ > 1.0D) + { + minV = (double)icon.getMinV(); + maxV = (double)icon.getMaxV(); + } + + double newMaxU = maxU; + double newMinU = minU; + double newMinV = minV; + double newMaxV = maxV; + +// double scale = 0.45D; + double combinedMinX = x + renderMinX;// - scale; + double combinedMaxX = x + renderMaxX;// + scale; + double combinedMinY = y + renderMinY; + double combinedMinZ = z + renderMinZ;// - scale; + double combinedMaxZ = z + renderMaxZ;// + scale; + + double c = 0.0D; + + double newX = x; + double newY = y; + double newZ = z; + +// if (randomOffset) { +// long hash = (long) (x * 3129871L) ^ (long) z * 116129781L; +// hash = hash * hash * 42317861L + hash * 11L; +// +// newX += ((double) ((float) (hash >> 16 & 15L) / 15.0F) - 0.5D) * 0.5D; +// newZ += ((double) ((float) (hash >> 24 & 15L) / 15.0F) - 0.5D) * 0.5D; +// +// double centerX = 8 / 16D; +// double centerZ = 8 / 16D; +// +// newCenterX = (Math.floor(newX * 16 + c) - c) / 16; +// newCenterZ = (Math.floor(newZ * 16 + c) - c) / 16; +// } + + if (randomHeight) + { + long hash = (long) (x * 3129871L) ^ (long) z * 116129781L; // ^ (long)j; + hash = hash * hash * 42317861L + hash * 11L; + + newY += ((double) ((float) (hash >> 20 & 15L) / 15.0F) - 1.0D) * heightVariation; + + combinedMinY = (Math.floor(newY * 16 + c) - c) / 16; + } + + if (rotationAngleX != 0 || rotationAngleY != 0 || rotationAngleZ != 0) + { + // Calculate the centroid of the plane (average of all X and Z coordinates) + double centroidX = (combinedMaxX + combinedMinX) / 2.0; + double centroidZ = (combinedMaxZ + combinedMinZ) / 2.0; + double centroidY = combinedMinY; // Assuming the Y coordinate is constant in this case + + // Convert angles from degrees to radians + double rotationAngleRadX = Math.toRadians(rotationAngleX); + double rotationAngleRadY = Math.toRadians(rotationAngleY); + double rotationAngleRadZ = Math.toRadians(rotationAngleZ); + + // Precompute cosines and sines for each axis rotation + double cosX = Math.cos(rotationAngleRadX); + double sinX = Math.sin(rotationAngleRadX); + double cosY = Math.cos(rotationAngleRadY); + double sinY = Math.sin(rotationAngleRadY); + double cosZ = Math.cos(rotationAngleRadZ); + double sinZ = Math.sin(rotationAngleRadZ); + + // Rotate each vertex's X, Y, Z coordinates of the bottom-facing plane + double[] vertex1 = rotate3D(combinedMinX, combinedMinY, combinedMaxZ, + centroidX, centroidY, centroidZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + double[] vertex2 = rotate3D(combinedMinX, combinedMinY, combinedMinZ, + centroidX, centroidY, centroidZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + double[] vertex3 = rotate3D(combinedMaxX, combinedMinY, combinedMinZ, + centroidX, centroidY, centroidZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + double[] vertex4 = rotate3D(combinedMaxX, combinedMinY, combinedMaxZ, + centroidX, centroidY, centroidZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + + // Replace the original coordinates with the rotated ones in the vertex function + tess.addVertexWithUV(vertex1[0], vertex1[1], vertex1[2], newMinU, newMaxV); + tess.addVertexWithUV(vertex2[0], vertex2[1], vertex2[2], minU, minV); + tess.addVertexWithUV(vertex3[0], vertex3[1], vertex3[2], newMaxU, newMinV); + tess.addVertexWithUV(vertex4[0], vertex4[1], vertex4[2], maxU, maxV); + } + else { + tess.addVertexWithUV(combinedMinX, combinedMinY + seShift, combinedMaxZ, newMinU, newMaxV); + tess.addVertexWithUV(combinedMinX, combinedMinY + neShift, combinedMinZ, minU, minV); + tess.addVertexWithUV(combinedMaxX, combinedMinY + nwShift, combinedMinZ, newMaxU, newMinV); + tess.addVertexWithUV(combinedMaxX, combinedMinY + swShift, combinedMaxZ, maxU, maxV); + } + + } + + public static void renderFaceZNeg(RenderBlocks renderer, Block block, double x, double y, double z, double xShift, double yShift, double zShift, double rotationAngleX, double rotationAngleY, double rotationAngleZ, double rotationCenterX, double rotationCenterY, double rotationCenterZ, Icon icon, boolean randomOffset, boolean randomHeight, double heightVariation) + { + Tessellator tess = Tessellator.instance; + //tess.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, (int)x, (int)y, (int)z)); + float brightness = 1.0F; + int colorMultiplier = block.colorMultiplier(renderer.blockAccess, (int)x, (int)y, (int)z); + float red = (float)(colorMultiplier >> 16 & 255) / 255.0F; + float green = (float)(colorMultiplier >> 8 & 255) / 255.0F; + float blue = (float)(colorMultiplier & 255) / 255.0F; + + tess.setColorOpaque_F(brightness * red, brightness * green, brightness * blue); + + if (renderer.hasOverrideBlockTexture()) + { + icon = renderer.getOverrideTexture(); + } + + double minX = (double)icon.getInterpolatedU(renderMinX * 16.0D); + double maxX = (double)icon.getInterpolatedU(renderMaxX * 16.0D); + double maxY = (double)icon.getInterpolatedV(16.0D - renderMaxY * 16.0D); + double minY = (double)icon.getInterpolatedV(16.0D - renderMinY * 16.0D); + double newMaxX; + + if (renderMinX < 0.0D || renderMaxX > 1.0D) + { + minX = (double)icon.getMinU(); + maxX = (double)icon.getMaxU(); + } + + if (renderMinY < 0.0D || renderMaxY > 1.0D) + { + maxY = (double)icon.getMinV(); + minY = (double)icon.getMaxV(); + } + + newMaxX = maxX; + double newMinX = minX; + double newMaxY = maxY; + double newMinY = minY; + + double combinedMinX = x + renderMinX; // + xShift; + double combinedMaxX = x + renderMaxX; // + xShift; + double combinedMinY = y + renderMinY; // + yShift; + double combinedMaxY = y + renderMaxY; // + yShift; + double combinedMinZ = z + renderMinZ; // + zShift; + + double c = 0.0D; + + double newX = x; + double newY = y; + double newZ = z; + + if (randomHeight) + { + long hash = (long) (x * 3129871L) ^ (long) z * 116129781L; // ^ (long)j; + hash = hash * hash * 42317861L + hash * 11L; + + newY += ((double) ((float) (hash >> 20 & 15L) / 15.0F) - 1.0D) * heightVariation; + + combinedMinY = (Math.floor(newY * 16 + c) - c) / 16; + } + + if (rotationAngleX != 0 || rotationAngleY != 0 || rotationAngleZ != 0) { + // Calculate the centroid for rotation + double centroidX = (combinedMinX + combinedMaxX) / 2.0; + double centroidY = (combinedMinY + combinedMaxY) / 2.0; + double centroidZ = combinedMinZ; + + // Convert rotation angles from degrees to radians + double rotationAngleRadX = Math.toRadians(rotationAngleX); + double rotationAngleRadY = Math.toRadians(rotationAngleY); + double rotationAngleRadZ = Math.toRadians(rotationAngleZ); + + // Precompute cosines and sines for each axis rotation + double cosX = Math.cos(rotationAngleRadX); + double sinX = Math.sin(rotationAngleRadX); + double cosY = Math.cos(rotationAngleRadY); + double sinY = Math.sin(rotationAngleRadY); + double cosZ = Math.cos(rotationAngleRadZ); + double sinZ = Math.sin(rotationAngleRadZ); + + // Rotate each vertex around the centroid + double[] vertex1 = rotate3D(combinedMinX, combinedMaxY, combinedMinZ, + rotationCenterX, rotationCenterY, rotationCenterZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + double[] vertex2 = rotate3D(combinedMaxX, combinedMaxY, combinedMinZ, + rotationCenterX, rotationCenterY, rotationCenterZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + double[] vertex3 = rotate3D(combinedMaxX, combinedMinY, combinedMinZ, + rotationCenterX, rotationCenterY, rotationCenterZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + double[] vertex4 = rotate3D(combinedMinX, combinedMinY, combinedMinZ, + rotationCenterX, rotationCenterY, rotationCenterZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + + // Shift vertices + vertex1[0] += xShift; + vertex2[0] += xShift; + vertex3[0] += xShift; + vertex4[0] += xShift; + + vertex1[1] += yShift; + vertex2[1] += yShift; + vertex3[1] += yShift; + vertex4[1] += yShift; + + vertex1[2] += zShift; + vertex2[2] += zShift; + vertex3[2] += zShift; + vertex4[2] += zShift; + + // Render the rotated vertices + tess.addVertexWithUV(vertex1[0], vertex1[1], vertex1[2], maxX, maxY); + tess.addVertexWithUV(vertex2[0], vertex2[1], vertex2[2], minX, maxY); + tess.addVertexWithUV(vertex3[0], vertex3[1], vertex3[2], minX, minY); + tess.addVertexWithUV(vertex4[0], vertex4[1], vertex4[2], maxX, minY); + } + else { + tess.addVertexWithUV(combinedMinX, combinedMaxY, combinedMinZ, newMaxX, newMaxY); + tess.addVertexWithUV(combinedMaxX, combinedMaxY, combinedMinZ, minX, maxY); + tess.addVertexWithUV(combinedMaxX, combinedMinY, combinedMinZ, newMinX, newMinY); + tess.addVertexWithUV(combinedMinX, combinedMinY, combinedMinZ, maxX, minY); + } + + } + + /** + * Renders the given texture to the south (z-positive) face of the block. Args: block, x, y, z, texture + */ + public static void renderFaceZPos(RenderBlocks renderer, Block block, double x, double y, double z, double xShift, double yShift, double zShift, double rotationAngleX, double rotationAngleY, double rotationAngleZ, double rotationCenterX, double rotationCenterY, double rotationCenterZ, Icon icon, boolean randomOffset, boolean randomHeight, double heightVariation) + { + Tessellator tess = Tessellator.instance; + float brightness = 1.0F; + int colorMultiplier = block.colorMultiplier(renderer.blockAccess, (int)x, (int)y, (int)z); + float var8 = (float)(colorMultiplier >> 16 & 255) / 255.0F; + float var9 = (float)(colorMultiplier >> 8 & 255) / 255.0F; + float var99 = (float)(colorMultiplier & 255) / 255.0F; + + tess.setColorOpaque_F(brightness * var8, brightness * var9, brightness * var99); + + if (renderer.hasOverrideBlockTexture()) + { + icon = renderer.getOverrideTexture(); + } + + double minU = (double)icon.getInterpolatedU(renderMinX * 16.0D); + double maxU = (double)icon.getInterpolatedU(renderMaxX * 16.0D); + double minV = (double)icon.getInterpolatedV(16.0D - renderMaxY * 16.0D); + double maxV = (double)icon.getInterpolatedV(16.0D - renderMinY * 16.0D); + double newMaxU; + + + if (renderMinX < 0.0D || renderMaxX > 1.0D) + { + minU = (double)icon.getMinU(); + maxU = (double)icon.getMaxU(); + } + + if (renderMinY < 0.0D || renderMaxY > 1.0D) + { + minV = (double)icon.getMinV(); + maxV = (double)icon.getMaxV(); + } + + newMaxU = maxU; + double newMinU = minU; + double newMinV = minV; + double newMaxV = maxV; + + double combinedMinX = x + renderMinX; // + xShift; + double combinedMaxX = x + renderMaxX; // + xShift; + double combinedMinY = y + renderMinY; // + yShift; + double combinedMaxY = y + renderMaxY; // + yShift; + double combinedMaxZ = z + renderMaxZ; // + zShift; + + double c = 0.0D; + + double newX = x; + double newY = y; + double newZ = z; + + if (randomHeight) + { + long hash = (long) (x * 3129871L) ^ (long) z * 116129781L; // ^ (long)j; + hash = hash * hash * 42317861L + hash * 11L; + + newY += ((double) ((float) (hash >> 20 & 15L) / 15.0F) - 1.0D) * heightVariation; + + combinedMinY = (Math.floor(newY * 16 + c) - c) / 16; + } + + if (rotationAngleX != 0 || rotationAngleY != 0 || rotationAngleZ != 0) + { + // Calculate the centroid of the face for rotation + double centroidX = (combinedMinX + combinedMaxX) / 2.0; + double centroidY = (combinedMinY + combinedMaxY) / 2.0; + double centroidZ = combinedMaxZ; + + // Convert rotation angles from degrees to radians + double rotationAngleRadX = Math.toRadians(rotationAngleX); + double rotationAngleRadY = Math.toRadians(rotationAngleY); + double rotationAngleRadZ = Math.toRadians(rotationAngleZ); + + // Precompute cosines and sines for each axis rotation + double cosX = Math.cos(rotationAngleRadX); + double sinX = Math.sin(rotationAngleRadX); + double cosY = Math.cos(rotationAngleRadY); + double sinY = Math.sin(rotationAngleRadY); + double cosZ = Math.cos(rotationAngleRadZ); + double sinZ = Math.sin(rotationAngleRadZ); + + // Rotate each vertex around the centroid + double[] vertex1 = rotate3D(combinedMinX, combinedMaxY, combinedMaxZ, + rotationCenterX, rotationCenterY, rotationCenterZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + double[] vertex2 = rotate3D(combinedMinX, combinedMinY, combinedMaxZ, + rotationCenterX, rotationCenterY, rotationCenterZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + double[] vertex3 = rotate3D(combinedMaxX, combinedMinY, combinedMaxZ, + rotationCenterX, rotationCenterY, rotationCenterZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + double[] vertex4 = rotate3D(combinedMaxX, combinedMaxY, combinedMaxZ, + rotationCenterX, rotationCenterY, rotationCenterZ, cosX, sinX, cosY, sinY, cosZ, sinZ); + + // Shift vertices + vertex1[0] += xShift; + vertex2[0] += xShift; + vertex3[0] += xShift; + vertex4[0] += xShift; + + vertex1[1] += yShift; + vertex2[1] += yShift; + vertex3[1] += yShift; + vertex4[1] += yShift; + + vertex1[2] += zShift; + vertex2[2] += zShift; + vertex3[2] += zShift; + vertex4[2] += zShift; + + // Render the rotated vertices + tess.addVertexWithUV(vertex1[0], vertex1[1], vertex1[2], minU, minV); + tess.addVertexWithUV(vertex2[0], vertex2[1], vertex2[2], minU, maxV); + tess.addVertexWithUV(vertex3[0], vertex3[1], vertex3[2], maxU, maxV); + tess.addVertexWithUV(vertex4[0], vertex4[1], vertex4[2], maxU, minV); + } + else { + tess.addVertexWithUV(combinedMinX, combinedMaxY, combinedMaxZ, minU, minV); + tess.addVertexWithUV(combinedMinX, combinedMinY, combinedMaxZ, newMinU, newMaxV); + tess.addVertexWithUV(combinedMaxX, combinedMinY, combinedMaxZ, maxU, maxV); + tess.addVertexWithUV(combinedMaxX, combinedMaxY, combinedMaxZ, newMaxU, newMinV); + } + } + + // Helper function to rotate a 3D point around a custom center point + private static double[] rotate3D(double x, double y, double z, + double centerX, double centerY, double centerZ, + double cosX, double sinX, double cosY, double sinY, double cosZ, double sinZ) { + // Translate point to the custom rotation center + double dx = x - centerX; + double dy = y - centerY; + double dz = z - centerZ; + + // Apply rotation around X-axis + double newY = dy * cosX - dz * sinX; + double newZ = dy * sinX + dz * cosX; + + // Apply rotation around Y-axis + double newX = dx * cosY + newZ * sinY; + newZ = -dx * sinY + newZ * cosY; + + // Apply rotation around Z-axis + double finalX = newX * cosZ - newY * sinZ; + double finalY = newX * sinZ + newY * cosZ; + double finalZ = newZ; + + // Translate point back to the original coordinates + return new double[]{finalX + centerX, finalY + centerY, finalZ + centerZ}; + } + + public static void renderMultiFlowerBlock(RenderBlocks renderer, Block block, int x, int y, int z, Icon[] icon){ + Tessellator tess = Tessellator.instance; + IBlockAccess blockAccess = renderer.blockAccess; + + tess.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z)); + float var6 = 1.0F; + int var7 = block.colorMultiplier(renderer.blockAccess, x, y, z); + float var8 = (float)(var7 >> 16 & 255) / 255.0F; + float var9 = (float)(var7 >> 8 & 255) / 255.0F; + float var10 = (float)(var7 & 255) / 255.0F; + + tess.setColorOpaque_F(var6 * var8, var6 * var9, var6 * var10); + + renderer.setRenderBounds(0,0,0,1,1,1); + + + int meta = blockAccess.getBlockMetadata(x,y,z); + int stage = MultiFlowerBlock.getStage(meta); + int dir = MultiFlowerBlock.getDirection(meta); + + switch (dir) { + default: + case 0: // Default direction (no change) + renderer.setUVRotateTop(0); + renderer.setUVRotateBottom(0); + renderThis(renderer, block, x, y, z, stage, icon); + renderer.clearUVRotation(); + break; + + case 1: // Rotated 90 degrees clockwise + renderer.setUVRotateTop(1); + renderer.setUVRotateBottom(2); + renderThis(renderer, block, x, y, z, stage, icon); + renderer.clearUVRotation(); + break; + + case 2: // Rotated 180 degrees + renderer.setUVRotateTop(3); + renderer.setUVRotateBottom(3); + renderThis(renderer, block, x, y, z, stage, icon); + renderer.clearUVRotation(); + break; + + case 3: // Rotated 270 degrees clockwise (or 90 degrees counterclockwise) + renderer.setUVRotateTop(2); + renderer.setUVRotateBottom(1); + renderThis(renderer, block, x, y, z, stage, icon); + renderer.clearUVRotation(); + break; + } + } + + private static void renderThis(RenderBlocks renderer, Block block, int x, int y, int z, int stage, Icon[] icon) { + if (stage >= 0) { + renderCornerSE(renderer, block, x, y, z, icon); + } + if (stage >= 1) { + renderCornerNE(renderer, block, x, y, z, icon); + } + if (stage >= 2) { + renderCornerNW(renderer, block, x, y, z, icon); + } + if (stage >= 3) { + renderCornerSW(renderer, block, x, y, z, icon); + } + } + + public static void renderStalkFlowers(RenderBlocks renderer, Block block, int x, int y, int z, int stage, int dir, int[] numberOfStalks, double[][][] shifts, Icon[] icon) { + renderStalkFlowers(renderer, block, x, y, z, stage, dir, numberOfStalks, shifts, new double[] {3/16D, 3/16D} ,icon); + } + + private static void renderStalkFlowers(RenderBlocks renderer, Block block, int x, int y, int z, int stage, int dir, int[] numberOfStalks, double[][][] shifts, double[] yShifts, Icon[] icon) { + if (dir >= 0 && dir <= 3) { + Block blockAbove = Block.blocksList[renderer.blockAccess.getBlockId(x,y + 1,z)]; + double snowShift = 0D; + if (blockAbove instanceof GroundCoverBlock) snowShift += groundShift; + + if (stage >= 1) { + for (int i = 0; i < numberOfStalks[1]; i++) { + double[] rotatedShift = rotateAntiClockwise(shifts[1][i][0], shifts[1][i][1], dir); + double xShift = rotatedShift[0]; + double zShift = rotatedShift[1]; + double yShift = -2/16D + yShifts[0] + snowShift; + renderCrossedSquaresWithTexture(renderer, block, x, y, z, xShift, yShift, zShift, icon[0], false); + } + } + + if (stage >= 3) { + for (int i = 0; i < numberOfStalks[3]; i++) { + double[] rotatedShift = rotateAntiClockwise(shifts[3][i][0], shifts[3][i][1], dir); + double xShift = rotatedShift[0]; + double zShift = rotatedShift[1]; + double yShift = -1/16D + yShifts[1] + snowShift; + renderCrossedSquaresWithTexture(renderer, block, x, y, z, xShift, yShift, zShift, icon[1], false); + } + } + } + } + + public static void renderStalks(RenderBlocks renderer, Block block, int x, int y, int z, int stage, int dir, int[] numberOfStalks, double[][][] shifts, Icon[] icon) { + if (dir >= 0 && dir <= 3) { + Block blockAbove = Block.blocksList[renderer.blockAccess.getBlockId(x,y + 1,z)]; + double snowShift = 0D; + if (blockAbove instanceof GroundCoverBlock) snowShift += groundShift; + + if (stage >= 0) { + for (int i = 0; i < numberOfStalks[0]; i++) { + double[] rotatedShift = rotateAntiClockwise(shifts[0][i][0], shifts[0][i][1], dir); + double xShift = rotatedShift[0]; + double zShift = rotatedShift[1]; + double yShift = 0/16D + snowShift; + renderCrossedSquaresWithTexture(renderer, block, x, y, z, xShift, yShift, zShift, icon[0], false); + } + } + + if (stage >= 1) { + for (int i = 0; i < numberOfStalks[1]; i++) { + double[] rotatedShift = rotateAntiClockwise(shifts[1][i][0], shifts[1][i][1], dir); + double xShift = rotatedShift[0]; + double zShift = rotatedShift[1]; + double yShift = -2/16D + snowShift; + renderCrossedSquaresWithTexture(renderer, block, x, y, z, xShift, yShift, zShift, icon[1], false); + } + } + + if (stage >= 2) { + for (int i = 0; i < numberOfStalks[2]; i++) { + double[] rotatedShift = rotateAntiClockwise(shifts[2][i][0], shifts[2][i][1], dir); + double xShift = rotatedShift[0]; + double zShift = rotatedShift[1]; + double yShift = -1/16D + snowShift; + renderCrossedSquaresWithTexture(renderer, block, x, y, z, xShift, yShift, zShift, icon[2], false); + } + } + + if (stage >= 3) { + for (int i = 0; i < numberOfStalks[3]; i++) { + double[] rotatedShift = rotateAntiClockwise(shifts[3][i][0], shifts[3][i][1], dir); + double xShift = rotatedShift[0]; + double zShift = rotatedShift[1]; + double yShift = -1/16D + snowShift; + renderCrossedSquaresWithTexture(renderer, block, x, y, z, xShift, yShift, zShift, icon[3], false); + } + } + } + } + + public static double[] rotateClockwise(double xShift, double zShift, int dir) { + for (int i = 0; i < dir; i++) { + // Rotate 90 degrees clockwise: (x, z) -> (z, -x) + double temp = xShift; + xShift = zShift; + zShift = -temp; + } + return new double[]{xShift, zShift}; + } + + public static double[] rotateAntiClockwise(double xShift, double zShift, int dir) { + for (int i = 0; i < dir; i++) { + // Rotate 90 degrees anti-clockwise: (x, z) -> (-z, x) + double temp = xShift; + xShift = -zShift; + zShift = temp; + } + return new double[]{xShift, zShift}; + } + + private static void renderCornerSW(RenderBlocks renderer, Block block, int x, int y, int z, Icon[] icon) { + Block blockAbove = Block.blocksList[renderer.blockAccess.getBlockId(x,y + 1,z)]; + double snowShift = 0D; + if (blockAbove instanceof GroundCoverBlock) snowShift += groundShift; + + renderer.renderFaceYNeg(block, x, y + 2/16D + snowShift, z, icon[3]); + renderer.renderFaceYPos(block, x, y - 14/16D + snowShift, z, icon[3]); + } + + private static void renderCornerNW(RenderBlocks renderer, Block block, int x, int y, int z, Icon[] icon) { + Block blockAbove = Block.blocksList[renderer.blockAccess.getBlockId(x,y + 1,z)]; + double snowShift = 0D; + if (blockAbove instanceof GroundCoverBlock) snowShift += groundShift; + + renderer.renderFaceYNeg(block, x, y + 2/16D + snowShift, z, icon[2]); + renderer.renderFaceYPos(block, x, y - 14/16D + snowShift, z, icon[2]); + } + + private static void renderCornerNE(RenderBlocks renderer, Block block, int x, int y, int z, Icon[] icon) { + Block blockAbove = Block.blocksList[renderer.blockAccess.getBlockId(x,y + 1,z)]; + double snowShift = 0D; + if (blockAbove instanceof GroundCoverBlock) snowShift += groundShift; + + + renderer.renderFaceYNeg(block, x, y + 1 / 16D + snowShift, z, icon[1]); + renderer.renderFaceYPos(block, x, y - 15 / 16D + snowShift, z, icon[1]); + } + + private static void renderCornerSE(RenderBlocks renderer, Block block, int x, int y, int z, Icon[] icon) { + Block blockAbove = Block.blocksList[renderer.blockAccess.getBlockId(x,y + 1,z)]; + double snowShift = 0D; + if (blockAbove instanceof GroundCoverBlock) snowShift += groundShift; + + renderer.renderFaceYNeg(block, x, y + 3/16D + snowShift, z, icon[0]); + renderer.renderFaceYPos(block, x, y - 13/16D + snowShift, z, icon[0]); + } + + + public static boolean renderCrossedSquares(RenderBlocks renderer, Block par1Block, int metadata, int par2, int par3, int par4, float xShift, float yShift, float zShift, float scale, boolean randomHeight) + { + Tessellator var5 = Tessellator.instance; + var5.setBrightness(par1Block.getMixedBrightnessForBlock(renderer.blockAccess, par2, par3, par4)); + float var6 = 1.0F; + int var7 = par1Block.colorMultiplier(renderer.blockAccess, par2, par3, par4); + float var8 = (float)(var7 >> 16 & 255) / 255.0F; + float var9 = (float)(var7 >> 8 & 255) / 255.0F; + float var10 = (float)(var7 & 255) / 255.0F; + + var5.setColorOpaque_F(var6 * var8, var6 * var9, var6 * var10); + double var19 = (double)par2; + double var20 = (double)par3; + double var15 = (double)par4; + + var19 += xShift; + var20 += yShift; + var15 += zShift; + + if (randomHeight) + { + long var17 = (long)(par2 * 3129871) ^ (long)par4 * 116129781L ^ (long)par3; + var17 = var17 * var17 * 42317861L + var17 * 11L; + var19 += ((double)((float)(var17 >> 16 & 15L) / 15.0F) - 0.5D) * 0.5D; + var20 += ((double)((float)(var17 >> 20 & 15L) / 15.0F) - 1.0D) * 0.2D; + var15 += ((double)((float)(var17 >> 24 & 15L) / 15.0F) - 0.5D) * 0.5D; + } + + drawCrossedSquares(renderer, par1Block, metadata, var19, var20, var15, scale); + return true; + } + + private static void drawCrossedSquares(RenderBlocks renderer, Block par1Block, int par2, double par3, double par5, double par7, float par9) + { + Tessellator var10 = Tessellator.instance; + Icon var11 = renderer.getBlockIconFromSideAndMetadata(par1Block, 0, par2); + if (renderer.hasOverrideBlockTexture()) + { + var11 = renderer.getOverrideTexture(); + } + + double var12 = (double)var11.getMinU(); + double var14 = (double)var11.getMinV(); + double var16 = (double)var11.getMaxU(); + double var18 = (double)var11.getMaxV(); + double var20 = 0.45D * (double)par9; + double var22 = par3 + 0.5D - var20; + double var24 = par3 + 0.5D + var20; + double var26 = par7 + 0.5D - var20; + double var28 = par7 + 0.5D + var20; + var10.addVertexWithUV(var22, par5 + (double)par9, var26, var12, var14); + var10.addVertexWithUV(var22, par5 + 0.0D, var26, var12, var18); + var10.addVertexWithUV(var24, par5 + 0.0D, var28, var16, var18); + var10.addVertexWithUV(var24, par5 + (double)par9, var28, var16, var14); + var10.addVertexWithUV(var24, par5 + (double)par9, var28, var12, var14); + var10.addVertexWithUV(var24, par5 + 0.0D, var28, var12, var18); + var10.addVertexWithUV(var22, par5 + 0.0D, var26, var16, var18); + var10.addVertexWithUV(var22, par5 + (double)par9, var26, var16, var14); + var10.addVertexWithUV(var22, par5 + (double)par9, var28, var12, var14); + var10.addVertexWithUV(var22, par5 + 0.0D, var28, var12, var18); + var10.addVertexWithUV(var24, par5 + 0.0D, var26, var16, var18); + var10.addVertexWithUV(var24, par5 + (double)par9, var26, var16, var14); + var10.addVertexWithUV(var24, par5 + (double)par9, var26, var12, var14); + var10.addVertexWithUV(var24, par5 + 0.0D, var26, var12, var18); + var10.addVertexWithUV(var22, par5 + 0.0D, var28, var16, var18); + var10.addVertexWithUV(var22, par5 + (double)par9, var28, var16, var14); + } } diff --git a/src/main/java/btw/community/sockthing/sockscrops/utils/WorldGenUtils.java b/src/main/java/btw/community/sockthing/sockscrops/utils/WorldGenUtils.java new file mode 100644 index 0000000..0f94014 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/utils/WorldGenUtils.java @@ -0,0 +1,22 @@ +package btw.community.sockthing.sockscrops.utils; + +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.interfaces.BlockInterface; +import net.minecraft.src.Block; +import net.minecraft.src.World; + +public class WorldGenUtils{ + public static boolean canLeavesBePlaced(World world, int x, int y, int z) + { + + int blockID = world.getBlockId(x, y, z); + Block block = Block.blocksList[blockID]; + + if (blockID == 0 || ((BlockInterface)block).canBeReplacedByLeaves(blockID) ) + { + return true; + } + + return false; + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/world/BBBiomeIDs.java b/src/main/java/btw/community/sockthing/sockscrops/world/BBBiomeIDs.java new file mode 100644 index 0000000..8a558ff --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/world/BBBiomeIDs.java @@ -0,0 +1,147 @@ +package btw.community.sockthing.sockscrops.world; + +public class BBBiomeIDs extends BTABiomeIDs { + //BB + public static final int + //Nether + //NETHER_WASTES_ID = 90, + ASH_FIELDS_ID = 91, + BASALT_DELTAS_ID = 92, + SOUL_SAND_VALLEY_ID = 93, + OBSIDIAN_GROVE_ID = 94, + CRYSTAL_CAVERNS_ID = 95, + PETRIFIED_FOREST_ID = 96, + //Primary + FIELD_ID = 98, + BOWER_ID = 99, + //WOODS_ID = 100, + //DESERT_ID = 101, + LUSH_DESERT_ID = 102, + OASIS_ID = 103, + SAVANNA_ID = 104, + WETLANDS_ID = 105, + BIRCH_FOREST_ID = 106, + SNOWY_WOODS_ID = 107, + STEPPE_ID = 108, + WOODED_STEPPE_ID = 109, + CHAPPARAL_ID = 110, + OLD_GROWTH_WOODLAND_ID = 111, + TROPICS_ID = 112, + //JUNGLE_ID = 113, + ALPINE_ID = 114, + ASPEN_GROVE_ID = 115, + FUNGAL_FOREST_ID = 116, + CONIFEROUS_FOREST_ID = 117, + CONIFEROUS_FOREST_CLEARING_ID = 118, + SNOWY_CONIFEROUS_FOREST_ID = 119, + SNOWY_CONIFEROUS_FOREST_CLEARING_ID = 120, + MYSTIC_Valley_ID = 121, + RAINFOREST_ID = 122, + MEADOW_ID = 123, + ORCHARD_ID = 124, + //MOUNTAINS_ID = 125, + DUNES_ID = 126, + HEATHLAND_ID = 127, + HEATHLAND_WOODS_ID = 128, + TEMPERATE_FOREST_ID = 129, + VALLEY_MOUNTAINS_ID = 130, + OLD_VALLEY_ID = 131, + //TUNDRA_ID = 132, + WILLOW_GROVE_ID = 133, + //ICY_PEAKS_ID = 134, + PATAGONIA_ID = 135, + GRASSLANDS_ID = 136, + //SIBERIA_ID = 137, + //PLAINS_ID = 138, + FROZEN_SPRINGS_ID = 139, + MANGROVE_FOREST_ID = 140, + BOREAL_FOREST_ID = 141, + //ARID_FOREST_ID = 142, + SHIELD_ID = 143, + BRUSHLAND_ID = 144, + HIGHLANDS_ID = 145, + FLORAL_FOREST_ID = 146, + REDWOOD_FOREST_ID = 147, + ICE_MARSH_ID = 148, + FORESTED_HIGHLANDS_ID = 149, + //Sub biomes + //WOODS_HILLS_ID = 150, + //DESERT_HILLS_ID = 151, + SAVANNA_HILLS_ID = 152, + BIRCH_FOREST_HILLS_ID = 153, + SNOWY_WOODS_HILLS = 154, + CHAPPARAL_HILLS_ID = 155, + OLD_GROWTH_WOODLAND_HILLS_ID = 156, + //JUNGLE_HILLS_ID = 157, + FUNGAL_FOREST_FLAT_ID = 158, + WETLANDS_HILLS_ID = 159, + CHERRY_BLOSSOM_GROVE_HILLS_ID = 160, + SEASONAL_FOREST_HILLS_ID = 161, + VALLEY_ID = 162, + ORCHARD_CLEARING_ID = 163, + WILLOW_HILLS_ID = 164, + //ICY_PEAKS_FORESTED_ID = 165, + PATAGONIA_MOUNTAINS_ID = 166, + GRASSLANDS_LAKE_ID = 167, + FROZEN_SPRINGS_POND_ID = 168, + MANGROVE_FOREST_ISLAND_OLD_ID = 169, + BOREAL_FOREST_HILLS_ID = 170, + SAVANNA_PLATEAU_ID = 171, + FIR_CANYON_VALLEY_ID = 172, + FLORAL_PLATEAU_ID = 173, + MAPLE_WOODS_HILLS_ID = 174, + SNOWY_MAPLE_WOODS_HILLS_ID = 175, + ICE_MARSH_POND_ID = 176, + MANGROVE_FOREST_ISLAND_ID = 177, + + //Deco only + OUTBACK_ID = 180, + CHERRY_BLOSSOM_GROVE_ID = 181, + BADLANDS_ID = 182, + BADLANDS_PLATEAU_ID = 183, + SEASONAL_FOREST_ID = 184, + IVORY_HILLS_ID = 185, + HOT_SPRINGS_ID = 186, + VOLCANIC_JUNGLE_ID = 187, + FIR_CANYON_ID = 188, + DARK_FOREST_ID = 189, + MAPLE_WOODS_ID = 190, + SNOWY_MAPLE_WOODS_ID = 191, + + //Rivers + //DESERT_RIVER_ID = 200, + MYSTIC_RIVER_ID = 201, + RAINFOREST_RIVER_ID = 202, + OUTBACK_RIVER_ID = 203, + BADLANDS_RIVER_ID = 204, + TROPICS_RIVER_ID = 205, + ORCHARD_RIVER_ID = 206, + //JUNGLE_RIVER_ID = 207, + WETLANDS_RIVER_ID = 208, + WILLOW_GROVE_RIVER_ID = 209, + PATAGONIA_RIVER_ID = 210, + //RIVER_ID = 211, + //FROZEN_RIVER_ID = 212, + VOLCANIC_RIVER_ID = 213, + MANGROVE_RIVER_ID = 214, + DARK_FOREST_RIVER_BIOME = 215, + + //Edges + FORESTED_HIGHLANDS_EDGE_ID = 229, + ALPINE_EDGE_ID = 230, + //MOUNTAIN_EDGE_ID = 231, + BADLANDS_EDGE_ID = 232, + //ICY_PEAKS_EDGE_ID = 233, + HIGHLANDS_EDGE_OLD_ID = 234, + //JUNGLE_EDGE_ID = 235, + RAINFOREST_EDGE_ID = 236, + TROPICS_EDGE_ID = 237, + HOT_SPRINGS_EDGE_ID = 238, + HIGHLANDS_EDGE_ID = 239, + //Beaches + RED_SAND_BEACH_ID = 240, + //BEACH_ID = 241, + //FROZEN_BEACH_ID = 242, + VOLCANIC_BEACH_ID = 243, + IVORY_BEACH_ID = 244; +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/world/BTABiomeIDs.java b/src/main/java/btw/community/sockthing/sockscrops/world/BTABiomeIDs.java new file mode 100644 index 0000000..832d2e1 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/world/BTABiomeIDs.java @@ -0,0 +1,37 @@ +package btw.community.sockthing.sockscrops.world; + +public class BTABiomeIDs { + //BTA + public static final int + SWAMP_ID = 50, + SWAMP_RIVER_ID = 51, + + NETHER_WASTES_ID = 90, + + WOODS_ID = 100, + DESERT_ID = 101, + JUNGLE_ID = 113, + MOUNTAINS_ID = 125, + TUNDRA_ID = 132, + ICY_PEAKS_ID = 134, + SIBERIA_ID = 137, + PLAINS_ID = 138, + ARID_FOREST_ID = 142, + + WOODS_HILLS_ID = 150, + DESERT_HILLS_ID = 151, + JUNGLE_HILLS_ID = 157, + ICY_PEAKS_FORESTED_ID = 165, + + DESERT_RIVER_ID = 200, + JUNGLE_RIVER_ID = 207, + RIVER_ID = 211, + FROZEN_RIVER_ID = 212, + + MOUNTAIN_EDGE_ID = 231, + ICY_PEAKS_EDGE_ID = 233, + JUNGLE_EDGE_ID = 235, + + BEACH_ID = 241, + FROZEN_BEACH_ID = 242; +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/world/BiomeIDs.java b/src/main/java/btw/community/sockthing/sockscrops/world/BiomeIDs.java index 84a0b6b..615c9af 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/world/BiomeIDs.java +++ b/src/main/java/btw/community/sockthing/sockscrops/world/BiomeIDs.java @@ -18,4 +18,8 @@ public class BiomeIDs { public static final int BEACH_FOREST_ID = 33; public static final int BEACH_TAIGA_ID = 34; public static final int BEACH_JUNGLE_ID = 35; + + + + } diff --git a/src/main/java/btw/community/sockthing/sockscrops/world/WorldDecorator.java b/src/main/java/btw/community/sockthing/sockscrops/world/WorldDecorator.java index 327004e..5fdcd96 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/world/WorldDecorator.java +++ b/src/main/java/btw/community/sockthing/sockscrops/world/WorldDecorator.java @@ -1,7 +1,10 @@ package btw.community.sockthing.sockscrops.world; +import btw.community.sockthing.sockscrops.SocksCropsAddon; import btw.community.sockthing.sockscrops.block.SCBlocks; -import btw.community.sockthing.sockscrops.block.blocks.DoubleTallGrassBlock; +import btw.community.sockthing.sockscrops.block.blocks.DoubleTallFlowerBlock; +import btw.community.sockthing.sockscrops.block.blocks.DoubleTallPlantBlock; +import btw.community.sockthing.sockscrops.world.generators.*; import btw.world.biome.BiomeDecoratorBase; import net.minecraft.src.*; @@ -9,50 +12,420 @@ public class WorldDecorator { - private static final int[] DOUBLE_GRASS_BIOMES = { + public static final int[] CLOVER_BIOMES = { + BiomeGenBase.plains.biomeID, + BiomeGenBase.forest.biomeID, + BiomeGenBase.forestHills.biomeID, + BiomeGenBase.taiga.biomeID, + BiomeGenBase.taigaHills.biomeID, + BiomeGenBase.swampland.biomeID, + BiomeGenBase.icePlains.biomeID, + + BTABiomeIDs.PLAINS_ID, + BTABiomeIDs.WOODS_ID, + BTABiomeIDs.WOODS_HILLS_ID, + BTABiomeIDs.TUNDRA_ID, + BTABiomeIDs.ICY_PEAKS_FORESTED_ID, + BTABiomeIDs.SWAMP_ID, + BTABiomeIDs.SIBERIA_ID, + + BBBiomeIDs.GRASSLANDS_ID, + BBBiomeIDs.FROZEN_SPRINGS_ID, + BBBiomeIDs.ALPINE_ID, + BBBiomeIDs.ALPINE_EDGE_ID, + BBBiomeIDs.CONIFEROUS_FOREST_ID, + BBBiomeIDs.CONIFEROUS_FOREST_CLEARING_ID, + BBBiomeIDs.SNOWY_CONIFEROUS_FOREST_ID, + BBBiomeIDs.SNOWY_CONIFEROUS_FOREST_CLEARING_ID, + BBBiomeIDs.BOREAL_FOREST_ID, + BBBiomeIDs.BOREAL_FOREST_HILLS_ID, + BBBiomeIDs.SHIELD_ID, + BBBiomeIDs.TEMPERATE_FOREST_ID, + BBBiomeIDs.SEASONAL_FOREST_ID, + BBBiomeIDs.SEASONAL_FOREST_HILLS_ID, + BBBiomeIDs.SNOWY_WOODS_ID, + BBBiomeIDs.BIRCH_FOREST_ID, + BBBiomeIDs.BIRCH_FOREST_HILLS_ID, + BBBiomeIDs.CHERRY_BLOSSOM_GROVE_ID, + BBBiomeIDs.CHERRY_BLOSSOM_GROVE_HILLS_ID, + BBBiomeIDs.WILLOW_GROVE_ID, + + }; + + public static final int[] DOUBLE_GRASS_BIOMES = { BiomeIDs.RIVER_PLAINS_ID, BiomeIDs.RIVER_FOREST_ID, BiomeIDs.RIVER_TAIGA_ID, BiomeIDs.RIVER_JUNGLE_ID, + + //Doesn't gen with BTA/BB }; - private static final int[] DOUBLE_FERN_BIOMES = { - BiomeIDs.RIVER_TAIGA_ID, + public static final int[] SUNFLOWER_BIOMES = { + BiomeGenBase.plains.biomeID, + + BTABiomeIDs.PLAINS_ID, + BBBiomeIDs.GRASSLANDS_ID, + BBBiomeIDs.FIELD_ID, + }; + + + + public static final int[] HOLLOW_LOG_OAK_BIOMES = { + BiomeGenBase.forest.biomeID, + BiomeGenBase.forestHills.biomeID, + + BTABiomeIDs.WOODS_ID, + BTABiomeIDs.WOODS_HILLS_ID, + + BBBiomeIDs.SEASONAL_FOREST_ID, + BBBiomeIDs.SEASONAL_FOREST_HILLS_ID, + BBBiomeIDs.SNOWY_WOODS_ID, + BBBiomeIDs.SHIELD_ID, + BBBiomeIDs.MYSTIC_Valley_ID, + BBBiomeIDs.FLORAL_FOREST_ID, + BBBiomeIDs.OLD_GROWTH_WOODLAND_ID, + BBBiomeIDs.OLD_GROWTH_WOODLAND_HILLS_ID, + BBBiomeIDs.ICE_MARSH_ID, + }; + + public static final int[] HOLLOW_LOG_BIRCH_BIOMES = { + BiomeGenBase.forest.biomeID, + BiomeGenBase.forestHills.biomeID, + + BTABiomeIDs.WOODS_ID, + BTABiomeIDs.WOODS_HILLS_ID, + + BBBiomeIDs.BIRCH_FOREST_ID, + BBBiomeIDs.BIRCH_FOREST_HILLS_ID, + BBBiomeIDs.CHERRY_BLOSSOM_GROVE_ID, + BBBiomeIDs.CHERRY_BLOSSOM_GROVE_HILLS_ID, + BBBiomeIDs.SEASONAL_FOREST_ID, + BBBiomeIDs.SEASONAL_FOREST_HILLS_ID, + BBBiomeIDs.SHIELD_ID, + BBBiomeIDs.FROZEN_SPRINGS_ID, + BBBiomeIDs.MYSTIC_Valley_ID, + BBBiomeIDs.FLORAL_FOREST_ID, + BBBiomeIDs.CONIFEROUS_FOREST_ID, + BBBiomeIDs.CONIFEROUS_FOREST_CLEARING_ID, + }; + + public static final int[] HOLLOW_LOG_SPRUCE_BIOMES = { + BiomeGenBase.taiga.biomeID, + BiomeGenBase.taigaHills.biomeID, + + BTABiomeIDs.TUNDRA_ID, + BTABiomeIDs.ICY_PEAKS_FORESTED_ID, + + BBBiomeIDs.SEASONAL_FOREST_ID, + BBBiomeIDs.SEASONAL_FOREST_HILLS_ID, + BBBiomeIDs.BOREAL_FOREST_ID, + BBBiomeIDs.BOREAL_FOREST_HILLS_ID, + BBBiomeIDs.SHIELD_ID, + BBBiomeIDs.FLORAL_FOREST_ID, + BBBiomeIDs.CONIFEROUS_FOREST_ID, + BBBiomeIDs.CONIFEROUS_FOREST_CLEARING_ID, + }; + + public static final int[] HOLLOW_LOG_JUNGLE_BIOMES = { + BiomeGenBase.jungle.biomeID, + BiomeGenBase.jungleHills.biomeID, + + BTABiomeIDs.JUNGLE_ID, + BTABiomeIDs.JUNGLE_HILLS_ID, + BTABiomeIDs.JUNGLE_EDGE_ID, + }; + + public static final int[] HOLLOW_LOG_BTA_BIOMES = { + + BBBiomeIDs.CHERRY_BLOSSOM_GROVE_ID, + BBBiomeIDs.CHERRY_BLOSSOM_GROVE_HILLS_ID, + BBBiomeIDs.SHIELD_ID, + BBBiomeIDs.FROZEN_SPRINGS_ID, + BBBiomeIDs.SNOWY_MAPLE_WOODS_ID, + BBBiomeIDs.SNOWY_MAPLE_WOODS_HILLS_ID, + BBBiomeIDs.CONIFEROUS_FOREST_ID, + BBBiomeIDs.CONIFEROUS_FOREST_CLEARING_ID, + BBBiomeIDs.DARK_FOREST_ID, + + }; + + public static final int[][] HOLLOW_LOG_BIOMES = { + HOLLOW_LOG_OAK_BIOMES, + HOLLOW_LOG_BIRCH_BIOMES, + HOLLOW_LOG_SPRUCE_BIOMES, + HOLLOW_LOG_JUNGLE_BIOMES, + HOLLOW_LOG_BTA_BIOMES + }; + + public static final int[] SIDESHROOM_BIOMES = { + BiomeGenBase.forest.biomeID, + BiomeGenBase.forestHills.biomeID, + BiomeGenBase.taiga.biomeID, + BiomeGenBase.taigaHills.biomeID, + BiomeGenBase.swampland.biomeID, + + BTABiomeIDs.WOODS_ID, + BTABiomeIDs.WOODS_HILLS_ID, + BTABiomeIDs.TUNDRA_ID, + BTABiomeIDs.ICY_PEAKS_FORESTED_ID, + BTABiomeIDs.SWAMP_ID, + + BBBiomeIDs.FUNGAL_FOREST_ID, + BBBiomeIDs.FUNGAL_FOREST_FLAT_ID, + BBBiomeIDs.SEASONAL_FOREST_ID, + BBBiomeIDs.SEASONAL_FOREST_HILLS_ID, + BBBiomeIDs.BOREAL_FOREST_ID, + BBBiomeIDs.BOREAL_FOREST_HILLS_ID, + BBBiomeIDs.SHIELD_ID, + BBBiomeIDs.FLORAL_FOREST_ID, + BBBiomeIDs.CONIFEROUS_FOREST_ID, + BBBiomeIDs.CONIFEROUS_FOREST_CLEARING_ID, + BBBiomeIDs.DARK_FOREST_ID, + BBBiomeIDs.BIRCH_FOREST_ID, + BBBiomeIDs.BIRCH_FOREST_HILLS_ID, + BBBiomeIDs.CHERRY_BLOSSOM_GROVE_ID, + BBBiomeIDs.CHERRY_BLOSSOM_GROVE_HILLS_ID, + }; + + + + public static final int[] SWEET_BERRY_BIOMES = { + BiomeGenBase.taiga.biomeID, + BiomeGenBase.taigaHills.biomeID, + BiomeGenBase.icePlains.biomeID, + + BTABiomeIDs.TUNDRA_ID, + BTABiomeIDs.ICY_PEAKS_FORESTED_ID, + BTABiomeIDs.SIBERIA_ID, + + BBBiomeIDs.FROZEN_SPRINGS_ID, + BBBiomeIDs.ALPINE_ID, + BBBiomeIDs.ALPINE_EDGE_ID, + BBBiomeIDs.CONIFEROUS_FOREST_ID, + BBBiomeIDs.CONIFEROUS_FOREST_CLEARING_ID, + BBBiomeIDs.SNOWY_CONIFEROUS_FOREST_ID, + BBBiomeIDs.SNOWY_CONIFEROUS_FOREST_CLEARING_ID, + BBBiomeIDs.BOREAL_FOREST_ID, + BBBiomeIDs.BOREAL_FOREST_HILLS_ID, + BBBiomeIDs.SHIELD_ID, + BBBiomeIDs.TEMPERATE_FOREST_ID, + }; + + public static final int[] BLUE_BERRY_BIOMES = { + BiomeGenBase.forest.biomeID, + BiomeGenBase.forestHills.biomeID, + + BTABiomeIDs.WOODS_ID, + BTABiomeIDs.WOODS_HILLS_ID, + BTABiomeIDs.ARID_FOREST_ID, + + BBBiomeIDs.BIRCH_FOREST_ID, + BBBiomeIDs.BIRCH_FOREST_HILLS_ID, + BBBiomeIDs.CHERRY_BLOSSOM_GROVE_ID, + BBBiomeIDs.CHERRY_BLOSSOM_GROVE_HILLS_ID, + BBBiomeIDs.SEASONAL_FOREST_ID, + BBBiomeIDs.SEASONAL_FOREST_HILLS_ID, + BBBiomeIDs.SNOWY_WOODS_ID, + BBBiomeIDs.SNOWY_MAPLE_WOODS_ID, + BBBiomeIDs.SNOWY_MAPLE_WOODS_HILLS_ID, + }; + + public static final int[] LILY_BIOMES = { + BiomeGenBase.swampland.biomeID, + BiomeIDs.RIVER_SWAMP_ID, + }; + + public static final int[] WATER_GRASS_BIOMES = { + BiomeGenBase.swampland.biomeID, + BiomeGenBase.jungle.biomeID, + BiomeGenBase.jungleHills.biomeID, + + BiomeIDs.RIVER_SWAMP_ID, BiomeIDs.RIVER_JUNGLE_ID, }; + public static boolean isValidBiome(int biomeID, int[] biomeIDs){ + for (int i = 0; i < biomeIDs.length; i++) { + if (biomeID == biomeIDs[i]) return true; + } + + return false; + } public static void decorateWorld(BiomeDecoratorBase decorator, World world, Random rand, int x, int z, BiomeGenBase biome) { - genTallGrassFern(world, rand, x, z); + + genHollowLog(world, rand, x, z, biome); + if (!SocksCropsAddon.isDecoInstalled()) { + genTallGrassFern(world, rand, x, z, biome); + } + genSunflowers(world, rand, x, z, biome); + genSideShroom(world, rand, x, z, biome); + genClover(world, rand, x, z, biome); + genBerryBush(world, rand, x, z, biome); + + genLilyRose(world, rand, x, z, biome); + genWaterPlants(world, rand, x, z, biome); } - protected static void genTallGrassFern(World world, Random random, int x, int z) { + private static void genWaterPlants(World world, Random random, int x, int z, BiomeGenBase biome) { int i; int xPos; int yPos; int zPos; - // Tall Grass - for (i = 0; i < 16; ++i) { + if (isValidBiome(biome.biomeID, WATER_GRASS_BIOMES) && random.nextFloat() <= 1/4F){ + for (i = 0; i < 4; ++i) { + xPos = x + random.nextInt(16) + 8; + yPos = 62; + zPos = z + random.nextInt(16) + 8; + + new WorldGenWaterPlants(8, SCBlocks.tallWaterPlant, 1, true).generate(world, random, xPos, yPos, zPos); + } + + for (i = 0; i < 4; ++i) { + xPos = x + random.nextInt(16) + 8; + yPos = 62; + zPos = z + random.nextInt(16) + 8; + int type = random.nextInt(2); + new WorldGenWaterPlants(16, SCBlocks.shortWaterPlant, type, false).generate(world, random, xPos, yPos, zPos); + } + } + } + + private static void genLilyRose(World world, Random random, int x, int z, BiomeGenBase biome) { + int i; + int xPos; + int yPos; + int zPos; + + if (isValidBiome(biome.biomeID, LILY_BIOMES) && random.nextFloat() <= 1/8F){ + for (i = 0; i < 4; ++i) { + xPos = x + random.nextInt(16) + 8; + yPos = 62; + zPos = z + random.nextInt(16) + 8; + int type = random.nextInt(2); + new WorldGenWaterPlants(5, SCBlocks.flowerLily, type, false).generate(world, random, xPos, yPos, zPos); + } + } + } + + + private static void genClover(World world, Random random, int x, int z, BiomeGenBase biome) { + int i; + int xPos; + int yPos; + int zPos; + + //Clover + for (i = 0; i < 12; ++i) + { xPos = x + random.nextInt(16) + 8; - yPos = random.nextInt(128); + yPos = 60 + random.nextInt(64); zPos = z + random.nextInt(16) + 8; - WorldGenerator var6 = new DoubleGrassWorldGen(16, SCBlocks.doubleTallGrass.blockID, - DoubleTallGrassBlock.GRASS, DOUBLE_GRASS_BIOMES); - var6.generate(world, random, xPos, yPos, zPos); + + if (isValidBiome(biome.biomeID, CLOVER_BIOMES)){ + float flowerChance = 0.25F; + if (biome.biomeID == BiomeGenBase.plains.biomeID) flowerChance = 0F; + + WorldGenerator gen = new CloverWorldGen(48, SCBlocks.clover.blockID, 0, flowerChance); + gen.generate(world, random, xPos, yPos, zPos); + } + } + } + + private static void genSideShroom(World world, Random random, int x, int z,BiomeGenBase biome) { + int i; + int xPos; + int yPos; + int zPos; + + if (isValidBiome(biome.biomeID, SIDESHROOM_BIOMES)){ + for (i = 0; i < 64; ++i) { + xPos = x + random.nextInt(16) + 8; + yPos = 60 + random.nextInt(64); + zPos = z + random.nextInt(16) + 8; + + new SideShroomWorldGen().generate(world, random, xPos, yPos, zPos); + } } + } + + private static void genHollowLog(World world, Random random, int x, int z, BiomeGenBase biome) { - // Tall Fern + for (int i = 0; i < HOLLOW_LOG_BIOMES.length; i++) { + int xPos = x + random.nextInt(16) + 8; + int zPos = z + random.nextInt(16) + 8; + int yPos = world.getHeightValue(xPos, zPos) + 1; + + WorldGenerator generator = new HollowLogWorldGen(biome, HOLLOW_LOG_BIOMES[i]); + generator.generate(world, random, xPos, yPos, zPos); + } + } + + private static void genTallGrassFern(World world, Random random, int x, int z, BiomeGenBase biome) { + int i; + int xPos; + int yPos; + int zPos; + + // Tall Grass for (i = 0; i < 16; ++i) { xPos = x + random.nextInt(16) + 8; - yPos = random.nextInt(128); + yPos = 60 + random.nextInt(64); zPos = z + random.nextInt(16) + 8; - WorldGenerator var6 = new DoubleGrassWorldGen(8, SCBlocks.doubleTallGrass.blockID, - DoubleTallGrassBlock.FERN, DOUBLE_FERN_BIOMES); + WorldGenerator var6 = new DoubleGrassWorldGen(16, SCBlocks.doubleTallPlant.blockID, + DoubleTallPlantBlock.GRASS, DOUBLE_GRASS_BIOMES, 0.25F); var6.generate(world, random, xPos, yPos, zPos); } } + private static void genSunflowers(World world, Random random, int x, int z, BiomeGenBase biome) { + int i; + int xPos; + int yPos; + int zPos; + + //Sunflowers + if (random.nextInt(3 * 128) == 0) { + for (i = 0; i < 16; ++i) { + xPos = x + random.nextInt(16) + 8; + yPos = 60 + random.nextInt(64); + zPos = z + random.nextInt(16) + 8; + WorldGenerator var6 = new DoubleGrassWorldGen(16, SCBlocks.tallFlower.blockID, + DoubleTallFlowerBlock.SUNFLOWER, SUNFLOWER_BIOMES, 0.0F); + var6.generate(world, random, xPos, yPos, zPos); + } + } + + } + + protected static void genBerryBush(World world, Random random, int x, int z, BiomeGenBase biome) { + int i; + int xPos; + int yPos; + int zPos; + + if (isValidBiome(biome.biomeID, BLUE_BERRY_BIOMES)){ + for (i = 0; i < 4; ++i) { + xPos = x + random.nextInt(16) + 8; + yPos = 60 + random.nextInt(64); + zPos = z + random.nextInt(16) + 8; + new BerryBushWorldGen(SCBlocks.blueberryBush).generate(world, random, xPos, yPos, zPos); + } + } + else if (isValidBiome(biome.biomeID, SWEET_BERRY_BIOMES)){ + int count = 4; + if (biome.biomeID == BiomeGenBase.icePlains.biomeID || biome.biomeID == BTABiomeIDs.SIBERIA_ID) count = 1; + for (i = 0; i < count; ++i) { + xPos = x + random.nextInt(16) + 8; + yPos = 60 + random.nextInt(64); + zPos = z + random.nextInt(16) + 8; + new BerryBushWorldGen(SCBlocks.sweetberryBush).generate(world, random, xPos, yPos, zPos); + } + } + } + public static void debugRivers(World world, int x, int z) { int i; diff --git a/src/main/java/btw/community/sockthing/sockscrops/world/generators/BerryBushWorldGen.java b/src/main/java/btw/community/sockthing/sockscrops/world/generators/BerryBushWorldGen.java new file mode 100644 index 0000000..72ea717 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/world/generators/BerryBushWorldGen.java @@ -0,0 +1,43 @@ +package btw.community.sockthing.sockscrops.world.generators; + +import btw.community.sockthing.sockscrops.block.SCBlocks; +import net.minecraft.src.BiomeGenBase; +import net.minecraft.src.Block; +import net.minecraft.src.World; + +import java.util.ArrayList; +import java.util.Random; + +public class BerryBushWorldGen { + + /** The ID of the plant block used in this plant generator. */ + private Block plantBlock; + + public BerryBushWorldGen(Block berryBush) + { + this.plantBlock = berryBush; + } + + public boolean generate(World par1World, Random rand, int x, int y, int z) + { + for (int var6 = 0; var6 < 6; ++var6) + { + if (rand.nextInt(3) == 0) continue; + + int plantX = x + rand.nextInt(4) - rand.nextInt(4); + int plantY = y; + int plantZ = z + rand.nextInt(4) - rand.nextInt(4); + + if (par1World.isAirBlock(plantX, plantY, plantZ)) + { + int randomGrowthStage = 2 + rand.nextInt(4); // 2, 3, 4 or 5 + + if (this.plantBlock.canBlockStay(par1World, plantX, plantY, plantZ)) { + par1World.setBlock(plantX, plantY, plantZ, this.plantBlock.blockID, randomGrowthStage, 2); + } + } + } + + return true; + } +} \ No newline at end of file diff --git a/src/main/java/btw/community/sockthing/sockscrops/world/generators/CloverWorldGen.java b/src/main/java/btw/community/sockthing/sockscrops/world/generators/CloverWorldGen.java new file mode 100644 index 0000000..582e054 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/world/generators/CloverWorldGen.java @@ -0,0 +1,65 @@ +package btw.community.sockthing.sockscrops.world.generators; + +import btw.community.sockthing.sockscrops.world.BBBiomeIDs; +import btw.community.sockthing.sockscrops.world.BTABiomeIDs; +import net.minecraft.src.BiomeGenBase; +import net.minecraft.src.Block; +import net.minecraft.src.World; +import net.minecraft.src.WorldGenerator; + +import java.util.Random; + +public class CloverWorldGen extends WorldGenerator +{ + private final float flowerChance; + private final int tries; + /** The ID of the plant block used in this plant generator. */ + private int blockID; + private int metadata; + + public CloverWorldGen(int tries, int blockID, int metadata, float flowerChance) + { + this.blockID = blockID; + this.metadata = metadata; + this.flowerChance = flowerChance; + this.tries = tries; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + int flowerColor = par2Random.nextInt(3) + 1; + + for (int var6 = 0; var6 < this.tries; ++var6) + { + int var7 = par3 + par2Random.nextInt(6) - par2Random.nextInt(6); + int var8 = par4 + par2Random.nextInt(2) - par2Random.nextInt(2); + int var9 = par5 + par2Random.nextInt(6) - par2Random.nextInt(6); + + int amount = par2Random.nextInt(4) * 4; + int dir = par2Random.nextInt(4); + + if (par1World.isAirBlock(var7, var8, var9) && Block.blocksList[this.blockID].canBlockStay(par1World, var7, var8, var9)) + { + if (isSwamp(par1World.getBiomeGenForCoords(par3, par5).biomeID) ){ + flowerColor = 1; + } + + if (par2Random.nextFloat() < flowerChance){ + amount = Math.max(amount, 4); + par1World.setBlock(var7, var8, var9, this.blockID + flowerColor, dir + amount, 2); + } + else par1World.setBlock(var7, var8, var9, this.blockID, dir + amount, 2); + } + } + + return true; + } + + private boolean isSwamp(int biomeID) { + if (biomeID == BiomeGenBase.swampland.biomeID) return true; + if (biomeID == BTABiomeIDs.SWAMP_ID) return true; + if (biomeID == BBBiomeIDs.WILLOW_GROVE_ID) return true; + + return false; + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/world/DoubleGrassWorldGen.java b/src/main/java/btw/community/sockthing/sockscrops/world/generators/DoubleGrassWorldGen.java similarity index 75% rename from src/main/java/btw/community/sockthing/sockscrops/world/DoubleGrassWorldGen.java rename to src/main/java/btw/community/sockthing/sockscrops/world/generators/DoubleGrassWorldGen.java index 8456be1..8544e01 100644 --- a/src/main/java/btw/community/sockthing/sockscrops/world/DoubleGrassWorldGen.java +++ b/src/main/java/btw/community/sockthing/sockscrops/world/generators/DoubleGrassWorldGen.java @@ -1,5 +1,6 @@ -package btw.community.sockthing.sockscrops.world; +package btw.community.sockthing.sockscrops.world.generators; +import btw.community.sockthing.sockscrops.block.blocks.DoubleTallPlantBlock; import net.minecraft.src.BiomeGenBase; import net.minecraft.src.Block; import net.minecraft.src.World; @@ -11,16 +12,18 @@ public class DoubleGrassWorldGen extends WorldGenerator { /** * Stores ID for WorldGenTallGrass */ - private final int tallGrassID; - private final int tallGrassMetadata; + private int tallGrassID; + private int tallGrassMetadata; private final int times; private static int[] biomes; + private final float fernChance; - public DoubleGrassWorldGen(int times, int id, int meta, int[] biomes) { + public DoubleGrassWorldGen(int times, int id, int meta, int[] biomes, float fernChance) { this.tallGrassID = id; this.tallGrassMetadata = meta; this.times = times; + this.fernChance = fernChance; DoubleGrassWorldGen.biomes = biomes; } @@ -55,12 +58,13 @@ public boolean generate(World par1World, Random par2Random, int par3, int par4, continue; } - if (var9 < 50 || var9 > 70) { - continue; - } - - if (par1World.isAirBlock(var8, var9, var10) && par1World.isAirBlock(var8, var9 + 1, var10) + if ((par1World.getBlockId(var8, var9, var10) == Block.snow.blockID && par1World.isAirBlock(var8, var9+1, var10)) || par1World.getBlockId(var8, var9 - 1, var10) != this.tallGrassID && par1World.isAirBlock(var8, var9, var10) && par1World.isAirBlock(var8, var9 + 1, var10) && Block.blocksList[this.tallGrassID].canBlockStay(par1World, var8, var9, var10)) { + + if (par2Random.nextFloat() < this.fernChance){ + this.tallGrassMetadata = DoubleTallPlantBlock.FERN; + } + par1World.setBlock(var8, var9, var10, this.tallGrassID, this.tallGrassMetadata, 2); par1World.setBlock(var8, var9 + 1, var10, this.tallGrassID, this.tallGrassMetadata + 8, 2); diff --git a/src/main/java/btw/community/sockthing/sockscrops/world/generators/GrassWorldGen.java b/src/main/java/btw/community/sockthing/sockscrops/world/generators/GrassWorldGen.java new file mode 100644 index 0000000..548b350 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/world/generators/GrassWorldGen.java @@ -0,0 +1,54 @@ +package btw.community.sockthing.sockscrops.world.generators; + +import net.minecraft.src.Block; +import net.minecraft.src.World; +import net.minecraft.src.WorldGenerator; + +import java.util.Random; + +public class GrassWorldGen extends WorldGenerator { + /** Stores ID for WorldGenTallGrass */ + private int tallGrassID; + private int tallGrassMetadata; + private int[][] blocks; + + public GrassWorldGen(int blockID, int metadata, int[][] blocks) + { + this.tallGrassID = blockID; + this.tallGrassMetadata = metadata; + this.blocks = blocks; + } + + public GrassWorldGen(int[][] blocks) + { + this.blocks = blocks; + } + + public boolean generate(World world, Random rand, int x, int y, int z) + { + int var11; + + for (boolean var6 = false; ((var11 = world.getBlockId(x, y, z)) == 0 || var11 == Block.leaves.blockID) && y > 0; --y) + { + ; + } + + for (int var7 = 0; var7 < 128; ++var7) + { + int xPos = x + rand.nextInt(8) - rand.nextInt(8); + int yPos = y + rand.nextInt(4) - rand.nextInt(4); + int zPos = z + rand.nextInt(8) - rand.nextInt(8); + + if (world.isAirBlock(xPos, yPos, zPos) && Block.blocksList[this.blocks[0][0]].canBlockStay(world, xPos, yPos, zPos)) + { + if (rand.nextInt(4) == 0) + { + world.setBlock(xPos, yPos, zPos, this.blocks[1][0], this.blocks[1][1], 2); + } + else world.setBlock(xPos, yPos, zPos, this.blocks[0][0], this.blocks[0][1], 2); + } + } + + return true; + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/world/generators/HollowLogWorldGen.java b/src/main/java/btw/community/sockthing/sockscrops/world/generators/HollowLogWorldGen.java new file mode 100644 index 0000000..2660dda --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/world/generators/HollowLogWorldGen.java @@ -0,0 +1,230 @@ +package btw.community.sockthing.sockscrops.world.generators; + +import btw.community.sockthing.sockscrops.block.SCBlocks; +import btw.community.sockthing.sockscrops.world.BBBiomeIDs; +import btw.community.sockthing.sockscrops.world.WorldDecorator; +import net.minecraft.src.BiomeGenBase; +import net.minecraft.src.Block; +import net.minecraft.src.World; +import net.minecraft.src.WorldGenerator; + +import java.util.Arrays; +import java.util.Random; + +public class HollowLogWorldGen extends WorldGenerator { + + private BiomeGenBase biome; + private int[] validBiomes; + + public HollowLogWorldGen(BiomeGenBase biome, int[] validBiomes) + { + this.biome = biome; + this.validBiomes = validBiomes; + } + + public boolean generate(World world, Random rand, int x, int y, int z) + { + if (!world.checkChunksExist(x - 16, y - 16, z - 16, x + 16, y + 16, z + 16)) { + //Maybe prevents erros of already decorating + return false; + } + + int numberPlaced = 0; + + for (int i = 0; i < 8; ++i) { + + //System.out.println("Trying to place fallen logs..."); + int xPos = x + rand.nextInt(8) - rand.nextInt(8); + int yPos = y + rand.nextInt(4) - rand.nextInt(4); + int zPos = z + rand.nextInt(8) - rand.nextInt(8); + + int dir = rand.nextInt(2); + + boolean shouldTryPlacing = true; + + for (int tempX = -1; tempX <= 1 && shouldTryPlacing; tempX++) { + for (int tempZ = -1; tempZ <= 1; tempZ++) { + if (!hasSpace(world, xPos + tempX, yPos, zPos + tempZ)) { + shouldTryPlacing = false; + break; + } + } + } + + if (!shouldTryPlacing) { + //System.out.println("gen failed: not enough space"); + shouldTryPlacing = true; + continue; + }; + + if (world.getBlockId(xPos, yPos - 1, zPos) == Block.grass.blockID + || world.getBlockId(xPos, yPos - 1, zPos) == Block.dirt.blockID ) + { + int mushroomType = rand.nextInt(4) * 4; + int treeID = SCBlocks.hollowLog.blockID; + int treeType = 0; + + if (Arrays.equals(validBiomes, WorldDecorator.HOLLOW_LOG_OAK_BIOMES) && WorldDecorator.isValidBiome(biome.biomeID, WorldDecorator.HOLLOW_LOG_OAK_BIOMES)) + { + treeType = 0; + } + else if (Arrays.equals(validBiomes, WorldDecorator.HOLLOW_LOG_SPRUCE_BIOMES) && WorldDecorator.isValidBiome(biome.biomeID, WorldDecorator.HOLLOW_LOG_SPRUCE_BIOMES)) + { + treeType = 1; + } + else if (Arrays.equals(validBiomes, WorldDecorator.HOLLOW_LOG_BIRCH_BIOMES) && WorldDecorator.isValidBiome(biome.biomeID, WorldDecorator.HOLLOW_LOG_BIRCH_BIOMES)) + { + treeType = 2; + } + else if (Arrays.equals(validBiomes, WorldDecorator.HOLLOW_LOG_JUNGLE_BIOMES) && WorldDecorator.isValidBiome(biome.biomeID, WorldDecorator.HOLLOW_LOG_JUNGLE_BIOMES)) + { + treeType = 3; + } + else { + if (Arrays.equals(validBiomes, WorldDecorator.HOLLOW_LOG_BTA_BIOMES) && WorldDecorator.isValidBiome(biome.biomeID, WorldDecorator.HOLLOW_LOG_BTA_BIOMES)){ + if (biome.biomeID == BBBiomeIDs.CHERRY_BLOSSOM_GROVE_ID || biome.biomeID == BBBiomeIDs.CHERRY_BLOSSOM_GROVE_HILLS_ID){ + //Cherry + treeID = SCBlocks.decoHollowLog3.blockID; + treeType = 0; + } + else if (biome.biomeID == BBBiomeIDs.SEASONAL_FOREST_ID || biome.biomeID == BBBiomeIDs.SEASONAL_FOREST_HILLS_ID){ + //Dark Oak + treeID = SCBlocks.decoHollowLog.blockID; + treeType = 0; + } + else if (biome.biomeID == BBBiomeIDs.SHIELD_ID){ + if (rand.nextInt(3) == 0){ + //Dark Oak + treeID = SCBlocks.decoHollowLog.blockID; + treeType = 0; + } + else { + //Fir & Aspen + treeID = SCBlocks.decoHollowLog2.blockID; + treeType = rand.nextInt(2) + 1; + } + } + else if (biome.biomeID == BBBiomeIDs.FROZEN_SPRINGS_ID){ + if (rand.nextInt(2) == 0){ + //Birch + treeID = SCBlocks.hollowLog.blockID; + treeType = 2; + } + else { + //Cherry + treeID = SCBlocks.decoHollowLog3.blockID; + treeType = 0; + } + } + else if (biome.biomeID == BBBiomeIDs.SNOWY_MAPLE_WOODS_ID + || biome.biomeID == BBBiomeIDs.SNOWY_MAPLE_WOODS_HILLS_ID){ + //Dark Oak + treeID = SCBlocks.decoHollowLog.blockID; + treeType = 0; + } + else if (biome.biomeID == BBBiomeIDs.CONIFEROUS_FOREST_ID + || biome.biomeID == BBBiomeIDs.CONIFEROUS_FOREST_CLEARING_ID){ + //Fir + treeID = SCBlocks.decoHollowLog2.blockID; + treeType = 1; + } + else if (biome.biomeID == BBBiomeIDs.MYSTIC_Valley_ID){ + //Cherry + treeID = SCBlocks.decoHollowLog3.blockID; + treeType = 0; + } + else if (biome.biomeID == BBBiomeIDs.DARK_FOREST_ID){ + //Dark Oak + treeID = SCBlocks.decoHollowLog.blockID; + treeType = 0; + } + } + else return false; + } + + if (dir == 0) + { + if (placeBlock(world, xPos - 1, yPos, zPos, treeID, 4 + treeType)){ + placeMossCarpet(world, xPos - 1, yPos + 1, zPos, rand); + if (rand.nextInt(2) == 0) placeBlock(world, xPos - 1, yPos, zPos - 1, SCBlocks.sideShroom.blockID, 0 + mushroomType); + if (rand.nextInt(2) == 0) placeBlock(world, xPos - 1, yPos, zPos + 1, SCBlocks.sideShroom.blockID, 2 + mushroomType); + } + + if (placeBlock(world, xPos, yPos, zPos, treeID, 4 + treeType)){ + placeMossCarpet(world, xPos, yPos + 1, zPos, rand); + if (rand.nextInt(2) == 0) placeBlock(world, xPos, yPos, zPos - 1, SCBlocks.sideShroom.blockID, 0 + mushroomType); + if (rand.nextInt(2) == 0) placeBlock(world, xPos, yPos, zPos + 1, SCBlocks.sideShroom.blockID, 2 + mushroomType); + } + + if (placeBlock(world, xPos + 1, yPos, zPos, treeID, 4 + treeType)){ + placeMossCarpet(world, xPos + 1, yPos + 1, zPos, rand); + if (rand.nextInt(2) == 0) placeBlock(world, xPos + 1, yPos, zPos - 1, SCBlocks.sideShroom.blockID, 0 + mushroomType); + if (rand.nextInt(2) == 0) placeBlock(world, xPos + 1, yPos, zPos + 1, SCBlocks.sideShroom.blockID, 2 + mushroomType); + } + } + else { + if (placeBlock(world, xPos, yPos, zPos - 1, treeID, 8 + treeType)){ + placeMossCarpet(world, xPos, yPos + 1, zPos - 1, rand); + if (rand.nextInt(2) == 0) placeBlock(world, xPos - 1, yPos, zPos - 1, SCBlocks.sideShroom.blockID, 3 + mushroomType); + if (rand.nextInt(2) == 0) placeBlock(world, xPos + 1, yPos, zPos - 1, SCBlocks.sideShroom.blockID, 1 + mushroomType); + } + + if (placeBlock(world, xPos, yPos, zPos, treeID, 8 + treeType)){ + placeMossCarpet(world, xPos, yPos + 1, zPos, rand); + if (rand.nextInt(2) == 0) placeBlock(world, xPos - 1, yPos, zPos, SCBlocks.sideShroom.blockID, 3 + mushroomType); + if (rand.nextInt(2) == 0) placeBlock(world, xPos + 1, yPos, zPos, SCBlocks.sideShroom.blockID, 1 + mushroomType); + } + + if (placeBlock(world, xPos, yPos, zPos + 1, treeID, 8 + treeType)){ + placeMossCarpet(world, xPos, yPos + 1, zPos + 1, rand); + if (rand.nextInt(2) == 0) placeBlock(world, xPos - 1, yPos, zPos + 1, SCBlocks.sideShroom.blockID, 3 + mushroomType); + if (rand.nextInt(2) == 0) placeBlock(world, xPos + 1, yPos, zPos + 1, SCBlocks.sideShroom.blockID, 1 + mushroomType); + } + } + + //gen clover around + WorldGenerator genClover = new CloverWorldGen(64, SCBlocks.clover.blockID, 0, 0F); + genClover.generate(world, rand, xPos, yPos, zPos); + + } + else { + //System.out.println("gen failed: block below isn't grass"); + } + + numberPlaced++; + if (numberPlaced > 1) return false; + //System.out.println("gen success: " + numberPlaced); + } + + //System.out.println("fallen logs gen - done"); + + return true; + + } + + private void placeMossCarpet(World world, int xPos, int yPos, int zPos, Random rand) { + if (rand.nextFloat() <= 0.25F){ + placeBlock(world, xPos, yPos, zPos, SCBlocks.clover.blockID + rand.nextInt(4), rand.nextInt(16)); + placeBlock(world, xPos, yPos + 1, zPos, SCBlocks.mossCarpet.blockID, 0); + } + else placeBlock(world, xPos, yPos, zPos, SCBlocks.mossCarpet.blockID, 0); + } + + private boolean hasSpace(World world, int xPos, int yPos, int zPos) { + return world.getBlockId(xPos,yPos,zPos) == Block.snow.blockID + || world.isAirBlock(xPos,yPos,zPos) + || (Block.blocksList[world.getBlockId(xPos, yPos, zPos)].isReplaceableVegetation(world, xPos, yPos, zPos) + ); + } + + private boolean placeBlock(World world, int xPos, int yPos, int zPos, int blockToPlaceID, int blockToPlaceMeta) { + if (hasSpace(world, xPos, yPos, zPos)) + { + world.setBlock(xPos, yPos, zPos, blockToPlaceID, blockToPlaceMeta, 2); + return true; + } + + return false; + + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/world/generators/SideShroomWorldGen.java b/src/main/java/btw/community/sockthing/sockscrops/world/generators/SideShroomWorldGen.java new file mode 100644 index 0000000..be6d330 --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/world/generators/SideShroomWorldGen.java @@ -0,0 +1,83 @@ +package btw.community.sockthing.sockscrops.world.generators; + +import btw.community.sockthing.sockscrops.block.SCBlocks; +import net.minecraft.src.BiomeGenBase; +import net.minecraft.src.Block; +import net.minecraft.src.World; +import net.minecraft.src.WorldGenerator; + +import java.util.Random; + +public class SideShroomWorldGen extends WorldGenerator +{ + + public SideShroomWorldGen() + { + + } + + public boolean generate(World world, Random rand, int x, int y, int z) + { + + BiomeGenBase currentBiome = world.getBiomeGenForCoords( x, z ); + + for (int i = 0; i < 8; ++i) + { + + int xPos = x; // + rand.nextInt(4) - rand.nextInt(4); + int yPos = y + rand.nextInt(4) - rand.nextInt(4); + int zPos = z; // + rand.nextInt(4) - rand.nextInt(4); + + int randDir = rand.nextInt(4); + int randType = rand.nextInt(2); + + if (world.getBlockId(xPos, yPos, zPos) == Block.wood.blockID) + { + + int type = 0; + int meta = world.getBlockMetadata(xPos, yPos, zPos); + int woodType = meta & 3; + boolean isStump = (meta & 12) == 12; + + if (woodType > 2 || isStump) continue; + + if ( woodType == 0 || woodType == 2) { // oak or birch + if (randType == 0) + type = 0; + else + type = 4; + } + else //if (woodType == 1) Spruce + { + if (randType == 0) + type = 8; + else + type = 12; + } + + if ( randDir == 0 && world.getBlockId(xPos, yPos, zPos - 1) == 0) + { + world.setBlockAndMetadata(xPos, yPos, zPos - 1, SCBlocks.sideShroom.blockID, 0 + type); + //System.out.println("Success at: x = " + xPos + " y = " + yPos + " z = " + zPos); + } + else if ( randDir == 2 && world.getBlockId(xPos, yPos, zPos + 1) == 0) + { + world.setBlockAndMetadata(xPos, yPos, zPos + 1, SCBlocks.sideShroom.blockID, 2 + type); + //System.out.println("Success at: x = " + xPos + " y = " + yPos + " z = " + zPos); + } + else if ( randDir == 1 && world.getBlockId(xPos + 1, yPos, zPos) == 0) + { + world.setBlockAndMetadata(xPos + 1,yPos, zPos, SCBlocks.sideShroom.blockID, 1 + type); + //System.out.println("Success at: x = " + xPos + " y = " + yPos + " z = " + zPos); + } + else if ( randDir == 3 && world.getBlockId(xPos - 1, yPos, zPos) == 0) + { + world.setBlockAndMetadata(xPos - 1,yPos, zPos, SCBlocks.sideShroom.blockID, 3 + type); + //System.out.println("Success at: x = " + xPos + " y = " + yPos + " z = " + zPos); + } + } + } + + return true; + } +} diff --git a/src/main/java/btw/community/sockthing/sockscrops/world/generators/WorldGenWaterPlants.java b/src/main/java/btw/community/sockthing/sockscrops/world/generators/WorldGenWaterPlants.java new file mode 100644 index 0000000..c20d65c --- /dev/null +++ b/src/main/java/btw/community/sockthing/sockscrops/world/generators/WorldGenWaterPlants.java @@ -0,0 +1,45 @@ +package btw.community.sockthing.sockscrops.world.generators; + +import net.minecraft.src.Block; +import net.minecraft.src.World; +import net.minecraft.src.WorldGenWaterlily; +import net.minecraft.src.WorldGenerator; + +import java.util.Random; + +public class WorldGenWaterPlants extends WorldGenerator +{ + private final Block plantBlock; + private final int plantBlockMeta; + private final boolean isDoubleTall; + private final int count; + + public WorldGenWaterPlants(int count, Block plantBlock, int plantBlockMeta, boolean isDoubleTall){ + this.plantBlock = plantBlock; + this.plantBlockMeta = plantBlockMeta; + this.isDoubleTall = isDoubleTall; + this.count = count; + } + + public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) + { + for (int var6 = 0; var6 < count; ++var6) + { + int var7 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8); + int var8 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4); + int var9 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8); + + if (par1World.isAirBlock(var7, var8, var9) && plantBlock.canPlaceBlockAt(par1World, var7, var8, var9)) + { + par1World.setBlock(var7, var8, var9, plantBlock.blockID, plantBlockMeta, 2); + + if (this.isDoubleTall) + { + par1World.setBlock(var7, var8 + 1, var9, plantBlock.blockID, plantBlockMeta + 8, 2); + } + } + } + + return true; + } +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 7c78ce0..e2fb560 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "id": "sockscrops", "version": "${version}", - "name": "Sock's Crops Addon", + "name": "Sock's Crops", "description": "This BTW Add-on features plenty of new crops and foods!", "authors": [ "Sockthing" diff --git a/src/main/resources/lang/SC_en_US.lang b/src/main/resources/lang/SC_en_US.lang index d3d341c..a8c9dea 100644 --- a/src/main/resources/lang/SC_en_US.lang +++ b/src/main/resources/lang/SC_en_US.lang @@ -1,12 +1,12 @@ ### Blocks ### # Grass -tile.scBlockGrassNutrition.grass_reduced.name=Reduced Nutrition Grass Block -tile.scBlockGrassNutrition.grass_low.name=Low Nutrition Grass Block -tile.scBlockGrassNutrition.grass_depleted.name=Depleted Nutrition Grass Block +tile.grassNutrition.grass_reduced.name=Reduced Nutrition Grass Block +tile.grassNutrition.grass_low.name=Low Nutrition Grass Block +tile.grassNutrition.grass_depleted.name=Depleted Nutrition Grass Block -tile.scBlockGrassNutrition.grass_sparse_reduced.name=Sparse Reduced Nutrition Grass Block -tile.scBlockGrassNutrition.grass_sparse_low.name=Sparse Low Nutrition Grass Block -tile.scBlockGrassNutrition.grass_sparse_depleted.name=Sparse Depleted Nutrition Grass Block +tile.grassNutrition.grass_sparse_reduced.name=Sparse Reduced Nutrition Grass Block +tile.grassNutrition.grass_sparse_low.name=Sparse Low Nutrition Grass Block +tile.grassNutrition.grass_sparse_depleted.name=Sparse Depleted Nutrition Grass Block # Dirt tile.dirt.dirt.name=Dirt @@ -23,63 +23,121 @@ tile.fcBlockDirtLoose.dirt_loose_depleted.name=Depleted Nutrition Loose Dirt # Farmland tile.fcBlockFarmlandNew.name=Old Farmland -tile.scBlockFarmlandNutrition_full.name=Farmland -tile.scBlockFarmlandNutrition_reduced.name=Farmland with Reduced Nutrition -tile.scBlockFarmlandNutrition_low.name=Farmland with Low Nutrition -tile.scBlockFarmlandNutrition_depleted.name=Farmland with Depleted Nutrition +tile.farmlandNutrition_full.name=Farmland +tile.farmlandNutrition_reduced.name=Farmland with Reduced Nutrition +tile.farmlandNutrition_low.name=Farmland with Low Nutrition +tile.farmlandNutrition_depleted.name=Farmland with Depleted Nutrition -tile.scBlockFarmlandFertilizedNutrition_full.name=Fertilized Farmland -tile.scBlockFarmlandFertilizedNutrition_reduced.name=Fertilized Farmland with Reduced Nutrition -tile.scBlockFarmlandFertilizedNutrition_low.name=Fertilized Farmland with Low Nutrition -tile.scBlockFarmlandFertilizedNutrition_depleted.name=Fertilized Farmland with Depleted Nutrition +tile.farmlandFertilizedNutrition_full.name=Fertilized Farmland +tile.farmlandFertilizedNutrition_reduced.name=Fertilized Farmland with Reduced Nutrition +tile.farmlandFertilizedNutrition_low.name=Fertilized Farmland with Low Nutrition +tile.farmlandFertilizedNutrition_depleted.name=Fertilized Farmland with Depleted Nutrition -tile.scBlockFarmlandDungedNutrition_full.name=Manured Farmland -tile.scBlockFarmlandDungedNutrition_reduced.name=Manured Farmland with Reduced Nutrition -tile.scBlockFarmlandDungedNutrition_low.name=Manured Farmland with Low Nutrition -tile.scBlockFarmlandDungedNutrition_depleted.name=Manured Farmland with Depleted Nutrition +tile.farmlandDungNutrition_full.name=Manured Farmland +tile.farmlandDungNutrition_reduced.name=Manured Farmland with Reduced Nutrition +tile.farmlandDungNutrition_low.name=Manured Farmland with Low Nutrition +tile.farmlandDungNutrition_depleted.name=Manured Farmland with Depleted Nutrition -tile.scBlockFarmlandMulchNutrition_full.name=Mulched Farmland -tile.scBlockFarmlandMulchNutrition_reduced.name=Mulched Farmland with Reduced Nutrition -tile.scBlockFarmlandMulchNutrition_low.name=Mulched Farmland with Low Nutrition -tile.scBlockFarmlandMulchNutrition_depleted.name=Mulched Farmland with Depleted Nutrition +tile.farmlandMulchNutrition_full.name=Mulched Farmland +tile.farmlandMulchNutrition_reduced.name=Mulched Farmland with Reduced Nutrition +tile.farmlandMulchNutrition_low.name=Mulched Farmland with Low Nutrition +tile.farmlandMulchNutrition_depleted.name=Mulched Farmland with Depleted Nutrition # Planter tile.fcBlockPlanterSoil.name=Old Planter With Soil -tile.scBlockPlanter_grass.full.name=Grass Planter -tile.scBlockPlanter_grass.reduced.name=Grass Planter with Reduced Nutrition -tile.scBlockPlanter_grass.low.name=Grass Planter with Low Nutrition -tile.scBlockPlanter_grass.depleted.name=Grass Planter with Depleted Nutrition +tile.planter_grass.full.name=Grass Planter +tile.planter_grass.reduced.name=Grass Planter with Reduced Nutrition +tile.planter_grass.low.name=Grass Planter with Low Nutrition +tile.planter_grass.depleted.name=Grass Planter with Depleted Nutrition -tile.scBlockPlanter_grass.sparse_full.name=Sparse Grass Planter -tile.scBlockPlanter_grass.sparse_reduced.name=Sparse Grass Planter with Reduced Nutrition -tile.scBlockPlanter_grass.sparse_low.name=Sparse Grass Planter with Low Nutrition -tile.scBlockPlanter_grass.sparse_depleted.name=Sparse Grass Planter with Depleted Nutrition +tile.planter_grass.sparse_full.name=Sparse Grass Planter +tile.planter_grass.sparse_reduced.name=Sparse Grass Planter with Reduced Nutrition +tile.planter_grass.sparse_low.name=Sparse Grass Planter with Low Nutrition +tile.planter_grass.sparse_depleted.name=Sparse Grass Planter with Depleted Nutrition -tile.scBlockPlanter_farmland.full.name=Farmland Planter -tile.scBlockPlanter_farmland.reduced.name=Farmland Planter with Reduced Nutrition -tile.scBlockPlanter_farmland.low.name=Farmland Planter with Low Nutrition -tile.scBlockPlanter_farmland.depleted.name=Farmland Planter with Depleted Nutrition +tile.planter_farmland.full.name=Farmland Planter +tile.planter_farmland.reduced.name=Farmland Planter with Reduced Nutrition +tile.planter_farmland.low.name=Farmland Planter with Low Nutrition +tile.planter_farmland.depleted.name=Farmland Planter with Depleted Nutrition -tile.scBlockPlanter_farmland_fertilized.full.name=Fertilized Farmland Planter -tile.scBlockPlanter_farmland_fertilized.reduced.name=Fertilized Farmland Planter with Reduced Nutrition -tile.scBlockPlanter_farmland_fertilized.low.name=Fertilized Farmland Planter with Low Nutrition -tile.scBlockPlanter_farmland_fertilized.depleted.name=Fertilized Farmland Planter with Depleted Nutrition +tile.planter_farmland_fertilized.full.name=Fertilized Farmland Planter +tile.planter_farmland_fertilized.reduced.name=Fertilized Farmland Planter with Reduced Nutrition +tile.planter_farmland_fertilized.low.name=Fertilized Farmland Planter with Low Nutrition +tile.planter_farmland_fertilized.depleted.name=Fertilized Farmland Planter with Depleted Nutrition -tile.scBlockPlanter_farmland_dung.full.name=Manured Farmland Planter -tile.scBlockPlanter_farmland_dung.reduced.name=Manured Farmland Planter with Reduced Nutrition -tile.scBlockPlanter_farmland_dung.low.name=Manured Farmland Planter with Low Nutrition -tile.scBlockPlanter_farmland_dung.depleted.name=Manured Farmland Planter with Depleted Nutrition +tile.planter_farmland_dung.full.name=Manured Farmland Planter +tile.planter_farmland_dung.reduced.name=Manured Farmland Planter with Reduced Nutrition +tile.planter_farmland_dung.low.name=Manured Farmland Planter with Low Nutrition +tile.planter_farmland_dung.depleted.name=Manured Farmland Planter with Depleted Nutrition # Plants -tile.scBlockDoubleTallPlant.grass.name=Double Tall Grass -tile.scBlockDoubleTallPlant.fern.name=Double Tall Fern +tile.tall_plant.grass.name=Double Tall Grass +tile.tall_plant.fern.name=Double Tall Fern + +tile.tall_flower.sunflower.name=Sunflower + +tile.short_grass.grass.name=Short Grass + +tile.waterPlantTall.cattail.name=Cattail +tile.waterPlantTall.grass.name=Tall Water Grass + +tile.waterPlantShort.tall_grass.name=Water Grass +tile.waterPlantShort.short_grass.name=Short Water Grass + +tile.clover.name=Clover +tile.clover_purple.name=Purple Clover +tile.clover_white.name=White Clover +tile.clover_red.name=Red Clover + +tile.sideshroom.white.name=White Sideshroom +tile.sideshroom.black.name=Black Sideshroom +tile.sideshroom.brown.name=Brown Sideshroom +tile.sideshroom.red.name=Red Sideshroom + +tile.moss_block.name=Moss Block + +tile.hollow_log.oak.name=Hollow Oak Log +tile.hollow_log.birch.name=Hollow Birch Log +tile.hollow_log.spruce.name=Hollow Spruce Log +tile.hollow_log.jungle.name=Hollow Jungle Log + +tile.hollow_log.blood.name=Hollow Bloodwood Log + +tile.hollow_log.darkOak.name=Hollow Dark Oak Log +tile.hollow_log.acacia.name=Hollow Acacia Log +tile.hollow_log.mahogany.name=Hollow Mahogany Log +tile.hollow_log.mangrove.name=Hollow Mangrove Log + +tile.hollow_log.hazel.name=Hollow Hazel Log +tile.hollow_log.fir.name=Hollow Fir Log +tile.hollow_log.aspen.name=Hollow Aspen Log +tile.hollow_log.willow.name=Hollow Willow Log + +tile.hollow_log.cherry.name=Hollow Cherry Log +tile.hollow_log.redwood.name=Hollow Redwood Log + +tile.lilyRose.pink.name=Pink Lily Rose +tile.lilyRose.white.name=White Lily Rose + +# Berries +tile.sweetberry.name=Sweetberry Bush +tile.blueberry.name=Blueberry Bush # Hay -tile.scBlockHay_drying.name=Drying Hay -tile.scBlockHay_dried.name=Hay -tile.scBlockBale_hay.name=Hay Bale -tile.scBlockBale_straw.name=Straw Bale +tile.hay_drying.name=Drying Hay +tile.hay_dried.name=Hay +tile.bale_hay.name=Hay Bale +tile.bale_straw.name=Straw Bale + +# Packed Blocks +tile.packed.sugarcane.name=Packed Sugarcane +tile.packed.shafts.name=Packed Shafts + +#Vanilla Override +tile.flower.flower.name=Yellow Flower +tile.flower.dandilion.name=Yellow Flower + ### Item ### # Tools @@ -88,4 +146,21 @@ item.gold_knife.name=Gold Knife item.diamond_knife.name=Diamond Knife item.steel_knife.name=Steel Knife -item.cuttings_item.name=Cuttings \ No newline at end of file +# Berries +item.sweetberry.name=Sweetberry +item.sweetberry_roots.name=Sweetberry Roots + +item.blueberry.name=Blueberry +item.blueberry_roots.name=Blueberry Roots + +item.fruit_bowl_berries.name=Sugared Berry Bowl + +item.moss_carpet.name=Moss Carpet +item.moss_ball.name=Moss Ball +# Plants +item.cuttings_item.name=Cuttings +item.sunflower.name=Sunflower +item.sunflower_seeds.name=Sunflower Seeds + +item.flowerPot.name=Flowerpot +item.large_flowerpot.name=Large Flowerpot \ No newline at end of file diff --git a/src/main/resources/sockscrops.accesswidener b/src/main/resources/sockscrops.accesswidener index 7b52bac..7b78bff 100644 --- a/src/main/resources/sockscrops.accesswidener +++ b/src/main/resources/sockscrops.accesswidener @@ -9,6 +9,12 @@ extendable method net/minecraft/src/StructureStrongholdPieces getStrongholdStone extendable method net/minecraft/src/WorldGenDungeons pickMobSpawner Lnet/minecraft/src/WorldGenDungeons;pickMobSpawner(Ljava/util/Random;)Ljava/lang/String; extendable method btw/block/blocks/FarmlandBlock setWeedsGrowthLevel Lbtw/block/blocks/FarmlandBlock;setWeedsGrowthLevel(Lnet/minecraft/src/World;IIII)V extendable method net/minecraft/src/GuiIngame renderModSpecificPlayerSightEffects Lnet/minecraft/src/GuiIngame;renderModSpecificPlayerSightEffects()V +accessible field net/minecraft/src/RenderBlocks uvRotateEast Lnet/minecraft/src/RenderBlocks;uvRotateEast:I +accessible field net/minecraft/src/RenderBlocks uvRotateWest Lnet/minecraft/src/RenderBlocks;uvRotateWest:I +accessible field net/minecraft/src/RenderBlocks uvRotateSouth Lnet/minecraft/src/RenderBlocks;uvRotateSouth:I +accessible field net/minecraft/src/RenderBlocks uvRotateNorth Lnet/minecraft/src/RenderBlocks;uvRotateNorth:I +accessible field net/minecraft/src/RenderBlocks uvRotateTop Lnet/minecraft/src/RenderBlocks;uvRotateTop:I +accessible field net/minecraft/src/RenderBlocks uvRotateBottom Lnet/minecraft/src/RenderBlocks;uvRotateBottom:I extendable class net/minecraft/src/ComponentScatteredFeature extendable class net/minecraft/src/StructureScatteredFeatureStones extendable class net/minecraft/src/ComponentScatteredFeaturePieces2 diff --git a/src/main/resources/sockscrops.mixins.json b/src/main/resources/sockscrops.mixins.json index f14e652..da90bf9 100644 --- a/src/main/resources/sockscrops.mixins.json +++ b/src/main/resources/sockscrops.mixins.json @@ -2,9 +2,12 @@ "required": true, "minVersion": "0.8", "package": "btw.community.sockthing.sockscrops.mixins", + "plugin": "btw.community.sockthing.sockscrops.mixins.plugins.DecoFlowerPotTileEntityPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ + "BiomeGenBaseMixin", "BiomeGenBeachMixin", + "BiomeGenJungleMixin", "BiomeGenRiverMixin", "BlockMixin", "BlockTallGrassMixin", @@ -19,16 +22,22 @@ "ComponentVillageHouse2Mixin", "DirtBlockMixin", "FarmlandBlockMixin", + "FlowerBlockMixin", "GenLayerRiverMixMixin", "GenLayerShoreMixin", "GrassBlockMixin", "GuiIngameMixin", "ItemMixin", + "LeavesBlockMixin", "LooseDirtBlockMixin", + "PlaceAsBlockItemAccessor", "SlotArmorMixin", "WeedsBlockMixin", "WorldGenDesertWellsMixin", - "WorldGenDungeonsMixin" + "WorldGenDungeonsMixin", + "WorldGenFlowersMixin", + "WorldGenShrubMixin", + "WorldGenTreesMixin" ], "client": [ ], diff --git a/src/main/resources/textures/blocks/bush_blueberry_0.png b/src/main/resources/textures/blocks/bush_blueberry_0.png new file mode 100644 index 0000000..b5d1c00 Binary files /dev/null and b/src/main/resources/textures/blocks/bush_blueberry_0.png differ diff --git a/src/main/resources/textures/blocks/bush_blueberry_1.png b/src/main/resources/textures/blocks/bush_blueberry_1.png new file mode 100644 index 0000000..ecc8aef Binary files /dev/null and b/src/main/resources/textures/blocks/bush_blueberry_1.png differ diff --git a/src/main/resources/textures/blocks/bush_blueberry_2.png b/src/main/resources/textures/blocks/bush_blueberry_2.png new file mode 100644 index 0000000..9f8233d Binary files /dev/null and b/src/main/resources/textures/blocks/bush_blueberry_2.png differ diff --git a/src/main/resources/textures/blocks/bush_blueberry_3.png b/src/main/resources/textures/blocks/bush_blueberry_3.png new file mode 100644 index 0000000..08ebbaa Binary files /dev/null and b/src/main/resources/textures/blocks/bush_blueberry_3.png differ diff --git a/src/main/resources/textures/blocks/bush_blueberry_4.png b/src/main/resources/textures/blocks/bush_blueberry_4.png new file mode 100644 index 0000000..1518ce4 Binary files /dev/null and b/src/main/resources/textures/blocks/bush_blueberry_4.png differ diff --git a/src/main/resources/textures/blocks/bush_blueberry_5.png b/src/main/resources/textures/blocks/bush_blueberry_5.png new file mode 100644 index 0000000..e9c5067 Binary files /dev/null and b/src/main/resources/textures/blocks/bush_blueberry_5.png differ diff --git a/src/main/resources/textures/blocks/bush_snow_0.png b/src/main/resources/textures/blocks/bush_snow_0.png new file mode 100644 index 0000000..480886a Binary files /dev/null and b/src/main/resources/textures/blocks/bush_snow_0.png differ diff --git a/src/main/resources/textures/blocks/bush_snow_1.png b/src/main/resources/textures/blocks/bush_snow_1.png new file mode 100644 index 0000000..8ac1abb Binary files /dev/null and b/src/main/resources/textures/blocks/bush_snow_1.png differ diff --git a/src/main/resources/textures/blocks/bush_snow_2.png b/src/main/resources/textures/blocks/bush_snow_2.png new file mode 100644 index 0000000..34f0939 Binary files /dev/null and b/src/main/resources/textures/blocks/bush_snow_2.png differ diff --git a/src/main/resources/textures/blocks/bush_snow_3.png b/src/main/resources/textures/blocks/bush_snow_3.png new file mode 100644 index 0000000..8a7905c Binary files /dev/null and b/src/main/resources/textures/blocks/bush_snow_3.png differ diff --git a/src/main/resources/textures/blocks/bush_snow_4.png b/src/main/resources/textures/blocks/bush_snow_4.png new file mode 100644 index 0000000..f46678d Binary files /dev/null and b/src/main/resources/textures/blocks/bush_snow_4.png differ diff --git a/src/main/resources/textures/blocks/bush_snow_5.png b/src/main/resources/textures/blocks/bush_snow_5.png new file mode 100644 index 0000000..dfc0a13 Binary files /dev/null and b/src/main/resources/textures/blocks/bush_snow_5.png differ diff --git a/src/main/resources/textures/blocks/bush_sweetberry_0.png b/src/main/resources/textures/blocks/bush_sweetberry_0.png new file mode 100644 index 0000000..e1a8ad8 Binary files /dev/null and b/src/main/resources/textures/blocks/bush_sweetberry_0.png differ diff --git a/src/main/resources/textures/blocks/bush_sweetberry_1.png b/src/main/resources/textures/blocks/bush_sweetberry_1.png new file mode 100644 index 0000000..c757550 Binary files /dev/null and b/src/main/resources/textures/blocks/bush_sweetberry_1.png differ diff --git a/src/main/resources/textures/blocks/bush_sweetberry_2.png b/src/main/resources/textures/blocks/bush_sweetberry_2.png new file mode 100644 index 0000000..8aea38f Binary files /dev/null and b/src/main/resources/textures/blocks/bush_sweetberry_2.png differ diff --git a/src/main/resources/textures/blocks/bush_sweetberry_3.png b/src/main/resources/textures/blocks/bush_sweetberry_3.png new file mode 100644 index 0000000..8441f84 Binary files /dev/null and b/src/main/resources/textures/blocks/bush_sweetberry_3.png differ diff --git a/src/main/resources/textures/blocks/bush_sweetberry_4.png b/src/main/resources/textures/blocks/bush_sweetberry_4.png new file mode 100644 index 0000000..049df8e Binary files /dev/null and b/src/main/resources/textures/blocks/bush_sweetberry_4.png differ diff --git a/src/main/resources/textures/blocks/bush_sweetberry_5.png b/src/main/resources/textures/blocks/bush_sweetberry_5.png new file mode 100644 index 0000000..23d273b Binary files /dev/null and b/src/main/resources/textures/blocks/bush_sweetberry_5.png differ diff --git a/src/main/resources/textures/blocks/cattail.png b/src/main/resources/textures/blocks/cattail.png new file mode 100644 index 0000000..a6f9d52 Binary files /dev/null and b/src/main/resources/textures/blocks/cattail.png differ diff --git a/src/main/resources/textures/blocks/cattail_bottom.png b/src/main/resources/textures/blocks/cattail_bottom.png new file mode 100644 index 0000000..4cb0780 Binary files /dev/null and b/src/main/resources/textures/blocks/cattail_bottom.png differ diff --git a/src/main/resources/textures/blocks/cattail_middle.png b/src/main/resources/textures/blocks/cattail_middle.png new file mode 100644 index 0000000..00eb6dc Binary files /dev/null and b/src/main/resources/textures/blocks/cattail_middle.png differ diff --git a/src/main/resources/textures/blocks/cattail_top.png b/src/main/resources/textures/blocks/cattail_top.png new file mode 100644 index 0000000..2ecede9 Binary files /dev/null and b/src/main/resources/textures/blocks/cattail_top.png differ diff --git a/src/main/resources/textures/blocks/clover.png b/src/main/resources/textures/blocks/clover.png new file mode 100644 index 0000000..5eeab13 Binary files /dev/null and b/src/main/resources/textures/blocks/clover.png differ diff --git a/src/main/resources/textures/blocks/clover_purple.png b/src/main/resources/textures/blocks/clover_purple.png new file mode 100644 index 0000000..56d7503 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_purple.png differ diff --git a/src/main/resources/textures/blocks/clover_purple_flower_top_0.png b/src/main/resources/textures/blocks/clover_purple_flower_top_0.png new file mode 100644 index 0000000..5e4988e Binary files /dev/null and b/src/main/resources/textures/blocks/clover_purple_flower_top_0.png differ diff --git a/src/main/resources/textures/blocks/clover_purple_flower_top_1.png b/src/main/resources/textures/blocks/clover_purple_flower_top_1.png new file mode 100644 index 0000000..c39395c Binary files /dev/null and b/src/main/resources/textures/blocks/clover_purple_flower_top_1.png differ diff --git a/src/main/resources/textures/blocks/clover_purple_flower_top_2.png b/src/main/resources/textures/blocks/clover_purple_flower_top_2.png new file mode 100644 index 0000000..5e4988e Binary files /dev/null and b/src/main/resources/textures/blocks/clover_purple_flower_top_2.png differ diff --git a/src/main/resources/textures/blocks/clover_purple_flower_top_3.png b/src/main/resources/textures/blocks/clover_purple_flower_top_3.png new file mode 100644 index 0000000..7876d18 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_purple_flower_top_3.png differ diff --git a/src/main/resources/textures/blocks/clover_red.png b/src/main/resources/textures/blocks/clover_red.png new file mode 100644 index 0000000..31791a1 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_red.png differ diff --git a/src/main/resources/textures/blocks/clover_red_flower_top_0.png b/src/main/resources/textures/blocks/clover_red_flower_top_0.png new file mode 100644 index 0000000..5e4988e Binary files /dev/null and b/src/main/resources/textures/blocks/clover_red_flower_top_0.png differ diff --git a/src/main/resources/textures/blocks/clover_red_flower_top_1.png b/src/main/resources/textures/blocks/clover_red_flower_top_1.png new file mode 100644 index 0000000..d3159e2 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_red_flower_top_1.png differ diff --git a/src/main/resources/textures/blocks/clover_red_flower_top_2.png b/src/main/resources/textures/blocks/clover_red_flower_top_2.png new file mode 100644 index 0000000..5e4988e Binary files /dev/null and b/src/main/resources/textures/blocks/clover_red_flower_top_2.png differ diff --git a/src/main/resources/textures/blocks/clover_red_flower_top_3.png b/src/main/resources/textures/blocks/clover_red_flower_top_3.png new file mode 100644 index 0000000..90e613f Binary files /dev/null and b/src/main/resources/textures/blocks/clover_red_flower_top_3.png differ diff --git a/src/main/resources/textures/blocks/clover_stalk_0.png b/src/main/resources/textures/blocks/clover_stalk_0.png new file mode 100644 index 0000000..9294ef9 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_stalk_0.png differ diff --git a/src/main/resources/textures/blocks/clover_stalk_1.png b/src/main/resources/textures/blocks/clover_stalk_1.png new file mode 100644 index 0000000..9df7a49 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_stalk_1.png differ diff --git a/src/main/resources/textures/blocks/clover_stalk_2.png b/src/main/resources/textures/blocks/clover_stalk_2.png new file mode 100644 index 0000000..9294ef9 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_stalk_2.png differ diff --git a/src/main/resources/textures/blocks/clover_stalk_3.png b/src/main/resources/textures/blocks/clover_stalk_3.png new file mode 100644 index 0000000..9df7a49 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_stalk_3.png differ diff --git a/src/main/resources/textures/blocks/clover_stalk_purple_flower_1.png b/src/main/resources/textures/blocks/clover_stalk_purple_flower_1.png new file mode 100644 index 0000000..c95cb10 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_stalk_purple_flower_1.png differ diff --git a/src/main/resources/textures/blocks/clover_stalk_purple_flower_3.png b/src/main/resources/textures/blocks/clover_stalk_purple_flower_3.png new file mode 100644 index 0000000..2c909ca Binary files /dev/null and b/src/main/resources/textures/blocks/clover_stalk_purple_flower_3.png differ diff --git a/src/main/resources/textures/blocks/clover_stalk_red_flower_1.png b/src/main/resources/textures/blocks/clover_stalk_red_flower_1.png new file mode 100644 index 0000000..0f78e83 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_stalk_red_flower_1.png differ diff --git a/src/main/resources/textures/blocks/clover_stalk_red_flower_3.png b/src/main/resources/textures/blocks/clover_stalk_red_flower_3.png new file mode 100644 index 0000000..d1b2fa1 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_stalk_red_flower_3.png differ diff --git a/src/main/resources/textures/blocks/clover_stalk_white_flower_1.png b/src/main/resources/textures/blocks/clover_stalk_white_flower_1.png new file mode 100644 index 0000000..78f0b32 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_stalk_white_flower_1.png differ diff --git a/src/main/resources/textures/blocks/clover_stalk_white_flower_3.png b/src/main/resources/textures/blocks/clover_stalk_white_flower_3.png new file mode 100644 index 0000000..eae2761 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_stalk_white_flower_3.png differ diff --git a/src/main/resources/textures/blocks/clover_top_0.png b/src/main/resources/textures/blocks/clover_top_0.png new file mode 100644 index 0000000..657246f Binary files /dev/null and b/src/main/resources/textures/blocks/clover_top_0.png differ diff --git a/src/main/resources/textures/blocks/clover_top_1.png b/src/main/resources/textures/blocks/clover_top_1.png new file mode 100644 index 0000000..feb0bb1 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_top_1.png differ diff --git a/src/main/resources/textures/blocks/clover_top_2.png b/src/main/resources/textures/blocks/clover_top_2.png new file mode 100644 index 0000000..c04f432 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_top_2.png differ diff --git a/src/main/resources/textures/blocks/clover_top_3.png b/src/main/resources/textures/blocks/clover_top_3.png new file mode 100644 index 0000000..91ff3f9 Binary files /dev/null and b/src/main/resources/textures/blocks/clover_top_3.png differ diff --git a/src/main/resources/textures/blocks/clover_white.png b/src/main/resources/textures/blocks/clover_white.png new file mode 100644 index 0000000..bed115a Binary files /dev/null and b/src/main/resources/textures/blocks/clover_white.png differ diff --git a/src/main/resources/textures/blocks/clover_white_flower_top_0.png b/src/main/resources/textures/blocks/clover_white_flower_top_0.png new file mode 100644 index 0000000..5e4988e Binary files /dev/null and b/src/main/resources/textures/blocks/clover_white_flower_top_0.png differ diff --git a/src/main/resources/textures/blocks/clover_white_flower_top_1.png b/src/main/resources/textures/blocks/clover_white_flower_top_1.png new file mode 100644 index 0000000..ae14aef Binary files /dev/null and b/src/main/resources/textures/blocks/clover_white_flower_top_1.png differ diff --git a/src/main/resources/textures/blocks/clover_white_flower_top_2.png b/src/main/resources/textures/blocks/clover_white_flower_top_2.png new file mode 100644 index 0000000..5e4988e Binary files /dev/null and b/src/main/resources/textures/blocks/clover_white_flower_top_2.png differ diff --git a/src/main/resources/textures/blocks/clover_white_flower_top_3.png b/src/main/resources/textures/blocks/clover_white_flower_top_3.png new file mode 100644 index 0000000..dcd22de Binary files /dev/null and b/src/main/resources/textures/blocks/clover_white_flower_top_3.png differ diff --git a/src/main/resources/textures/blocks/dandilion_white.png b/src/main/resources/textures/blocks/dandilion_white.png new file mode 100644 index 0000000..29f917a Binary files /dev/null and b/src/main/resources/textures/blocks/dandilion_white.png differ diff --git a/src/main/resources/textures/blocks/fcItemBreadDough.png b/src/main/resources/textures/blocks/fcItemBreadDough.png new file mode 100644 index 0000000..0a6f0d5 Binary files /dev/null and b/src/main/resources/textures/blocks/fcItemBreadDough.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_acacia_top.png b/src/main/resources/textures/blocks/hollow_log_acacia_top.png new file mode 100644 index 0000000..84c1780 Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_acacia_top.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_aspen_top.png b/src/main/resources/textures/blocks/hollow_log_aspen_top.png new file mode 100644 index 0000000..0017478 Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_aspen_top.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_birch_top.png b/src/main/resources/textures/blocks/hollow_log_birch_top.png new file mode 100644 index 0000000..3eabfec Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_birch_top.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_blood_inner.png b/src/main/resources/textures/blocks/hollow_log_blood_inner.png new file mode 100644 index 0000000..9ddf92c Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_blood_inner.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_blood_top.png b/src/main/resources/textures/blocks/hollow_log_blood_top.png new file mode 100644 index 0000000..3910279 Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_blood_top.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_cherry_top.png b/src/main/resources/textures/blocks/hollow_log_cherry_top.png new file mode 100644 index 0000000..72296e5 Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_cherry_top.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_darkoak_top.png b/src/main/resources/textures/blocks/hollow_log_darkoak_top.png new file mode 100644 index 0000000..45a10ee Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_darkoak_top.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_fir_top.png b/src/main/resources/textures/blocks/hollow_log_fir_top.png new file mode 100644 index 0000000..6da4a8c Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_fir_top.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_hazel_top.png b/src/main/resources/textures/blocks/hollow_log_hazel_top.png new file mode 100644 index 0000000..6f3a1b9 Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_hazel_top.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_jungle_top.png b/src/main/resources/textures/blocks/hollow_log_jungle_top.png new file mode 100644 index 0000000..a24bbfd Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_jungle_top.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_mahogany_top.png b/src/main/resources/textures/blocks/hollow_log_mahogany_top.png new file mode 100644 index 0000000..b90cb02 Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_mahogany_top.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_mangrove_top.png b/src/main/resources/textures/blocks/hollow_log_mangrove_top.png new file mode 100644 index 0000000..9f36b48 Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_mangrove_top.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_oak_top.png b/src/main/resources/textures/blocks/hollow_log_oak_top.png new file mode 100644 index 0000000..9b191eb Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_oak_top.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_redwood_top.png b/src/main/resources/textures/blocks/hollow_log_redwood_top.png new file mode 100644 index 0000000..cb4484b Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_redwood_top.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_spruce_top.png b/src/main/resources/textures/blocks/hollow_log_spruce_top.png new file mode 100644 index 0000000..9a016b3 Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_spruce_top.png differ diff --git a/src/main/resources/textures/blocks/hollow_log_willow_top.png b/src/main/resources/textures/blocks/hollow_log_willow_top.png new file mode 100644 index 0000000..c5c0e49 Binary files /dev/null and b/src/main/resources/textures/blocks/hollow_log_willow_top.png differ diff --git a/src/main/resources/textures/blocks/large_flowerpot.png b/src/main/resources/textures/blocks/large_flowerpot.png new file mode 100644 index 0000000..f426c6f Binary files /dev/null and b/src/main/resources/textures/blocks/large_flowerpot.png differ diff --git a/src/main/resources/textures/blocks/large_grass_bottom.png b/src/main/resources/textures/blocks/large_grass_bottom.png deleted file mode 100644 index ecc4e5d..0000000 Binary files a/src/main/resources/textures/blocks/large_grass_bottom.png and /dev/null differ diff --git a/src/main/resources/textures/blocks/large_grass_top.png b/src/main/resources/textures/blocks/large_grass_top.png deleted file mode 100644 index f192abc..0000000 Binary files a/src/main/resources/textures/blocks/large_grass_top.png and /dev/null differ diff --git a/src/main/resources/textures/blocks/lily_flower_pink.png b/src/main/resources/textures/blocks/lily_flower_pink.png new file mode 100644 index 0000000..e3c0575 Binary files /dev/null and b/src/main/resources/textures/blocks/lily_flower_pink.png differ diff --git a/src/main/resources/textures/blocks/lily_flower_white.png b/src/main/resources/textures/blocks/lily_flower_white.png new file mode 100644 index 0000000..0fd60cf Binary files /dev/null and b/src/main/resources/textures/blocks/lily_flower_white.png differ diff --git a/src/main/resources/textures/blocks/lily_item_pink.png b/src/main/resources/textures/blocks/lily_item_pink.png new file mode 100644 index 0000000..d825c55 Binary files /dev/null and b/src/main/resources/textures/blocks/lily_item_pink.png differ diff --git a/src/main/resources/textures/blocks/lily_item_white.png b/src/main/resources/textures/blocks/lily_item_white.png new file mode 100644 index 0000000..840a585 Binary files /dev/null and b/src/main/resources/textures/blocks/lily_item_white.png differ diff --git a/src/main/resources/textures/blocks/lily_roots.png b/src/main/resources/textures/blocks/lily_roots.png new file mode 100644 index 0000000..34db06f Binary files /dev/null and b/src/main/resources/textures/blocks/lily_roots.png differ diff --git a/src/main/resources/textures/blocks/lily_rose_pink.png b/src/main/resources/textures/blocks/lily_rose_pink.png new file mode 100644 index 0000000..c20d69a Binary files /dev/null and b/src/main/resources/textures/blocks/lily_rose_pink.png differ diff --git a/src/main/resources/textures/blocks/lily_rose_white.png b/src/main/resources/textures/blocks/lily_rose_white.png new file mode 100644 index 0000000..a2d7e7e Binary files /dev/null and b/src/main/resources/textures/blocks/lily_rose_white.png differ diff --git a/src/main/resources/textures/blocks/moss.png b/src/main/resources/textures/blocks/moss.png new file mode 100644 index 0000000..634161d Binary files /dev/null and b/src/main/resources/textures/blocks/moss.png differ diff --git a/src/main/resources/textures/blocks/moss_block.png b/src/main/resources/textures/blocks/moss_block.png new file mode 100644 index 0000000..634161d Binary files /dev/null and b/src/main/resources/textures/blocks/moss_block.png differ diff --git a/src/main/resources/textures/blocks/moss_carpet_side.png b/src/main/resources/textures/blocks/moss_carpet_side.png new file mode 100644 index 0000000..70c6108 Binary files /dev/null and b/src/main/resources/textures/blocks/moss_carpet_side.png differ diff --git a/src/main/resources/textures/blocks/packed_shafts_side.png b/src/main/resources/textures/blocks/packed_shafts_side.png new file mode 100644 index 0000000..4c7d3ab Binary files /dev/null and b/src/main/resources/textures/blocks/packed_shafts_side.png differ diff --git a/src/main/resources/textures/blocks/packed_shafts_top.png b/src/main/resources/textures/blocks/packed_shafts_top.png new file mode 100644 index 0000000..c0d2a48 Binary files /dev/null and b/src/main/resources/textures/blocks/packed_shafts_top.png differ diff --git a/src/main/resources/textures/blocks/packed_sugarcane_side.png b/src/main/resources/textures/blocks/packed_sugarcane_side.png new file mode 100644 index 0000000..5f9a437 Binary files /dev/null and b/src/main/resources/textures/blocks/packed_sugarcane_side.png differ diff --git a/src/main/resources/textures/blocks/packed_sugarcane_top.png b/src/main/resources/textures/blocks/packed_sugarcane_top.png new file mode 100644 index 0000000..e72bb5b Binary files /dev/null and b/src/main/resources/textures/blocks/packed_sugarcane_top.png differ diff --git a/src/main/resources/textures/blocks/petals_stalk.png b/src/main/resources/textures/blocks/petals_stalk.png new file mode 100644 index 0000000..b3a02fe Binary files /dev/null and b/src/main/resources/textures/blocks/petals_stalk.png differ diff --git a/src/main/resources/textures/blocks/pink_petals_0.png b/src/main/resources/textures/blocks/pink_petals_0.png new file mode 100644 index 0000000..1e4ab70 Binary files /dev/null and b/src/main/resources/textures/blocks/pink_petals_0.png differ diff --git a/src/main/resources/textures/blocks/pink_petals_1.png b/src/main/resources/textures/blocks/pink_petals_1.png new file mode 100644 index 0000000..bf70df0 Binary files /dev/null and b/src/main/resources/textures/blocks/pink_petals_1.png differ diff --git a/src/main/resources/textures/blocks/pink_petals_2.png b/src/main/resources/textures/blocks/pink_petals_2.png new file mode 100644 index 0000000..d361f4a Binary files /dev/null and b/src/main/resources/textures/blocks/pink_petals_2.png differ diff --git a/src/main/resources/textures/blocks/pink_petals_3.png b/src/main/resources/textures/blocks/pink_petals_3.png new file mode 100644 index 0000000..0d43bfa Binary files /dev/null and b/src/main/resources/textures/blocks/pink_petals_3.png differ diff --git a/src/main/resources/textures/blocks/short_grass.png b/src/main/resources/textures/blocks/short_grass.png new file mode 100644 index 0000000..193ed16 Binary files /dev/null and b/src/main/resources/textures/blocks/short_grass.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_black.png b/src/main/resources/textures/blocks/sideshroom_black.png new file mode 100644 index 0000000..e932fa4 Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_black.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_black_0.png b/src/main/resources/textures/blocks/sideshroom_black_0.png new file mode 100644 index 0000000..3cab471 Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_black_0.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_black_1.png b/src/main/resources/textures/blocks/sideshroom_black_1.png new file mode 100644 index 0000000..d4f6bf6 Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_black_1.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_black_2.png b/src/main/resources/textures/blocks/sideshroom_black_2.png new file mode 100644 index 0000000..45d4317 Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_black_2.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_brown.png b/src/main/resources/textures/blocks/sideshroom_brown.png new file mode 100644 index 0000000..496053b Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_brown.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_brown_0.png b/src/main/resources/textures/blocks/sideshroom_brown_0.png new file mode 100644 index 0000000..f912163 Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_brown_0.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_brown_1.png b/src/main/resources/textures/blocks/sideshroom_brown_1.png new file mode 100644 index 0000000..32de21c Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_brown_1.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_brown_2.png b/src/main/resources/textures/blocks/sideshroom_brown_2.png new file mode 100644 index 0000000..7e32be7 Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_brown_2.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_red.png b/src/main/resources/textures/blocks/sideshroom_red.png new file mode 100644 index 0000000..6b5c19d Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_red.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_red_0.png b/src/main/resources/textures/blocks/sideshroom_red_0.png new file mode 100644 index 0000000..da24a81 Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_red_0.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_red_1.png b/src/main/resources/textures/blocks/sideshroom_red_1.png new file mode 100644 index 0000000..f785b10 Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_red_1.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_red_2.png b/src/main/resources/textures/blocks/sideshroom_red_2.png new file mode 100644 index 0000000..777f850 Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_red_2.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_white.png b/src/main/resources/textures/blocks/sideshroom_white.png new file mode 100644 index 0000000..b0127a2 Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_white.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_white_0.png b/src/main/resources/textures/blocks/sideshroom_white_0.png new file mode 100644 index 0000000..4e1210a Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_white_0.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_white_1.png b/src/main/resources/textures/blocks/sideshroom_white_1.png new file mode 100644 index 0000000..7873aaf Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_white_1.png differ diff --git a/src/main/resources/textures/blocks/sideshroom_white_2.png b/src/main/resources/textures/blocks/sideshroom_white_2.png new file mode 100644 index 0000000..91e0153 Binary files /dev/null and b/src/main/resources/textures/blocks/sideshroom_white_2.png differ diff --git a/src/main/resources/textures/blocks/sunflower_back_0.png b/src/main/resources/textures/blocks/sunflower_back_0.png new file mode 100644 index 0000000..3399a36 Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_back_0.png differ diff --git a/src/main/resources/textures/blocks/sunflower_back_1.png b/src/main/resources/textures/blocks/sunflower_back_1.png new file mode 100644 index 0000000..e9472c8 Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_back_1.png differ diff --git a/src/main/resources/textures/blocks/sunflower_back_2.png b/src/main/resources/textures/blocks/sunflower_back_2.png new file mode 100644 index 0000000..2333538 Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_back_2.png differ diff --git a/src/main/resources/textures/blocks/sunflower_back_3.png b/src/main/resources/textures/blocks/sunflower_back_3.png new file mode 100644 index 0000000..d17d045 Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_back_3.png differ diff --git a/src/main/resources/textures/blocks/sunflower_bottom_0.png b/src/main/resources/textures/blocks/sunflower_bottom_0.png new file mode 100644 index 0000000..fd2bd45 Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_bottom_0.png differ diff --git a/src/main/resources/textures/blocks/sunflower_bottom_1.png b/src/main/resources/textures/blocks/sunflower_bottom_1.png new file mode 100644 index 0000000..387614b Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_bottom_1.png differ diff --git a/src/main/resources/textures/blocks/sunflower_bottom_2.png b/src/main/resources/textures/blocks/sunflower_bottom_2.png new file mode 100644 index 0000000..bc519af Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_bottom_2.png differ diff --git a/src/main/resources/textures/blocks/sunflower_bottom_3.png b/src/main/resources/textures/blocks/sunflower_bottom_3.png new file mode 100644 index 0000000..e2f4fa5 Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_bottom_3.png differ diff --git a/src/main/resources/textures/blocks/sunflower_bottom_4.png b/src/main/resources/textures/blocks/sunflower_bottom_4.png new file mode 100644 index 0000000..f662951 Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_bottom_4.png differ diff --git a/src/main/resources/textures/blocks/sunflower_front_0.png b/src/main/resources/textures/blocks/sunflower_front_0.png new file mode 100644 index 0000000..accdf33 Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_front_0.png differ diff --git a/src/main/resources/textures/blocks/sunflower_front_1.png b/src/main/resources/textures/blocks/sunflower_front_1.png new file mode 100644 index 0000000..2270cb5 Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_front_1.png differ diff --git a/src/main/resources/textures/blocks/sunflower_front_2.png b/src/main/resources/textures/blocks/sunflower_front_2.png new file mode 100644 index 0000000..2773b02 Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_front_2.png differ diff --git a/src/main/resources/textures/blocks/sunflower_front_3.png b/src/main/resources/textures/blocks/sunflower_front_3.png new file mode 100644 index 0000000..d143442 Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_front_3.png differ diff --git a/src/main/resources/textures/blocks/sunflower_top_0.png b/src/main/resources/textures/blocks/sunflower_top_0.png new file mode 100644 index 0000000..d526dad Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_top_0.png differ diff --git a/src/main/resources/textures/blocks/sunflower_top_1.png b/src/main/resources/textures/blocks/sunflower_top_1.png new file mode 100644 index 0000000..01fcf82 Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_top_1.png differ diff --git a/src/main/resources/textures/blocks/sunflower_top_2.png b/src/main/resources/textures/blocks/sunflower_top_2.png new file mode 100644 index 0000000..14a98b7 Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_top_2.png differ diff --git a/src/main/resources/textures/blocks/sunflower_top_3.png b/src/main/resources/textures/blocks/sunflower_top_3.png new file mode 100644 index 0000000..891b4fd Binary files /dev/null and b/src/main/resources/textures/blocks/sunflower_top_3.png differ diff --git a/src/main/resources/textures/blocks/large_fern_bottom.png b/src/main/resources/textures/blocks/tall_plant_fern_bottom.png similarity index 100% rename from src/main/resources/textures/blocks/large_fern_bottom.png rename to src/main/resources/textures/blocks/tall_plant_fern_bottom.png diff --git a/src/main/resources/textures/blocks/large_fern_top.png b/src/main/resources/textures/blocks/tall_plant_fern_top.png similarity index 100% rename from src/main/resources/textures/blocks/large_fern_top.png rename to src/main/resources/textures/blocks/tall_plant_fern_top.png diff --git a/src/main/resources/textures/blocks/tall_plant_grass_bottom.png b/src/main/resources/textures/blocks/tall_plant_grass_bottom.png new file mode 100644 index 0000000..d1bdd9e Binary files /dev/null and b/src/main/resources/textures/blocks/tall_plant_grass_bottom.png differ diff --git a/src/main/resources/textures/blocks/tall_plant_grass_top.png b/src/main/resources/textures/blocks/tall_plant_grass_top.png new file mode 100644 index 0000000..c055bea Binary files /dev/null and b/src/main/resources/textures/blocks/tall_plant_grass_top.png differ diff --git a/src/main/resources/textures/blocks/vine_dandilion.png b/src/main/resources/textures/blocks/vine_dandilion.png new file mode 100644 index 0000000..1c9b402 Binary files /dev/null and b/src/main/resources/textures/blocks/vine_dandilion.png differ diff --git a/src/main/resources/textures/blocks/vine_rose.png b/src/main/resources/textures/blocks/vine_rose.png new file mode 100644 index 0000000..2d6d378 Binary files /dev/null and b/src/main/resources/textures/blocks/vine_rose.png differ diff --git a/src/main/resources/textures/blocks/vine_yellow.png b/src/main/resources/textures/blocks/vine_yellow.png new file mode 100644 index 0000000..ac0b9af Binary files /dev/null and b/src/main/resources/textures/blocks/vine_yellow.png differ diff --git a/src/main/resources/textures/items/blueberry.png b/src/main/resources/textures/items/blueberry.png new file mode 100644 index 0000000..3906a1d Binary files /dev/null and b/src/main/resources/textures/items/blueberry.png differ diff --git a/src/main/resources/textures/items/blueberry_roots.png b/src/main/resources/textures/items/blueberry_roots.png new file mode 100644 index 0000000..facad2a Binary files /dev/null and b/src/main/resources/textures/items/blueberry_roots.png differ diff --git a/src/main/resources/textures/items/clover.png b/src/main/resources/textures/items/clover.png new file mode 100644 index 0000000..5eeab13 Binary files /dev/null and b/src/main/resources/textures/items/clover.png differ diff --git a/src/main/resources/textures/items/clover_purple.png b/src/main/resources/textures/items/clover_purple.png new file mode 100644 index 0000000..56d7503 Binary files /dev/null and b/src/main/resources/textures/items/clover_purple.png differ diff --git a/src/main/resources/textures/items/clover_red.png b/src/main/resources/textures/items/clover_red.png new file mode 100644 index 0000000..31791a1 Binary files /dev/null and b/src/main/resources/textures/items/clover_red.png differ diff --git a/src/main/resources/textures/items/clover_white.png b/src/main/resources/textures/items/clover_white.png new file mode 100644 index 0000000..bed115a Binary files /dev/null and b/src/main/resources/textures/items/clover_white.png differ diff --git a/src/main/resources/textures/items/fruit_bowl_berries.png b/src/main/resources/textures/items/fruit_bowl_berries.png new file mode 100644 index 0000000..4b1240b Binary files /dev/null and b/src/main/resources/textures/items/fruit_bowl_berries.png differ diff --git a/src/main/resources/textures/items/large_flowerpot.png b/src/main/resources/textures/items/large_flowerpot.png new file mode 100644 index 0000000..ca2a552 Binary files /dev/null and b/src/main/resources/textures/items/large_flowerpot.png differ diff --git a/src/main/resources/textures/items/moss_ball.png b/src/main/resources/textures/items/moss_ball.png new file mode 100644 index 0000000..74448e3 Binary files /dev/null and b/src/main/resources/textures/items/moss_ball.png differ diff --git a/src/main/resources/textures/items/moss_carpet.png b/src/main/resources/textures/items/moss_carpet.png new file mode 100644 index 0000000..60f10fc Binary files /dev/null and b/src/main/resources/textures/items/moss_carpet.png differ diff --git a/src/main/resources/textures/items/sunflower.png b/src/main/resources/textures/items/sunflower.png new file mode 100644 index 0000000..d143442 Binary files /dev/null and b/src/main/resources/textures/items/sunflower.png differ diff --git a/src/main/resources/textures/items/sunflower_seeds.png b/src/main/resources/textures/items/sunflower_seeds.png new file mode 100644 index 0000000..56f46f1 Binary files /dev/null and b/src/main/resources/textures/items/sunflower_seeds.png differ diff --git a/src/main/resources/textures/items/sweetberry.png b/src/main/resources/textures/items/sweetberry.png new file mode 100644 index 0000000..8df0781 Binary files /dev/null and b/src/main/resources/textures/items/sweetberry.png differ diff --git a/src/main/resources/textures/items/sweetberry_roots.png b/src/main/resources/textures/items/sweetberry_roots.png new file mode 100644 index 0000000..44316ea Binary files /dev/null and b/src/main/resources/textures/items/sweetberry_roots.png differ