Skip to content

Commit

Permalink
Merge branch 'release-2.4'
Browse files Browse the repository at this point in the history
* release-2.4:
  Refactor block-/item-/achievement-names
  Fix must missing texture
  Fix growing of must + change speed
  Fix texture issues
  Add own texture for fully grown must
  Fix obvious errors after update to 1.8
  Updated version to 1.8-2.4
  • Loading branch information
TeNNoX committed Apr 7, 2015
2 parents f2e56a3 + b6ae20d commit 22398fc
Show file tree
Hide file tree
Showing 39 changed files with 673 additions and 364 deletions.
45 changes: 26 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,36 @@ buildscript {

apply plugin: 'forge'

version = "1.7.2-2.3.2"
version = "1.8-2.4"
group= "tennox.bacteria" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "BacteriaMod"

minecraft {
version = "1.7.10-10.13.2.1232"
runDir = "../run/assets"
version = "1.8-11.14.1.1350"
runDir = "eclipse"

// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not allways work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20150402"
}

dependencies {
// you may put jars on which you depend on in ./libs
// or you may define them like so..
//compile "some.group:artifact:version:classifier"
//compile "some.group:artifact:version"

// real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env

// for more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html

}

processResources
Expand All @@ -45,19 +68,3 @@ processResources
exclude 'mcmod.info'
}
}

dependencies {
// you may put jars on which you depend on in ./libs
// or you may define them like so..
//compile "some.group:artifact:version:classifier"
//compile "some.group:artifact:version"

// real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env

// for more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html

}
173 changes: 50 additions & 123 deletions src/main/java/tennox/bacteriamod/Bacteria.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,46 @@
import java.util.ArrayList;
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.stats.AchievementList;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent;
import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent.MissingMapping;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;

