Skip to content

Commit

Permalink
1.9 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
JackyyTV committed Sep 26, 2018
1 parent c71f19e commit 7037a6a
Show file tree
Hide file tree
Showing 30 changed files with 554 additions and 205 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Submit any bug reports / suggestions via [issue tracker](https://github.com/Jack
- Twitter - [@JackyyTV](https://twitter.com/JackyyTV)
- Discord - Jacky#1234
- Twitch - [Jackyy](https://www.twitch.tv/jackyy)
- Reddit - [Jacky1356400](https://www.reddit.com/message/compose/?to=Jacky1356400)
- Reddit - [JackyyTV](https://www.reddit.com/message/compose/?to=JackyyTV)

---

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
org.gradle.jvmargs=-Xmx4G
mc_version=1.11.2
forge_version=1.11.2-13.20.1.2530
mod_version=1.8.3
mod_version=1.9
mappings_version=stable_32
2 changes: 1 addition & 1 deletion src/main/java/jackyy/exchangers/Exchangers.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@Mod(modid = Exchangers.MODID, version = Exchangers.VERSION, name = Exchangers.MODNAME, dependencies = Exchangers.DEPENDS, certificateFingerprint = "@FINGERPRINT@", acceptedMinecraftVersions = Exchangers.MCVERSION, useMetadata = true)
public class Exchangers {

public static final String VERSION = "1.11.2-1.8.3";
public static final String VERSION = "1.11.2-1.9";
public static final String MCVERSION = "[1.11,1.12)";
public static final String MODID = "exchangers";
public static final String MODNAME = "Exchangers";
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/jackyy/exchangers/client/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@SideOnly(Side.CLIENT)
public class Keys {

public static final KeyBinding MODE_KEY = new KeyBinding("key.exchanger_mode", new IKeyConflictContext() {
public static final KeyBinding RANGE_SWITCH_KEY = new KeyBinding("key.exchanger_range_switch", new IKeyConflictContext() {
@Override
public boolean isActive() {
return KeyConflictContext.IN_GAME.isActive();
Expand All @@ -22,6 +22,17 @@ public boolean conflicts(IKeyConflictContext other) {
}
}, Keyboard.KEY_COMMA, "key.categories.exchangers");

public static final KeyBinding MODE_SWITCH_KEY = new KeyBinding("key.exchanger_mode_switch", 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_SEMICOLON, "key.categories.exchangers");

public static final KeyBinding FORCE_DROP_ITEMS_KEY = new KeyBinding("key.exchanger_force_drop_items", new IKeyConflictContext() {
@Override
public boolean isActive() {
Expand All @@ -34,7 +45,8 @@ public boolean conflicts(IKeyConflictContext other) {
}, Keyboard.KEY_PERIOD, "key.categories.exchangers");

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

Expand Down
30 changes: 15 additions & 15 deletions src/main/java/jackyy/exchangers/handler/ClientEventsHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
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.PacketToggleMode;
import jackyy.exchangers.item.ItemExchangerBase;
import jackyy.exchangers.item.special.ItemCreativeExchanger;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
Expand Down Expand Up @@ -110,7 +110,7 @@ public void onGameOverlayRender(RenderGameOverlayEvent event) {
GlStateManager.disableDepth();
GlStateManager.disableRescaleNormal();

String exchangeMode = ExchangerHandler.modeSwitchList[stack.getTagCompound().getInteger("mode")];
String exchangeMode = ExchangerHandler.modeSwitchList[stack.getTagCompound().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 @@ -132,11 +132,11 @@ public void renderWorldLastEvent(RenderWorldLastEvent event) {
if (mouseOver != null && mouseOver.sideHit != null) {
IBlockState state = world.getBlockState(mouseOver.getBlockPos());
Block block = state.getBlock();
if (block.getMaterial(state) != Material.AIR) {
if (!block.isAir(state, world, mouseOver.getBlockPos())) {
ItemStack stack = player.getHeldItemMainhand();
float partialTicks = event.getPartialTicks();
if (!stack.isEmpty() && stack.getItem() instanceof ItemExchangerBase && stack.getTagCompound() != null && mouseOver.sideHit != null) {
Set<BlockPos> coordinates = ExchangerHandler.findSuitableBlocks(stack, player.getEntityWorld(), mouseOver.sideHit, mouseOver.getBlockPos(), block, block.getMetaFromState(state));
Set<BlockPos> coordinates = ExchangerHandler.findSuitableBlocks(stack, player.getEntityWorld(), player, mouseOver.sideHit, mouseOver.getBlockPos(), state);
double offsetX = player.prevPosX + (player.posX - player.prevPosX) * (double) partialTicks;
double offsetY = player.prevPosY + (player.posY - player.prevPosY) * (double) partialTicks;
double offsetZ = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) partialTicks;
Expand All @@ -152,11 +152,9 @@ public void renderWorldLastEvent(RenderWorldLastEvent event) {
GlStateManager.disableDepth();

for (BlockPos coordinate : coordinates) {
String exId = ExchangerHandler.getTagCompound(stack).getString("block");
IBlockState exState = NBTUtil.readBlockState(ExchangerHandler.getTagCompound(stack).getCompoundTag("blockstate"));
Block exBlock = Block.getBlockFromName(exId);
float blockHardness = block.getBlockHardness(state, world, coordinate);
if (world.isAirBlock(coordinate) || (exBlock == block && exState == state)) {
if (world.isAirBlock(coordinate) || exState == state) {
continue;
}
double renderX = coordinate.getX() - offsetX;
Expand All @@ -167,9 +165,10 @@ public void renderWorldLastEvent(RenderWorldLastEvent event) {
float g = 1.0f;
float b = 1.0f;
float a = 1.0f;
if ((player.isSneaking() &&
((world.getTileEntity(coordinate) != null && !ExchangerHandler.isWhitelisted(world, coordinate))
|| (!(stack.getItem() instanceof ItemCreativeExchanger) && blockHardness < -0.1f)))) {
if ((player.isSneaking()
&& ((world.getTileEntity(coordinate) != null && !ExchangerHandler.isWhitelisted(world, coordinate))
|| ExchangerHandler.isBlacklisted(world, coordinate)
|| (!(stack.getItem() instanceof ItemCreativeExchanger) && blockHardness < -0.1f)))) {
r = 1.0f;
g = 0.1f;
b = 0.1f;
Expand Down Expand Up @@ -216,10 +215,11 @@ public void renderWorldLastEvent(RenderWorldLastEvent event) {

@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
if (Keys.MODE_KEY.isPressed()) {
PacketHandler.INSTANCE.sendToServer(new PacketToggleMode());
}
if (Keys.FORCE_DROP_ITEMS_KEY.isPressed()) {
if (Keys.RANGE_SWITCH_KEY.isPressed()) {
PacketHandler.INSTANCE.sendToServer(new PacketSwitchRange());
} else if (Keys.MODE_SWITCH_KEY.isPressed()) {
PacketHandler.INSTANCE.sendToServer(new PacketSwitchMode());
} else if (Keys.FORCE_DROP_ITEMS_KEY.isPressed()) {
PacketHandler.INSTANCE.sendToServer(new PacketToggleForceDropItemsMode());
}
}
Expand Down
Loading

0 comments on commit 7037a6a

Please sign in to comment.