Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies {
devOnlyNonPublishable("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev") { transitive = false }
devOnlyNonPublishable('com.github.GTNewHorizons:Backhand:1.8.14:dev') { transitive = false }
devOnlyNonPublishable('com.github.GTNewHorizons:FindIt:1.4.6:dev') { transitive = false }
devOnlyNonPublishable('com.github.GTNewHorizons:BetterBuildersWands:0.13.12-GTNH:dev') { transitive = false }

// // optional runtime dependencies, you'll want to copy over the full pack configs to your dev env or else it will crash.
// // debugging tools
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/gtnewhorizon/cropsnh/CropsNH.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.gtnewhorizon.cropsnh.compatibility.StructureLib.StructureLibCompatHandler;
import com.gtnewhorizon.cropsnh.compatibility.TiC.TiCCompatHandler;
import com.gtnewhorizon.cropsnh.compatibility.betterbuilderswands.BetterBuildersWandsCompatHandler;
import com.gtnewhorizon.cropsnh.compatibility.extrautils.ExUWateringCanHandler;
import com.gtnewhorizon.cropsnh.compatibility.findit.FindItCompatHandler;
import com.gtnewhorizon.cropsnh.compatibility.forestry.ForestryCompatHandler;
Expand Down Expand Up @@ -67,6 +68,7 @@
+ "after:" + ModUtils.ModIDs.TwilightForest + "; "
+ "after:" + ModUtils.ModIDs.StructureLib + "; "
+ "after:" + ModUtils.ModIDs.PamsHarvestCraft + "; "
+ "after:" + ModUtils.ModIDs.BetterBuildersWands + "; "
// spotless:on
)
public class CropsNH {
Expand Down Expand Up @@ -132,6 +134,7 @@ public static void postInit(FMLPostInitializationEvent event) {
ForestryCompatHandler.postInit();
ExUWateringCanHandler.postInit();
FindItCompatHandler.postInit();
BetterBuildersWandsCompatHandler.postInit();

LogHelper.debug("Post-Initialization Complete");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.gtnewhorizon.cropsnh.compatibility.betterbuilderswands;

import net.minecraftforge.oredict.OreDictionary;

import com.gtnewhorizon.cropsnh.blocks.BlockCropSticks;
import com.gtnewhorizon.cropsnh.utility.ModUtils;

import portablejim.bbw.BetterBuildersWandsMod;

public class BetterBuildersWandsCompatHandler {

public static void postInit() {
if (!ModUtils.BetterBuildersWands.isModLoaded()) return;

BetterBuildersWandsMod.instance.mappingManager
.setMapping(new CropsNHBetterBuildersWandsCropStickCustomMapping());

// unbreakable wand
BlockCropSticks.BLOCK_INTERACTION_WITH
.add(ModUtils.BetterBuildersWands.getItem("wandUnbreakable"), OreDictionary.WILDCARD_VALUE);

// diamond wand
BlockCropSticks.BLOCK_INTERACTION_WITH
.add(ModUtils.BetterBuildersWands.getItem("wandDiamond"), OreDictionary.WILDCARD_VALUE);

// stone wand
BlockCropSticks.BLOCK_INTERACTION_WITH
.add(ModUtils.BetterBuildersWands.getItem("wandStone"), OreDictionary.WILDCARD_VALUE);

// iron wand
BlockCropSticks.BLOCK_INTERACTION_WITH
.add(ModUtils.BetterBuildersWands.getItem("wandIron"), OreDictionary.WILDCARD_VALUE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.gtnewhorizon.cropsnh.compatibility.betterbuilderswands;

import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;

import com.gtnewhorizon.cropsnh.api.CropsNHItemList;
import com.gtnewhorizon.cropsnh.init.CropsNHBlocks;

import portablejim.bbw.basics.Point3d;
import portablejim.bbw.core.conversion.ICustomMapping;
import portablejim.bbw.shims.IPlayerShim;
import portablejim.bbw.shims.IWorldShim;

public class CropsNHBetterBuildersWandsCropStickCustomMapping implements ICustomMapping {

@Override
public Block getLookBlock() {
return CropsNHBlocks.blockCropSticks;
}

@Override
public int getMeta() {
return 0;
}

@Override
public ItemStack getItems(IWorldShim world, IPlayerShim player, Point3d point) {
return CropsNHItemList.cropSticks.get(
player.getPlayer()
.isSneaking() ? 2 : 1);
}

@Override
public boolean shouldCopyTileNBT() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.PlayerUseItemEvent;
import net.minecraftforge.oredict.OreDictionary;

import com.gtnewhorizon.cropsnh.api.ICropStickTile;
import com.gtnewhorizon.cropsnh.blocks.BlockCropSticks;
Expand Down Expand Up @@ -36,6 +37,13 @@ public static void postInit() {
BlockCropSticks.BLOCK_INTERACTION_WITH.add(EXTRA_UTILS_WATERING_CAN, 0);
// reinforced
BlockCropSticks.BLOCK_INTERACTION_WITH.add(EXTRA_UTILS_WATERING_CAN, 3);

// building wands
Comment thread
C0bra5 marked this conversation as resolved.
BlockCropSticks.BLOCK_INTERACTION_WITH
.add(ModUtils.ExtraUtilities.getItem("builderswand"), OreDictionary.WILDCARD_VALUE);
BlockCropSticks.BLOCK_INTERACTION_WITH
.add(ModUtils.ExtraUtilities.getItem("creativebuilderswand"), OreDictionary.WILDCARD_VALUE);

}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import com.gtnewhorizon.cropsnh.api.ICropRightClickHandler;
import com.gtnewhorizon.cropsnh.api.ICropStickTile;
import com.gtnewhorizon.cropsnh.farming.registries.SoilRegistry;
import com.gtnewhorizon.cropsnh.init.CropsNHBlocks;

public class ItemCropSticks extends ItemBlockCropsNH implements ICropRightClickHandler {

Expand All @@ -31,39 +29,43 @@ public boolean canItemEditBlocks() {

// this is called when you right-click with this item in hand
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
float hitX, float hitY, float hitZ) {
// check if we are targeting the top side of a valid soil block
if (side != 1 || !SoilRegistry.instance.isRegistered(world, x, y, z)
|| world.getHeight() <= y + 1
|| !world.canPlaceEntityOnSide(CropsNHBlocks.blockCropSticks, x, y + 1, z, false, 0, player, stack)) {
return false;
}
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
float hitX, float hitY, float hitZ, int metadata) {

// you can shift-right-click to place a cross.
boolean isPlacingCross = player.isSneaking() && (player.capabilities.isCreativeMode || stack.stackSize >= 2);

world.setBlock(x, y + 1, z, CropsNHBlocks.blockCropSticks);

if (!player.capabilities.isCreativeMode) {
stack.stackSize -= isPlacingCross ? 2 : 1;
}
// place the stick
if (!world.setBlock(x, y, z, field_150939_a, metadata, 3)) return false;

// upgrade it if necessary
if (isPlacingCross && world.getTileEntity(x, y + 1, z) instanceof ICropStickTile crop) {
if (isPlacingCross && world.getTileEntity(x, y, z) instanceof ICropStickTile crop) {
Comment thread
C0bra5 marked this conversation as resolved.
crop.setCrossCrop(true);
world.markBlockForUpdate(x, y + 1, z);
world.markBlockForUpdate(x, y, z);
}

// copies vanilla mechanics
if (world.getBlock(x, y, z) == field_150939_a) {
field_150939_a.onBlockPlacedBy(world, x, y, z, player, stack);
field_150939_a.onPostBlockPlaced(world, x, y, z, metadata);
}

// play placement sound
world.playSoundEffect(
((float) x + 0.5F),
((float) y + 1.5F),
((float) y + 0.5F),
((float) z + 0.5F),
Blocks.planks.stepSound.func_150496_b(),
(Blocks.planks.stepSound.getVolume() + 1.0F) / 2.0F,
Blocks.planks.stepSound.getPitch() * 0.8F);
return true;

// consume items
if (!player.capabilities.isCreativeMode) {
stack.stackSize -= isPlacingCross ? 2 : 1;
}

// returning false because we're handling block placement sounds and stack consuming
return false;
}

@Override
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/gtnewhorizon/cropsnh/utility/ModUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

import org.jetbrains.annotations.Nullable;

import com.gtnewhorizon.gtnhlib.util.data.IMod;

import cpw.mods.fml.common.Loader;
Expand All @@ -17,6 +19,7 @@ public enum ModUtils implements IMod {
Angelica(ModIDs.Angelica),
Avaritia(ModIDs.Avaritia),
Backhand(ModIDs.Backhand),
BetterBuildersWands(ModIDs.BetterBuildersWands),
BiomesOPlenty(ModIDs.BiomesOPlenty),
BloodMagic(ModIDs.BloodMagic),
Botania(ModIDs.Botania),
Expand Down Expand Up @@ -124,6 +127,10 @@ public Item getItem(String name) {
return item;
}

public @Nullable Item getItemAllowNull(String name) {
return GameRegistry.findItem(this.ID, name);
}

public Block getBlock(String name) {
Block block = GameRegistry.findBlock(this.ID, name);

Expand All @@ -143,6 +150,10 @@ public Block getBlock(String name) {
return block;
}

public @Nullable Block getBlockAllowNull(String name) {
Comment thread
C0bra5 marked this conversation as resolved.
return GameRegistry.findBlock(this.ID, name);
}

public ItemStack getStack(String name, int amount, int meta) {
return CropsNHUtils.getModItem(this, name, amount, meta);
}
Expand All @@ -152,6 +163,7 @@ public static class ModIDs {
public static final String Angelica = "angelica";
public static final String Avaritia = "Avaritia";
public static final String Backhand = "backhand";
public static final String BetterBuildersWands = "betterbuilderswands";
public static final String BiomesOPlenty = "BiomesOPlenty";
public static final String BloodMagic = "AWWayofTime";
public static final String Botania = "Botania";
Expand Down