import org.apache.logging.log4j.Logger;

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = "tennox_bacteria", name = "Bacteria", version = "2.3.3")
@Mod(modid = Bacteria.MODID, version = Bacteria.VERSION)
public class Bacteria {
static boolean achievements = false;
public static final String MODID = "tennox_bacteria";
public static final String VERSION = "2.4";

@Mod.Instance
public static Bacteria instance;

@SidedProxy(clientSide = "tennox.bacteriamod.BacteriaClientProxy", serverSide = "tennox.bacteriamod.BacteriaCommonProxy")
public static BacteriaCommonProxy proxy;

public static Logger logger;
public static BacteriaWorldGenerator worldGen = new BacteriaWorldGenerator();
public static boolean randomize;
public static String isolation;
public static ArrayList<Food> blacklist;
public static int speed;
public static int jamAchievementID;
public static Item bacteriaBunch;
public static Item jammerItem;
public static Item bacteriaPotion;
public static Block bacteria;
public static Block replacer;
public static Block marker;
public static Block jammer;
public static Block must;
public static ItemBacteria bacteriaBunch;
public static ItemBacteriaJammer jammerItem;
public static ItemBacteriaPotion bacteriaPotion;
public static BlockBacteria bacteria;
public static BlockBacteriaReplace replacer;
public static BlockBacteriaJammer jammer;
public static BlockMust must;
public static Achievement mustAchievement;
public static Achievement bacteriaAchievement;
public static Achievement bacteriumAchievement;
Expand All @@ -58,126 +52,59 @@ public class Bacteria {

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
FMLCommonHandler.instance().bus().register(this);
MinecraftForge.EVENT_BUS.register(this);
proxy.registerRenderInformation();
logger = event.getModLog();

Configuration config = new Configuration(event.getSuggestedConfigurationFile());
config.load();
achievements = config.get("General", "Enable achievements", true).getBoolean(true);

isolation = config.get("General", "isolation block", "brick_block").getString();
speed = config.get("General", "bacteria speed", 50).getInt();
randomize = config.get("General", "randomize bacteria spread", true).getBoolean(true);
String blacklist1 = config.get("General", "blacklist", "").getString();
config.save();

blacklist = new ArrayList<Food>();
if (blacklist1.length() > 0) {
for (String s : blacklist1.split(",")) {
try {
int meta = 0;
if (s.contains(":")) {
String[] s2 = s.split(":");
s = s2[0];
meta = Integer.parseInt(s2[1]);
}

int id = Integer.parseInt(s);
Block block = Block.getBlockById(id);
if (block == Blocks.air) {
logger.error("Error while parsing blacklist: ID " + id + " is not a valid block!");
} else {
blacklist.add(new Food(block, meta));
}
} catch (NumberFormatException e) {
logger.error("Error while parsing blacklist: '" + s + "' is not a valid number!");
continue;
}
}
}

bacteriaBunch = new ItemBacteria().setUnlocalizedName("tennox_bacteriaitem");
jammerItem = new ItemBacteriaJammer().setUnlocalizedName("tennox_jammeritem");
bacteriaPotion = new ItemBacteriaPotion().setUnlocalizedName("tennox_bacteriapotion");

bacteria = new BlockBacteria().setBlockName("tennox_bacteria");
replacer = new BlockBacteriaReplace().setBlockName("tennox_replacer");
jammer = new BlockBacteriaJammer().setBlockName("tennox_jammer");
must = new BlockMust().setBlockName("tennox_must");

GameRegistry.registerBlock(bacteria, "bacteria");
GameRegistry.registerBlock(replacer, "replacer");
GameRegistry.registerBlock(jammer, "jammer");
GameRegistry.registerBlock(must, "must");
GameRegistry.registerItem(bacteriaBunch, "bunch");
GameRegistry.registerItem(jammerItem, "jammerItem");
GameRegistry.registerItem(bacteriaPotion, "potion");
proxy.preInit(event);
}

@EventHandler
public void load(FMLInitializationEvent event) {

GameRegistry.addRecipe(new ItemStack(jammer, 1),
new Object[] { "+#+", "#*#", "+-+", Character.valueOf('#'), bacteria, Character.valueOf('*'), Items.iron_ingot, Character.valueOf('-'), Blocks.redstone_torch,
Character.valueOf('+'), Blocks.cobblestone });
GameRegistry.addRecipe(new ItemStack(jammerItem, 1), new Object[] { " # ", "#*#", " - ", Character.valueOf('#'), bacteria, Character.valueOf('*'), Items.iron_ingot,
Character.valueOf('-'), Blocks.redstone_torch });
GameRegistry.addRecipe(new ItemStack(bacteria, 1),
new Object[] { " # ", "#*#", " # ", Character.valueOf('#'), bacteriaBunch, Character.valueOf('*'), Blocks.redstone_torch });
GameRegistry.addRecipe(new ItemStack(replacer, 1), new Object[] { " # ", "#*#", " # ", Character.valueOf('#'), bacteriaBunch, Character.valueOf('*'), Items.coal });
GameRegistry.addRecipe(new ItemStack(must, 1),
new Object[] { "+*+", " # ", Character.valueOf('+'), Items.bread, Character.valueOf('#'), Items.water_bucket, Character.valueOf('*'), Blocks.sponge });
GameRegistry.addRecipe(new ItemStack(Blocks.sponge, 2), new Object[] { "+*+", "*+*", "+#+", Character.valueOf('+'), Blocks.wool, Character.valueOf('#'),
Items.water_bucket, Character.valueOf('*'), Blocks.yellow_flower });

GameRegistry.addRecipe(new ItemStack(Blocks.sponge, 2), new Object[] { "+*+", "*+*", "+#+", Character.valueOf('+'), Blocks.wool, Character.valueOf('#'),
Items.water_bucket, Character.valueOf('*'), Blocks.yellow_flower });

GameRegistry.addShapelessRecipe(new ItemStack(bacteriaPotion, 1), Items.potionitem, Items.nether_wart, bacteriaBunch);

if (achievements) { // Achievements
mustAchievement = new Achievement("bacteriamod.must", "must", 5, -2, must, AchievementList.buildWorkBench).registerStat();
bacteriaAchievement = new Achievement("bacteriamod.bacteria", "bacteria", 5, -3, bacteriaBunch, mustAchievement).registerStat();
bacteriumAchievement = new Achievement("bacteriamod.bacterium", "bacterium", 5, -4, bacteria, bacteriaAchievement).setSpecial().registerStat();
jamAchievement = new Achievement("bacteriamod.jammer", "jammer", 5, -5, jammerItem, bacteriumAchievement).setSpecial().registerStat();
}
GameRegistry.registerTileEntity(TileEntityBacteria.class, "bacteria_tileentity");
GameRegistry.registerTileEntity(TileEntityBacteriaReplacer.class, "replacer_tileentity");
GameRegistry.registerWorldGenerator(worldGen, 0);
proxy.init(event);
}

@EventHandler //TODO: This should be ForgeSubscribe, I think
@EventHandler
public void onMapMissing(FMLMissingMappingsEvent event) {
List<MissingMapping> list = event.get();

for (MissingMapping m : list) {
System.out.println("missing: " + m.name);
logger.warn("missing: " + m.name);
if (m.name.equals("tennox_bacteria:Bunch of Bacteria")) {
m.remap(bacteriaBunch);
} else if (m.name.equals("tennox_bacteria:Bacteria Jammer")) {
m.remap(jammerItem);
} else if (m.name.equals("tennox_bacteria:Bacteria Potion")) {
m.remap(bacteriaPotion);
} else
System.out.println("STILL MISSING: " + m.name);
}

else if (m.name.equals("tennox_bacteria:jammerItem")) { // renamed to jammeritem
m.remap(jammerItem);
}

else
logger.warn("STILL MISSING: " + m.name);
}
}

