Skip to content

Commit

Permalink
2.9 Update
Browse files Browse the repository at this point in the history
- Added GunpowderLib as a required dependency, refactored some codes to call methods from new library

- Requires Forge 2816 or above for a change in the item rarity system

- Added support for Ender IO Endergy, along with 6 new exchangers (Crude steel, Energetic silver, Vivid alloy, Crystalline alloy, Melodic alloy and Stellar alloy)

- Added localized texts for harvest level 5, 6 and 7

- Adjusted energy costs for most of the powered exchangers, a manual config reset is required in order to receive the changes

- Added support for Better With Mods Hardcore Strata, exchangers will now display an error message when the harvest level is lower than the strata stones instead of bypassing it, closes #57

- (Hopefully) Fixed exchangers attepting to pull blocks out of Draconic Evolution tools when a junk filter is applied, closes #58

- Added a new directional placement mode, allows exchangers to ignore their saved block states and swap blocks based on player facing direction instead (by default it's disabled, toggle using the apostrophe key), closes #59

- Rewritten codes for handling silk touch blocks upon exchanging, fixed issues with exchangers giving out incorrect blocks that are different from the target, closes #60 and #61
  • Loading branch information
JackyyTV committed Mar 17, 2020
1 parent 03a9336 commit 5bc87a4
Show file tree
Hide file tree
Showing 111 changed files with 1,703 additions and 871 deletions.
15 changes: 7 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ buildscript {
repositories {
jcenter()
maven { url = "http://files.minecraftforge.net/maven" }
maven { url = "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath 'com.wynprice.cursemaven:CurseMaven:2.+'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'com.wynprice.cursemaven'

version = "${mc_version}-${mod_version}"
group = "jackyy.exchangers"
Expand Down Expand Up @@ -44,8 +47,11 @@ repositories {

dependencies {
deobfCompile "mezz.jei:jei_1.12.2:+"
deobfCompile "mcp.mobius.waila:Hwyla:+"
deobfCompile "mcp.mobius.waila:Hwyla:1.8.26-B41_1.12.2"
deobfCompile "cofh:RedstoneFlux:1.12-2.+:universal"
deobfCompile "cofh:CoFHCore:1.12.2-4.+:universal"
deobfCompile "curse.maven:gunpowderlib:2852431"
deobfCompile "curse.maven:better-with-mods:2885221"
}

processResources {
Expand All @@ -58,13 +64,6 @@ processResources {
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
rename '(.+_at.cfg)', 'META-INF/$1'
}

jar {
manifest {
attributes 'FMLAT': 'exchangers_at.cfg'
}
}

task signJar(type: SignJar, dependsOn: reobfJar) {
Expand Down
6 changes: 2 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# 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=-Xmx4G
mc_version=1.12.2
forge_version=1.12.2-14.23.4.2760
mod_version=2.8
forge_version=1.12.2-14.23.5.2847
mod_version=2.9
mappings_version=stable_39
41 changes: 4 additions & 37 deletions src/main/java/jackyy/exchangers/Exchangers.java
Original file line number Diff line number Diff line change
@@ -1,51 +1,18 @@
package jackyy.exchangers;

import jackyy.exchangers.proxy.CommonProxy;
import jackyy.exchangers.registry.ModItems;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.util.EnumHelper;
import jackyy.exchangers.util.Reference;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@Mod(modid = Exchangers.MODID, version = Exchangers.VERSION, name = Exchangers.MODNAME, dependencies = Exchangers.DEPENDS, certificateFingerprint = "@FINGERPRINT@", acceptedMinecraftVersions = Exchangers.MCVERSION, useMetadata = true)
@Mod(modid = Reference.MODID, version = Reference.VERSION, name = Reference.MODNAME, dependencies = Reference.DEPENDS, certificateFingerprint = "@FINGERPRINT@", acceptedMinecraftVersions = Reference.MCVERSION, useMetadata = true)
public class Exchangers {

public static final String VERSION = "1.12.2-2.8";
public static final String MCVERSION = "[1.12,1.13)";
public static final String MODID = "exchangers";
public static final String MODNAME = "Exchangers";
public static final String EIO = "enderio";
public static final String TE = "thermalexpansion";
public static final String MEK = "mekanism";
public static final String IE = "immersiveengineering";
public static final String DEPENDS
= "after:redstoneflux;"
+ "after:" + EIO + ";"
+ "after:cofhcore;"
+ "after:thermalfoundation;"
+ "after:" + TE + ";"
+ "after:" + MEK + ";"
+ "after:" + IE + ";";
public static final CreativeTabs TAB = new CreativeTabs(MODID) {
@Override
public ItemStack createIcon() {
return new ItemStack(ModItems.obsidianExchanger);
}
};
public static final EnumRarity TIER_1 = EnumHelper.addRarity("TIER_1", TextFormatting.GREEN, "Tier 1");

public static Logger logger = LogManager.getLogger(MODNAME);

@SidedProxy(serverSide = "jackyy.exchangers.proxy.CommonProxy", clientSide = "jackyy.exchangers.proxy.ClientProxy")
@SidedProxy(serverSide = Reference.COMMON_PROXY, clientSide = Reference.CLIENT_PROXY)
public static CommonProxy proxy;

@Mod.EventHandler
Expand All @@ -65,7 +32,7 @@ public void postInit(FMLPostInitializationEvent e) {

@Mod.EventHandler
public void onFingerprintViolation(FMLFingerprintViolationEvent event) {
logger.warn("Invalid fingerprint detected! The file " + event.getSource().getName() + " may have been modified. This will NOT be supported by the mod author!");
Reference.LOGGER.warn("Invalid fingerprint detected! The file " + event.getSource().getName() + " may have been modified. This will NOT be supported by the mod author!");
}

}
77 changes: 0 additions & 77 deletions src/main/java/jackyy/exchangers/client/CapeBufferDownload.java

This file was deleted.

12 changes: 12 additions & 0 deletions src/main/java/jackyy/exchangers/client/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,22 @@ public boolean conflicts(IKeyConflictContext other) {
}
}, Keyboard.KEY_PERIOD, "key.categories.exchangers");

public static final KeyBinding Directional_PLACEMENT_KEY = new KeyBinding("key.exchanger_directional_placement", new IKeyConflictContext() {
@Override
public boolean isActive() {
return KeyConflictContext.IN_GAME.isActive();
}
@Override
public boolean conflicts(IKeyConflictContext other) {
return other == this || KeyConflictContext.IN_GAME.isActive();
}
}, Keyboard.KEY_APOSTROPHE, "key.categories.exchangers");

public static void init() {
ClientRegistry.registerKeyBinding(RANGE_SWITCH_KEY);
ClientRegistry.registerKeyBinding(MODE_SWITCH_KEY);
ClientRegistry.registerKeyBinding(FORCE_DROP_ITEMS_KEY);
ClientRegistry.registerKeyBinding(Directional_PLACEMENT_KEY);
}

}
63 changes: 8 additions & 55 deletions src/main/java/jackyy/exchangers/handler/ClientEventsHandler.java
Original file line number Diff line number Diff line change
@@ -1,87 +1,39 @@
package jackyy.exchangers.handler;

import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import jackyy.exchangers.client.CapeBufferDownload;
import jackyy.exchangers.client.Keys;
import jackyy.exchangers.handler.network.PacketHandler;
import jackyy.exchangers.handler.network.PacketSwitchMode;
import jackyy.exchangers.handler.network.PacketSwitchRange;
import jackyy.exchangers.handler.network.PacketToggleForceDropItemsMode;
import jackyy.exchangers.handler.network.*;
import jackyy.exchangers.item.ItemExchangerBase;
import jackyy.exchangers.item.special.ItemCreativeExchanger;
import jackyy.gunpowderlib.helper.NBTHelper;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.network.NetworkPlayerInfo;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

@SideOnly(Side.CLIENT)
public class ClientEventsHandler {

private static Minecraft mc = FMLClientHandler.instance().getClient();
private static final String DEV_CAPE = "https://jackyytv.github.io/imgs/mc_mods/exchangers/capes/cape_dev.png";

private Map<String, CapeBufferDownload> buffer = new HashMap<>();

@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
if (event.phase == TickEvent.Phase.START) {
if (mc.world != null && mc.player != null && !mc.isGamePaused()) {
for (EntityPlayer entityPlayer : mc.world.playerEntities) {
if (entityPlayer instanceof AbstractClientPlayer) {
AbstractClientPlayer player = (AbstractClientPlayer) entityPlayer;
if (player.getUniqueID().equals(UUID.fromString("38de3769-70fa-441c-89e8-67280f3068a0"))) {
CapeBufferDownload download = buffer.get(player.getName());
if (download == null) {
download = new CapeBufferDownload(player.getName(), DEV_CAPE);
buffer.put(player.getName(), download);
download.start();
} else {
if (!download.downloaded) {
continue;
}
setCape(player, download.getResourceLocation());
}
}
}
}
}
}
}

private static void setCape(AbstractClientPlayer player, ResourceLocation cape) {
NetworkPlayerInfo info = player.getPlayerInfo();
if (info != null) {
info.playerTextures.put(MinecraftProfileTexture.Type.CAPE, cape);
}
}
private static Minecraft mc = Minecraft.getMinecraft();

@SubscribeEvent
public void onGameOverlayRender(RenderGameOverlayEvent event) {
Expand All @@ -101,7 +53,7 @@ public void onGameOverlayRender(RenderGameOverlayEvent event) {

ItemStack stack = player.getHeldItemMainhand();

if (stack.getTagCompound() != null) {
if (NBTHelper.getTag(stack) != null) {
ScaledResolution scaledresolution = new ScaledResolution(mc);
int w = scaledresolution.getScaledWidth();
int h = scaledresolution.getScaledHeight();
Expand All @@ -110,7 +62,7 @@ public void onGameOverlayRender(RenderGameOverlayEvent event) {
GlStateManager.disableDepth();
GlStateManager.disableRescaleNormal();

String exchangeMode = ExchangerHandler.modeSwitchList[stack.getTagCompound().getInteger("range")];
String exchangeMode = ExchangerHandler.modeSwitchList[NBTHelper.getTag(stack).getInteger("range")];
double scale = exchangeMode.length() > 2 ? 1 : 1;
double swidth = mc.fontRenderer.getStringWidth(exchangeMode) * scale;
GlStateManager.translate((w / 2 - 2 - swidth), h / 2 - 4, 0);
Expand All @@ -125,7 +77,6 @@ public void onGameOverlayRender(RenderGameOverlayEvent event) {

@SubscribeEvent @SuppressWarnings("deprecation")
public void renderWorldLastEvent(RenderWorldLastEvent event) {
Minecraft mc = Minecraft.getMinecraft();
RayTraceResult mouseOver = mc.objectMouseOver;
EntityPlayerSP player = mc.player;
World world = player.getEntityWorld();
Expand All @@ -152,7 +103,7 @@ public void renderWorldLastEvent(RenderWorldLastEvent event) {
GlStateManager.disableDepth();

for (BlockPos coordinate : coordinates) {
IBlockState exState = NBTUtil.readBlockState(ExchangerHandler.getTagCompound(stack).getCompoundTag("blockstate"));
IBlockState exState = NBTUtil.readBlockState(NBTHelper.getTag(stack).getCompoundTag("blockstate"));
float blockHardness = block.getBlockHardness(state, world, coordinate);
if (world.isAirBlock(coordinate) || exState == state) {
continue;
Expand Down Expand Up @@ -221,6 +172,8 @@ public void onKeyInput(InputEvent.KeyInputEvent event) {
PacketHandler.INSTANCE.sendToServer(new PacketSwitchMode());
} else if (Keys.FORCE_DROP_ITEMS_KEY.isPressed()) {
PacketHandler.INSTANCE.sendToServer(new PacketToggleForceDropItemsMode());
} else if (Keys.Directional_PLACEMENT_KEY.isPressed()) {
PacketHandler.INSTANCE.sendToServer(new PacketToggleDirectionalPlacement());
}
}

Expand Down
Loading

0 comments on commit 5bc87a4

Please sign in to comment.