Skip to content

Commit

Permalink
Merge pull request #24 from GiantTreeLP/1.10.2-wip
Browse files Browse the repository at this point in the history
1.10.2 wip
  • Loading branch information
GiantTreeLP committed Jul 13, 2016
2 parents 4ed1847 + bf10a36 commit ed45e36
Show file tree
Hide file tree
Showing 20 changed files with 136 additions and 57 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ compileJava {
targetCompatibility = 1.8
}

version = "1.10.2-0.4.0"
version = "1.10.2-0.4.1"
group = "gtlp.prettyniceores" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "prettyniceores"

minecraft {
version = "1.10.2-12.18.0.2007-1.10.0"
version = "1.10.2-12.18.1.2013"
runDir = "run"

// the mappings can be changed at any time, and must be in the following format.
Expand Down Expand Up @@ -99,7 +99,7 @@ curseforge {
apiKey = project.hasProperty("curseapitoken") ? project.getProperty("curseapitoken") : ""
project {
id = '245633'
changelog = "Changelog and releases: https://github.com/GiantTreeLP/PrettyNiceOres/commits/1.9.4"
changelog = "Changelog and releases: https://github.com/GiantTreeLP/PrettyNiceOres/commits/1.10.2"
releaseType = 'release'

mainArtifact jar
Expand All @@ -110,4 +110,4 @@ minecraft {
replaceIn "Constants.java"
replace "\${version}", project.version
replace "\${mcversion}", project.minecraft.version
}
}
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#Tue Jul 05 23:30:10 CEST 2016
#Wed Jul 06 23:46:18 CEST 2016
#Thu Jul 07 02:04:11 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/gtlp/prettyniceores/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
public final class Constants {

public static final String MOD_ID = "prettyniceores";
public static final String VERSION = "${version}";
public static final String UPDATE_URL = "https://raw.githubusercontent.com/GiantTreeLP/PrettyNiceOres/1.9.4/versions.json";
public static final String NAME = "PrettyNiceOres";
public static final String DEPENDENCIES = "after:neotech;after:tconstruct;after:basemetals";
protected static final String MC_VERSION = "[${mcversion},)";
static final String VERSION = "${version}";
static final String UPDATE_URL = "https://raw.githubusercontent.com/GiantTreeLP/PrettyNiceOres/1.9.4/versions.json";
static final String DEPENDENCIES = "after:neotech;after:tconstruct;after:basemetals;after:substratum";
static final String MC_VERSION = "[${mcversion},)";

private Constants() {
}
Expand Down
56 changes: 46 additions & 10 deletions src/main/java/gtlp/prettyniceores/PrettyNiceOres.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
import gtlp.prettyniceores.interfaces.IOreDictCompatible;
import gtlp.prettyniceores.interfaces.ISmeltable;
import gtlp.prettyniceores.recipes.ShapelessOreDictRecipe;
import gtlp.prettyniceores.util.OreDictUtils;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
Expand All @@ -30,6 +34,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -48,12 +53,24 @@

public class PrettyNiceOres {
public static final Logger LOGGER = LogManager.getLogger(Constants.MOD_ID);

public static final CreativeTabs CREATIVE_TAB = new CreativeTabs(Constants.MOD_ID) {
@SideOnly(Side.CLIENT)
@Override
@Nonnull
public Item getTabIconItem() {
return ItemBlock.getItemFromBlock(Blocks.DIAMOND_ORE);
}
};

private static final Map<String, Block> blockList = new HashMap<>();
private static final Map<String, Item> itemList = new HashMap<>();
private static final Map<String, ItemBlock> itemBlockList = new HashMap<>();
private static final List<IRecipe> recipeList = new ArrayList<>();

@SidedProxy(clientSide = "gtlp.prettyniceores.client.ClientProxy", serverSide = "gtlp.prettyniceores.common.CommonProxy")
public static CommonProxy proxy;
private List<IRecipe> recipeList = new ArrayList<>();


public static Map<String, Block> getBlockList() {
return blockList;
Expand All @@ -69,6 +86,24 @@ private static void registerItemRenderer(Item item, int meta) {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta, new ModelResourceLocation(item.getRegistryName(), "inventory"));
}

private static void addSmeltingRecipe(Item item) {
if (item instanceof ISmeltable) {
ItemStack result = ((ISmeltable) item).getSmeltingResult();
if (result != null) {
GameRegistry.addSmelting(item, result, ((ISmeltable) item).getSmeltingExp());
}
}
}

private static void addSmeltingRecipe(Block block) {
if (block instanceof ISmeltable) {
ItemStack result = ((ISmeltable) block).getSmeltingResult();
if (result != null) {
GameRegistry.addSmelting(block, result, ((ISmeltable) block).getSmeltingExp());
}
}
}

/**
* Preinitialization of the mod.
*
Expand All @@ -93,20 +128,16 @@ public void preInit(FMLPreInitializationEvent event) {
if (block instanceof IOreDictCompatible) {
OreDictionary.registerOre(((IOreDictCompatible) block).getOreDictType(), item);
}
if (block instanceof ISmeltable) {
GameRegistry.addSmelting(item, ((ISmeltable) block).getSmeltingResult(), (((ISmeltable) block).getSmeltingExp()));
}
addSmeltingRecipe(block);
});
itemList.forEach((name, item) -> {
GameRegistry.register(item);
if (item instanceof IOreDictCompatible) {
OreDictionary.registerOre(((IOreDictCompatible) item).getOreDictType(), item);
}
if (item instanceof ISmeltable) {
GameRegistry.addSmelting(item, ((ISmeltable) item).getSmeltingResult(), ((ISmeltable) item).getSmeltingExp());
}
addSmeltingRecipe(item);
});
recipeList.forEach(GameRegistry::addRecipe);

MinecraftForge.EVENT_BUS.register(new OnPlayerLoginEvent());
LOGGER.info("PreInit done.");
}
Expand All @@ -129,7 +160,8 @@ private void addVanillaOres() {
* Adds all replacements for mod ores, if they have been created by any other mod.
*/
private void addModOres() {
Block[] blockArray = {new NiceCopperOre(),
Block[] blockArray = {
new NiceCopperOre(),
new NiceTinOre(),
new NiceSilverOre(),
new NiceLeadOre(),
Expand Down Expand Up @@ -165,8 +197,12 @@ public void init(FMLInitializationEvent event) {
});
blockList.entrySet().stream().filter(entry -> entry.getValue() instanceof IOreDictCompatible).forEach(entry -> {
IOreDictCompatible block = (IOreDictCompatible) entry.getValue();
GameRegistry.addRecipe(new ShapelessOreRecipe(OreDictionary.getOres(block.getOreDictType()).get(0), block));
ItemStack result = OreDictUtils.getFirstOre(block.getOreDictType());
if (result != null) {
GameRegistry.addRecipe(new ShapelessOreRecipe(result, block));
}
});
recipeList.forEach(GameRegistry::addRecipe);

LOGGER.info("Init done.");
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/gtlp/prettyniceores/blocks/NiceOreBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
public abstract class NiceOreBase extends BlockOre {

private static final float HARDNESS = 10f;
//Vectors pointing to adjacent and diagonal positions around the block
private static final Vec3i[] ADJACENT = new Vec3i[]{new Vec3i(-1, -1, -1), new Vec3i(-1, -1, 0), new Vec3i(-1, -1, 1), new Vec3i(-1, 0, -1), new Vec3i(-1, 0, 0),
new Vec3i(-1, 0, 1), new Vec3i(-1, 1, -1), new Vec3i(-1, 1, 0), new Vec3i(-1, 1, 1), new Vec3i(0, -1, -1),
Expand All @@ -44,7 +45,8 @@ protected NiceOreBase(String name) {
setRegistryName(Constants.MOD_ID, name);
setUnlocalizedName(name);
setDefaultState(blockState.getBaseState());
setHardness(10f);
setHardness(HARDNESS);
setCreativeTab(PrettyNiceOres.CREATIVE_TAB);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import gtlp.prettyniceores.interfaces.IOre;
import gtlp.prettyniceores.interfaces.IOreDictCompatible;
import gtlp.prettyniceores.interfaces.ISmeltable;
import gtlp.prettyniceores.util.OreDictUtils;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

/**
* Created by Marv1 on 23.05.2016 as part of forge-modding-1.9.
Expand All @@ -24,7 +24,7 @@ public NiceCopperOre() {

@Override
public final ItemStack getSmeltingResult() {
return OreDictionary.getOres("ingotCopper").get(0);
return OreDictUtils.getFirstOre("ingotCopper");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import gtlp.prettyniceores.interfaces.IOre;
import gtlp.prettyniceores.interfaces.IOreDictCompatible;
import gtlp.prettyniceores.interfaces.ISmeltable;
import gtlp.prettyniceores.util.OreDictUtils;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

/**
* Created by Marv1 on 23.05.2016 as part of forge-modding-1.9.
Expand All @@ -24,7 +24,7 @@ public NiceLeadOre() {

@Override
public final ItemStack getSmeltingResult() {
return OreDictionary.getOres("ingotLead").get(0);
return OreDictUtils.getFirstOre("ingotLead");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import gtlp.prettyniceores.interfaces.IOre;
import gtlp.prettyniceores.interfaces.IOreDictCompatible;
import gtlp.prettyniceores.interfaces.ISmeltable;
import gtlp.prettyniceores.util.OreDictUtils;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

/**
* Created by Marv1 on 23.05.2016 as part of forge-modding-1.9.
Expand All @@ -24,7 +24,7 @@ public NiceMercuryOre() {

@Override
public final ItemStack getSmeltingResult() {
return OreDictionary.getOres("ingotMercury").get(0);
return OreDictUtils.getFirstOre("ingotMercury");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import gtlp.prettyniceores.interfaces.IOre;
import gtlp.prettyniceores.interfaces.IOreDictCompatible;
import gtlp.prettyniceores.interfaces.ISmeltable;
import gtlp.prettyniceores.util.OreDictUtils;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

/**
* Created by Marv1 on 23.05.2016 as part of forge-modding-1.9.
Expand All @@ -24,7 +24,7 @@ public NiceNickelOre() {

@Override
public final ItemStack getSmeltingResult() {
return OreDictionary.getOres("ingotNickel").get(0);
return OreDictUtils.getFirstOre("ingotNickel");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import gtlp.prettyniceores.interfaces.IOre;
import gtlp.prettyniceores.interfaces.IOreDictCompatible;
import gtlp.prettyniceores.interfaces.ISmeltable;
import gtlp.prettyniceores.util.OreDictUtils;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

/**
* Created by Marv1 on 09.06.2016.
Expand All @@ -24,7 +24,7 @@ public NicePlatinumOre() {

@Override
public final ItemStack getSmeltingResult() {
return OreDictionary.getOres("ingotPlatinum").get(0);
return OreDictUtils.getFirstOre("ingotPlatinum");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import gtlp.prettyniceores.interfaces.IOre;
import gtlp.prettyniceores.interfaces.IOreDictCompatible;
import gtlp.prettyniceores.interfaces.ISmeltable;
import gtlp.prettyniceores.util.OreDictUtils;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

/**
* Created by Marv1 on 09.06.2016.
Expand All @@ -24,7 +24,7 @@ public NiceSilverOre() {

@Override
public final ItemStack getSmeltingResult() {
return OreDictionary.getOres("ingotSilver").get(0);
return OreDictUtils.getFirstOre("ingotSilver");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import gtlp.prettyniceores.interfaces.IOre;
import gtlp.prettyniceores.interfaces.IOreDictCompatible;
import gtlp.prettyniceores.interfaces.ISmeltable;
import gtlp.prettyniceores.util.OreDictUtils;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

/**
* Created by Marv1 on 09.06.2016.
Expand All @@ -24,7 +24,7 @@ public NiceTinOre() {

@Override
public final ItemStack getSmeltingResult() {
return OreDictionary.getOres("ingotTin").get(0);
return OreDictUtils.getFirstOre("ingotTin");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import gtlp.prettyniceores.interfaces.IOre;
import gtlp.prettyniceores.interfaces.IOreDictCompatible;
import gtlp.prettyniceores.interfaces.ISmeltable;
import gtlp.prettyniceores.util.OreDictUtils;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

/**
* Created by Marv1 on 23.05.2016 as part of forge-modding-1.9.
Expand All @@ -24,7 +24,7 @@ public NiceZincOre() {

@Override
public final ItemStack getSmeltingResult() {
return OreDictionary.getOres("ingotZinc").get(0);
return OreDictUtils.getFirstOre("ingotZinc");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import net.minecraftforge.fml.common.IWorldGenerator;
import net.minecraftforge.oredict.OreDictionary;

Expand Down Expand Up @@ -43,14 +44,19 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG
//Fairly quick nested loop to replace vanilla and ore dictionary ores with ours upon generation of a chunk.
Stream.of(chunk.getBlockStorageArray()).filter(blockStorage -> blockStorage != null).parallel().forEach(blockStorage ->
IntStream.range(0, STORAGE_ARRAY_SIZE).forEach(y ->
IntStream.range(0, STORAGE_ARRAY_SIZE).forEach(z ->
IntStream.range(0, STORAGE_ARRAY_SIZE).forEach(x -> {
IBlockState state = blockStorage.get(x, y, z);
if (replacementMap.containsKey(state.getBlock())) {
synchronized (this) {
blockStorage.getData().set(x, y, z, replacementMap.get(state.getBlock()).getDefaultState());
}
}
}))));
IntStream.range(0, STORAGE_ARRAY_SIZE).forEach(z -> {
IntStream.range(0, STORAGE_ARRAY_SIZE).forEach(x -> {
IBlockState state = blockStorage.get(x, y, z);
if (replacementMap.containsKey(state.getBlock())) {
setBlock(blockStorage, y, z, x, replacementMap.get(state.getBlock()).getDefaultState());
}
});
})));
}

private synchronized void setBlock(ExtendedBlockStorage blockStorage, int y, int z, int x, IBlockState state) {
synchronized (this) {
blockStorage.getData().set(x, y, z, state);
}
}
}
Loading

0 comments on commit ed45e36

Please sign in to comment.