Skip to content

Commit

Permalink
Backport
Browse files Browse the repository at this point in the history
- Backported some stuff from 1.12
- Updated Gradle and mappings
  • Loading branch information
Jacky1356400 committed Jul 9, 2017
1 parent 241bb0d commit 521679b
Show file tree
Hide file tree
Showing 37 changed files with 277 additions and 217 deletions.
68 changes: 27 additions & 41 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,56 @@ buildscript {
}
}
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.

//Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup.

version = "${mc_version}-${mod_version}"
group = "me.jacky1356400.exchangers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
group= "me.jacky1356400.exchangers"
archivesBaseName = "Exchangers"

sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly.
sourceCompatibility = targetCompatibility = "1.8"
compileJava {
sourceCompatibility = targetCompatibility = "1.8"
}

minecraft {
version = "${mc_version}-${forge_version}"
runDir = "run"

// 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 always work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_${mappings_version}"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
mappings = "${mappings_version}"
}

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

// the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
//provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

// the deobf configurations: 'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
// except that these dependencies get remapped to your current MCP mappings
//deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
//deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'

// for more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
repositories {
maven {
url "http://dvs1.progwml6.com/files/maven"
}
maven {
url "http://maven.epoxide.xyz"
}
maven {
url "http://maven.amadornes.com/"
}
maven {
url "http://tehnut.info/maven"
}
}

dependencies {
compile files('libs/')
deobfCompile "mezz.jei:jei_1.11.2:4.5.0.289:api"
runtime "mezz.jei:jei_1.11.2:4.5.0.289"
deobfCompile "mcp.mobius.waila:Hwyla:1.8.15-B29_1.11:api"
runtime "mcp.mobius.waila:Hwyla:1.8.15-B29_1.11"
}

