Skip to content

Commit

Permalink
Backported the latest 1.12 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hennamann committed Jan 6, 2018
1 parent e77ed9e commit 1991cdc
Show file tree
Hide file tree
Showing 19 changed files with 218 additions and 192 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "1.1.0"
version = "1.2.0"
group = "com.legacy.wasteland" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "wastelands"

Expand Down
6 changes: 1 addition & 5 deletions src/main/java/com/legacy/wasteland/Wasteland.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.legacy.wasteland;

import com.legacy.wasteland.config.LootConfig;
import com.legacy.wasteland.config.WorldConfig;
import com.legacy.wasteland.world.WastelandWorld;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
Expand All @@ -20,7 +18,7 @@
public class Wasteland {

public static final String MOD_ID = "wastelands";
public static final String VERSION = "1.1.0";
public static final String VERSION = "1.2.0";

public static Logger wastelandLogger;

Expand All @@ -34,8 +32,6 @@ public class Wasteland {
@EventHandler
public static void preInit(FMLPreInitializationEvent event) {
wastelandLogger = event.getModLog();
LootConfig.init(event.getModConfigurationDirectory());
WorldConfig.init(event.getModConfigurationDirectory());
PROXY.preInit();
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/legacy/wasteland/WastelandEventHandler.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.legacy.wasteland;

import com.legacy.wasteland.config.WorldConfig;
import com.legacy.wasteland.config.WastelandConfig;
import com.legacy.wasteland.world.WastelandWorld;
import com.legacy.wasteland.world.biome.decorations.BiomeDecoratorWasteland;
import com.legacy.wasteland.world.util.WastelandWorldData;
Expand Down Expand Up @@ -65,7 +65,7 @@ public void setSpawnpointEvent(EntityJoinWorldEvent event) {
}

if(!spawnSet && spawnLocation != null) {
if(!bunkerSpawned && WorldConfig.shouldSpawnBunker) {
if(!bunkerSpawned && WastelandConfig.worldgen.shouldSpawnBunker) {
if(!event.getWorld().isRemote) {
BiomeDecoratorWasteland.spawnBunker(event.getWorld());
}
Expand All @@ -91,22 +91,22 @@ public void setSpawnpointEvent(EntityJoinWorldEvent event) {
*/
@SubscribeEvent
public void zombieRenderOnFire(RenderLivingEvent event) {
if (event.getEntity() instanceof EntityZombie && event.getEntity().isBurning() && event.getEntity().world.getWorldType() == WastelandWorld.worldtype_wasteland && WorldConfig.shouldSpawnDayZombies) {
if (event.getEntity() instanceof EntityZombie && event.getEntity().isBurning() && event.getEntity().world.getWorldType() == WastelandWorld.worldtype_wasteland && WastelandConfig.worldgen.shouldSpawnDayZombies) {
event.getEntity().extinguish();
}
}

@SubscribeEvent
public void zombieOnFire(LivingHurtEvent event) {
if (event.getEntity() instanceof EntityZombie && event.getSource() == DamageSource.ON_FIRE && event.getEntity().world.getWorldType() == WastelandWorld.worldtype_wasteland && WorldConfig.shouldSpawnDayZombies) {
if (event.getEntity() instanceof EntityZombie && event.getSource() == DamageSource.ON_FIRE && event.getEntity().world.getWorldType() == WastelandWorld.worldtype_wasteland && WastelandConfig.worldgen.shouldSpawnDayZombies) {
event.getEntity().extinguish();
event.setCanceled(true);
}
}

@SubscribeEvent
public void zombieUpdateFire(LivingUpdateEvent event) {
if (event.getEntity() instanceof EntityZombie && event.getEntity().isBurning() && event.getEntity().world.getWorldType() == WastelandWorld.worldtype_wasteland && WorldConfig.shouldSpawnDayZombies) {
if (event.getEntity() instanceof EntityZombie && event.getEntity().isBurning() && event.getEntity().world.getWorldType() == WastelandWorld.worldtype_wasteland && WastelandConfig.worldgen.shouldSpawnDayZombies) {
event.getEntity().extinguish();
}
}
Expand Down
58 changes: 0 additions & 58 deletions src/main/java/com/legacy/wasteland/config/LootConfig.java

This file was deleted.

141 changes: 141 additions & 0 deletions src/main/java/com/legacy/wasteland/config/WastelandConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
package com.legacy.wasteland.config;

import com.legacy.wasteland.Wasteland;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

import java.util.Random;

@Config(modid = Wasteland.MOD_ID, name = "wasteland_mod/Wasteland")
@Config.LangKey("wastelands.config.title")
public class WastelandConfig {

@Config.Comment("Add item names chest loot. Do NOT add blank entries. Format for items:\\nmod_name:item_name,max,min\\nCheck mod language registry for item names. max = maximum stack size, min = minimum stack size. If max/min stack size > game stack limit, game will choose the stack limit.\"")
public static Loot loot = new Loot();

public static Worldgen worldgen = new Worldgen();

public static Biomes biomes = new Biomes();

public static class Worldgen {

@Config.Comment("Dead Tree Rarity")
public int wastelandTreeSpawnRate = 2;

@Config.Comment("Wasteland fires per chunk")
public int randomFirePerChunk = 1;

@Config.Comment("Wasteland ruins rarity")
public int wastelandRuinRarirty = 50;

@Config.Comment("Forest tent/treehouse/ruins rarity")
public int forestRuinRarity = 50;

@Config.Comment("Mountain ruins rarity")
public int mountainRuinRarity = 50;

@Config.Comment("Oasis rarity")
public int oasisRarity = 50;

@Config.Comment("Wasteland Top Block")
public String surfaceBlock = "minecraft:dirt";

@Config.Comment("Wasteland Fill Block")
public String fillerBlock = "minecraft:stone";

@Config.Comment("Spawn in underground bunker")
public boolean shouldSpawnBunker = true;

@Config.Comment("Enable cities")
public boolean shouldSpawnCities = true;

@Config.Comment("Allow zombies to spawn in daylight")
public boolean shouldSpawnDayZombies = true;

@Config.Comment("Allow CyberZombies from the CyberWare mod to spawn, this is only in effect if the CyberWare mod is installed")
public boolean shouldSpawnCyberZombies = true;

public Block getSurfaceBlock() {
return Block.REGISTRY.getObject(new ResourceLocation(surfaceBlock));
}

public Block getFillerBlock() {
return Block.REGISTRY.getObject(new ResourceLocation(fillerBlock));
}
}

public static class Biomes {

@Config.Comment("Should the Wasteland Mountains biome be enabled?")
public boolean wastelandMountainsEnabled = true;

@Config.Comment("Should the Wasteland Forest biome be enabled?")
public boolean wastelandForestEnabled = true;

@Config.Comment("Should the Wasteland City biome be enabled?")
public boolean wastelandCityEnabled = true;

@Config.Comment("Should the Oasis structure be enabled?")
public boolean oasisEnabled = true;

@Config.Comment({"Should Wasteland Biomes be able to spawn in the overworld?", "NOTE: Setting this to true can cause issues with other mod's structures!"})
public boolean shouldWastelandBiomesSpawnInOverworld = false;
}

public static class Loot {

@Config.Comment("Common ruins chest loot items")
public String[] ruinEasyLoot = new String[]{"minecraft:mushroom_stew,1,1", "minecraft:bread,4,1", "minecraft:wheat,2,1", "minecraft:apple,3,1", "minecraft:string,6,2", "minecraft:rotten_flesh,8,2"};

@Config.Comment("Rare ruins chest loot items")
public String[] ruinRareLoot = new String[]{"minecraft:bucket,1,1", "minecraft:cooked_porkchop,3,2", "minecraft:cooked_beef,4,1", "minecraft:feather,8,2", "minecraft:iron_ingot,3,1"};

@Config.Comment("Ruins seed chest loot items")
public String[] seedLoot = new String[]{"minecraft:wheat_seeds,8,2"};

@Config.Comment("Start bunker chest loot items")
public String[] startLoot = new String[]{"minecraft:stone_sword,1,1", "minecraft:bread,2,2", "minecraft:leather_helmet,1,1", "minecraft:leather_boots,1,1", "minecraft:cooked_chicken,3,2", "minecraft:glass_bottle,2,1"};


public ItemStack[] getLoot(String[] rawStringArray) {
ItemStack[] items = new ItemStack[rawStringArray.length];

for(int i = 0; i < rawStringArray.length; ++i) {
if(rawStringArray[i].length() > 0) {
String[] split = rawStringArray[i].split(",");
int max;
int min;
if(split.length == 3) {
max = Integer.parseInt(split[1]);
min = Integer.parseInt(split[2]);
} else {
max = 1;
min = 1;
}

int range = max - min <= 0?1:max - min;
items[i] = GameRegistry.makeItemStack(split[0], 0, (new Random()).nextInt(range) + 1, null);
}
}

return items;
}
}

@Mod.EventBusSubscriber(modid = Wasteland.MOD_ID)
private static class EventHandler {
@SubscribeEvent
public static void onConfigChangedEvent(final ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.getModID().equals(Wasteland.MOD_ID)) {
ConfigManager.sync(Wasteland.MOD_ID, Config.Type.INSTANCE);
}
}
}
}
59 changes: 0 additions & 59 deletions src/main/java/com/legacy/wasteland/config/WorldConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.legacy.wasteland.world;

import com.legacy.wasteland.WastelandEventHandler;
import com.legacy.wasteland.config.WorldConfig;
import com.legacy.wasteland.world.WastelandWorld;
import com.legacy.wasteland.config.WastelandConfig;
import com.legacy.wasteland.world.biome.decorations.BiomeDecoratorWasteland;
import java.util.List;
import java.util.Random;
Expand Down Expand Up @@ -144,7 +143,7 @@ public void setBlocksInChunk(int x, int z, ChunkPrimer primer) {
if((lvt_45_1_ += d16) > 0.0D) {
primer.setBlockState(i * 4 + k2, i2 * 8 + j2, l * 4 + l2, STONE);
} else if(i2 * 8 + j2 < this.settings.seaLevel) {
primer.setBlockState(i * 4 + k2, i2 * 8 + j2, l * 4 + l2, WorldConfig.getSurfaceBlock().getDefaultState());
primer.setBlockState(i * 4 + k2, i2 * 8 + j2, l * 4 + l2, WastelandConfig.worldgen.getSurfaceBlock().getDefaultState());
}
}

Expand Down
Loading

0 comments on commit 1991cdc

Please sign in to comment.