Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added module to support modded crops #6

Merged
merged 2 commits into from
Aug 27, 2024
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
7 changes: 7 additions & 0 deletions src/main/java/vswe/stevescarts/ModuleData/ModuleData.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
import vswe.stevescarts.Modules.Addons.ModuleSmelter;
import vswe.stevescarts.Modules.Addons.ModuleSmelterAdv;
import vswe.stevescarts.Modules.Addons.ModuleSnowCannon;
import vswe.stevescarts.Modules.Addons.Plants.ModuleModCrops;
import vswe.stevescarts.Modules.Addons.Plants.ModuleModTrees;
import vswe.stevescarts.Modules.Addons.Plants.ModuleNetherwart;
import vswe.stevescarts.Modules.Addons.Plants.ModulePlantSize;
Expand Down Expand Up @@ -942,6 +943,12 @@ public String getCartInfoText(String name, byte b) {
{ Items.redstone, Blocks.sapling, Items.redstone }, { ComponentTypes.SIMPLE_PCB.getItemStack(),
ComponentTypes.EMPTY_DISK.getItemStack(), ComponentTypes.SIMPLE_PCB.getItemStack() } });

new ModuleData(102, "Crop: Exotic", ModuleModCrops.class, 30).addRequirement(farmerGroup).addRecipe(
new Object[][] { { Items.glowstone_dust, null, Items.glowstone_dust },
{ Items.redstone, Items.wheat_seeds, Items.redstone },
{ ComponentTypes.SIMPLE_PCB.getItemStack(), ComponentTypes.EMPTY_DISK.getItemStack(),
ComponentTypes.SIMPLE_PCB.getItemStack() } });

new ModuleData(89, "Planter Range Extender", ModulePlantSize.class, 20).addRequirement(woodcutterGroup)
.addRecipe(
new Object[][] { { Items.redstone, ComponentTypes.ADVANCED_PCB.getItemStack(), Items.redstone },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package vswe.stevescarts.Modules.Addons.Plants;

import net.minecraft.block.Block;
import net.minecraft.block.IGrowable;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.IPlantable;

import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
import vswe.stevescarts.Carts.MinecartModular;
import vswe.stevescarts.Modules.Addons.ModuleAddon;
import vswe.stevescarts.Modules.ICropModule;

public class ModuleModCrops extends ModuleAddon implements ICropModule {

public ModuleModCrops(MinecartModular cart) {
super(cart);
}

@Override
public boolean isSeedValid(ItemStack seed) {

UniqueIdentifier uniqueIdentifier = GameRegistry.findUniqueIdentifierFor(seed.getItem());

if (seed.getItem() == Items.melon_seeds || seed.getItem() == Items.pumpkin_seeds
|| seed.getItem() == Items.nether_wart) {
return false;
}

// tb seeds need more work
if (uniqueIdentifier.modId.equals("thaumicbases")) {
return false;
}

// Natura crops don't work well with the SC2 approach
if (uniqueIdentifier.modId.equals("Natura")) {
return false;
}
return seed.getItem() instanceof IPlantable;
}

@Override
public Block getCropFromSeed(ItemStack seed) {
return ((IPlantable) seed.getItem()).getPlant(getCart().worldObj, 0, 0, 0);
}

@Override
public boolean isReadyToHarvest(int x, int y, int z) {
Block block = getCart().worldObj.getBlock(x, y, z);
int m = getCart().worldObj.getBlockMetadata(x, y, z);
UniqueIdentifier uniqueIdentifier = GameRegistry.findUniqueIdentifierFor(block);

if (!(block instanceof IGrowable)) {
return false;
}

// witchery compatibility
if (uniqueIdentifier.modId.equals("witchery")) {
if (uniqueIdentifier.name.equals("garlicplant") && m == 5) {
return true;
} else if (m == 4) {
return true;
}
}

// default for crops
if (m == 7) {
return true;
}

return false;
}

}
1 change: 1 addition & 0 deletions src/main/resources/assets/stevescarts/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ item.SC2:cake_server.name=Cake Server
item.SC2:creative_incinerator.name=Creative Incinerator
item.SC2:creative_supplies.name=Creative Supplies
item.SC2:color_randomizer.name=Color Randomizer
item.SC2:crop_exotic.name=Crop: Exotic

# Components
item.SC2:unknowncomponent.name=Unknown SC2 Component
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.