processResources {
// this will ensure that this task is redone when the versions change.
processResources
{
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version

// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'

// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version
}

// copy everything else except the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}

8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.jvmargs=-Xmx4G
mc_version=1.11.2
forge_version=13.20.0.2315
mod_version=1.1
mappings_version=20161220
forge_version=13.20.1.2393
mod_version=1.2
mappings_version=snapshot_20170612
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-bin.zip
227 changes: 137 additions & 90 deletions src/main/java/me/jacky1356400/exchangers/Config.java

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/java/me/jacky1356400/exchangers/Exchangers.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@Mod(modid = Exchangers.MODID, version = Exchangers.VERSION, name = Exchangers.MODNAME, dependencies = Exchangers.DEPENDS, useMetadata = true)
public class Exchangers {

public static final String VERSION = "1.11.2-1.1";
public static final String VERSION = "1.11.2-1.2";
public static final String MODID = "exchangers";
public static final String MODNAME = "Exchangers";
public static final String PREFIX = MODID + ".";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,9 @@ public static void initSpecialBlockLists() {
}
}

softBlocks.add(Blocks.SNOW);
softBlocks.add(Blocks.SNOW_LAYER);
softBlocks.add(Blocks.REDSTONE_WIRE);
softBlocks.add(Blocks.TRIPWIRE);
softBlocks.add(Blocks.VINE);
softBlocks.add(Blocks.FIRE);
softBlocks.add(Blocks.AIR);
Expand Down Expand Up @@ -462,14 +464,15 @@ public static String getBlockName(Block block, int meta) {
return s.getDisplayName();
}

@SuppressWarnings("deprecation")
public static boolean exchangeBlocks(ItemStack stack, EntityPlayer player, World world, BlockPos pos,
EnumFacing facing) {
Block newBlock = Block.getBlockFromName(stack.getTagCompound().getString("BlockName"));
int newMeta = stack.getTagCompound().getInteger("BlockData");

if (newBlock == null)
return false;
world.theProfiler.startSection("Exchangers-Building/Queueing");
world.profiler.startSection("Exchangers-Building/Queueing");

IBlockState newState = newBlock.getStateFromMeta(newMeta);
List<BlockPos> toExchange = getBlocksToExchange(stack, pos, world, facing);
Expand Down Expand Up @@ -507,52 +510,52 @@ public static boolean exchangeBlocks(ItemStack stack, EntityPlayer player, World
stack.damageItem(1, player);
}
//Ender IO Exchangers
if (stack.getItem() instanceof ItemConductiveIronExchanger && stack.getTagCompound().getInteger("Energy") >= Config.conductiveIronExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.conductiveIronExchangerPerBlockRF);
if (stack.getItem() instanceof ItemConductiveIronExchanger && stack.getTagCompound().getInteger("Energy") >= Config.conductivePerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.conductivePerBlockUse);
}
if (stack.getItem() instanceof ItemPulsatingIronExchanger && stack.getTagCompound().getInteger("Energy") >= Config.pulsatingIronExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.pulsatingIronExchangerPerBlockRF);
if (stack.getItem() instanceof ItemPulsatingIronExchanger && stack.getTagCompound().getInteger("Energy") >= Config.pulsatingPerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.pulsatingPerBlockUse);
}
if (stack.getItem() instanceof ItemElectricalSteelExchanger && stack.getTagCompound().getInteger("Energy") >= Config.electricalSteelExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.electricalSteelExchangerPerBlockRF);
if (stack.getItem() instanceof ItemElectricalSteelExchanger && stack.getTagCompound().getInteger("Energy") >= Config.electricalSteelPerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.electricalSteelPerBlockUse);
}
if (stack.getItem() instanceof ItemEnergeticExchanger && stack.getTagCompound().getInteger("Energy") >= Config.energeticExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.energeticExchangerPerBlockRF);
if (stack.getItem() instanceof ItemEnergeticExchanger && stack.getTagCompound().getInteger("Energy") >= Config.energeticPerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.energeticPerBlockUse);
}
if (stack.getItem() instanceof ItemDarkSteelExchanger && stack.getTagCompound().getInteger("Energy") >= Config.darkSteelExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.darkSteelExchangerPerBlockRF);
if (stack.getItem() instanceof ItemDarkSteelExchanger && stack.getTagCompound().getInteger("Energy") >= Config.darkSteelPerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.darkSteelPerBlockUse);
}
if (stack.getItem() instanceof ItemVibrantExchanger && stack.getTagCompound().getInteger("Energy") >= Config.vibrantExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.vibrantExchangerPerBlockRF);
if (stack.getItem() instanceof ItemVibrantExchanger && stack.getTagCompound().getInteger("Energy") >= Config.vibrantPerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.vibrantPerBlockUse);
}
//Thermal Expansion Exchangers
if (stack.getItem() instanceof ItemLeadstoneExchanger && stack.getTagCompound().getInteger("Energy") >= Config.leadstoneExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.leadstoneExchangerPerBlockRF);
if (stack.getItem() instanceof ItemLeadstoneExchanger && stack.getTagCompound().getInteger("Energy") >= Config.leadstonePerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.leadstonePerBlockUse);
}
if (stack.getItem() instanceof ItemHardenedExchanger && stack.getTagCompound().getInteger("Energy") >= Config.hardenedExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.hardenedExchangerPerBlockRF);
if (stack.getItem() instanceof ItemHardenedExchanger && stack.getTagCompound().getInteger("Energy") >= Config.hardenedPerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.hardenedPerBlockUse);
}
if (stack.getItem() instanceof ItemReinforcedExchanger && stack.getTagCompound().getInteger("Energy") >= Config.reinforcedExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.reinforcedExchangerPerBlockRF);
if (stack.getItem() instanceof ItemReinforcedExchanger && stack.getTagCompound().getInteger("Energy") >= Config.reinforcedPerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.reinforcedPerBlockUse);
}
if (stack.getItem() instanceof ItemSignalumExchanger && stack.getTagCompound().getInteger("Energy") >= Config.signalumExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.signalumExchangerPerBlockRF);
if (stack.getItem() instanceof ItemSignalumExchanger && stack.getTagCompound().getInteger("Energy") >= Config.signalumPerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.signalumPerBlockUse);
}
if (stack.getItem() instanceof ItemResonantExchanger && stack.getTagCompound().getInteger("Energy") >= Config.resonantExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.resonantExchangerPerBlockRF);
if (stack.getItem() instanceof ItemResonantExchanger && stack.getTagCompound().getInteger("Energy") >= Config.resonantPerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.resonantPerBlockUse);
}
//Mekanism Exchangers
if (stack.getItem() instanceof ItemBasicExchanger && stack.getTagCompound().getInteger("Energy") >= Config.basicExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.basicExchangerPerBlockRF);
if (stack.getItem() instanceof ItemBasicExchanger && stack.getTagCompound().getInteger("Energy") >= Config.basicPerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.basicPerBlockUse);
}
if (stack.getItem() instanceof ItemAdvancedExchanger && stack.getTagCompound().getInteger("Energy") >= Config.advancedExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.advancedExchangerPerBlockRF);
if (stack.getItem() instanceof ItemAdvancedExchanger && stack.getTagCompound().getInteger("Energy") >= Config.advancedPerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.advancedPerBlockUse);
}
if (stack.getItem() instanceof ItemEliteExchanger && stack.getTagCompound().getInteger("Energy") >= Config.eliteExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.eliteExchangerPerBlockRF);
if (stack.getItem() instanceof ItemEliteExchanger && stack.getTagCompound().getInteger("Energy") >= Config.elitePerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.elitePerBlockUse);
}
if (stack.getItem() instanceof ItemUltimateExchanger && stack.getTagCompound().getInteger("Energy") >= Config.ultimateExchangerPerBlockRF) {
stack.getTagCompound().setInteger("Energy", energy - Config.ultimateExchangerPerBlockRF);
if (stack.getItem() instanceof ItemUltimateExchanger && stack.getTagCompound().getInteger("Energy") >= Config.ultimatePerBlockUse) {
stack.getTagCompound().setInteger("Energy", energy - Config.ultimatePerBlockUse);
}
}
}
Expand All @@ -561,7 +564,7 @@ public static boolean exchangeBlocks(ItemStack stack, EntityPlayer player, World
}
}
}
world.theProfiler.endSection();
world.profiler.endSection();

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ public void onGameOverlayRender(RenderGameOverlayEvent event) {
GL11.glDisable(GL11.GL_LIGHTING);

String am = Integer.toString(this.lastExchangeSourceCount);
if (!player.capabilities.isCreativeMode) drawItemQuantity(mc.fontRendererObj, xOffset+4, yOffset+2 , am);
else drawItemQuantity(mc.fontRendererObj, xOffset+2, yOffset+1 , "Inf");
if (!player.capabilities.isCreativeMode) drawItemQuantity(mc.fontRenderer, xOffset+4, yOffset+2 , am);
else drawItemQuantity(mc.fontRenderer, xOffset+2, yOffset+1 , "Inf");
String exchangeMode;
exchangeMode = new String(modeSwitchList[exchangerStack.getTagCompound().getInteger("ExchangeMode")]);
drawExchangeMode(mc.fontRendererObj, xOffset+1, yOffset+2 , exchangeMode);
drawExchangeMode(mc.fontRenderer, xOffset+1, yOffset+2 , exchangeMode);

net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ private void exchangeTick(World world) {

if (queue == null || queue.size() == 0) return;

world.theProfiler.startSection("Exchangers-Exchanging");
world.profiler.startSection("Exchangers-Exchanging");
List<Exchange> queueList = new ArrayList<Exchange>(queue);
Exchange exchange = queueList.get(0);

world.destroyBlock(exchange.pos, false);
world.setBlockState(exchange.pos, exchange.state, 3);

queue.remove(exchange);
world.theProfiler.endSection();
world.profiler.endSection();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public PacketToggleMode() { }

@Override
public IMessage onMessage(PacketToggleMode message, MessageContext context) {
EntityPlayerMP playerMP = context.getServerHandler().playerEntity;
EntityPlayerMP playerMP = context.getServerHandler().player;
ItemStack heldItem = playerMP.getHeldItemMainhand();
if (heldItem != null && heldItem.getItem() instanceof ExchangerHandler) {
ExchangerHandler exchanger = (ExchangerHandler) (heldItem.getItem());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static String localize(String unlocalized, Object... args) {
return localize(unlocalized, true, args);
}

@SuppressWarnings("deprecation")
public static String localize(String unlocalized, boolean prefix, Object... args) {
String toLocalize = (prefix ? Exchangers.PREFIX : "") + unlocalized;
if(args != null && args.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
package me.jacky1356400.exchangers.item;

import me.jacky1356400.exchangers.handler.ExchangerHandler;
import me.jacky1356400.exchangers.helper.StringHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

import java.util.List;

import static me.jacky1356400.exchangers.helper.StringHelper.localize;

public class ItemExchangerBase extends ExchangerHandler {

public boolean showDurabilityBar(ItemStack stack) {
return stack.isItemDamaged();
}

public boolean isPowered() {
return false;
}

@Override
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean bool) {
super.addInformation(stack, player, tooltip, bool);
if (!isPowered()){
tooltip.add(StringHelper.formatNumber(stack.getMaxDamage() - stack.getItemDamage()) + " / " + StringHelper.formatNumber(stack.getMaxDamage()) + " " + localize("tooltip.durability"));
}
}

}
Loading

0 comments on commit 521679b

Please sign in to comment.