@SubscribeEvent
public void onPickup(EntityItemPickupEvent event) {
if (achievements && event.item.getEntityItem().getItem() == bacteriaBunch)
if (event.item.getEntityItem().getItem() == bacteriaBunch)
event.entityPlayer.addStat(bacteriaAchievement, 1);
}

@SubscribeEvent
public void onCrafting(ItemCraftedEvent event) { // SlotCrafting
if (achievements) {
if (event.crafting.getItem() == Item.getItemFromBlock(must))
event.player.addStat(mustAchievement, 1);
if (event.crafting.getItem() == Item.getItemFromBlock(bacteria))
event.player.addStat(bacteriumAchievement, 1);
}
if (event.crafting.getItem() == Item.getItemFromBlock(must))
event.player.addStat(mustAchievement, 1);
if (event.crafting.getItem() == Item.getItemFromBlock(bacteria))
event.player.addStat(bacteriumAchievement, 1);
}

/**
* Prepend the name with the mod ID, suitable for ResourceLocations such as textures.
*
* @param name
* @return eg "minecraftbyexample:myblockname"
*/
public static String prependModID(String name) {
return MODID + ":" + name;
}
}
40 changes: 40 additions & 0 deletions src/main/java/tennox/bacteriamod/BacteriaClientProxy.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
package tennox.bacteriamod;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class BacteriaClientProxy extends BacteriaCommonProxy {
@Override
public void registerRenderInformation() {
}

@Override
public void preInit(FMLPreInitializationEvent event) {
super.preInit(event);
}

@Override
public void init(FMLInitializationEvent event) {
super.init(event);

// ITEMS //
registerItemModel(Bacteria.bacteriaBunch, 0);
registerItemModel(Bacteria.bacteriaPotion, 0);
registerItemModel(Bacteria.jammerItem, 0);

// BLOCKS //
registerBlockModel(Bacteria.bacteria, 0);
registerBlockModel(Bacteria.replacer, 0);
registerBlockModel(Bacteria.jammer, 0);
registerBlockModel(Bacteria.must, 0);
}

private void registerBlockModel(IBlockWithName block, int defaultSubtype) {
Item item = Item.getItemFromBlock((Block) block);
ModelResourceLocation res = new ModelResourceLocation(Bacteria.prependModID(block.getName()), "inventory");
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, defaultSubtype, res);
}

public void registerItemModel(IItemWithName item, int defaultSubtype) {
ModelResourceLocation res = new ModelResourceLocation(Bacteria.prependModID(item.getName()), "inventory");
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register((Item) item, defaultSubtype, res);
}
}
Loading

0 comments on commit 22398fc

Please sign in to comment.