Skip to content

Commit

Permalink
Ring of loki improvement (VazkiiMods#25)
Browse files Browse the repository at this point in the history
* fix deps

* make ring trigger block activation

* remove runtime dep

* AdReSs ReVieW
  • Loading branch information
LewisSaber committed Apr 24, 2023
1 parent 391406e commit 876b183
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
7 changes: 4 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ dependencies {

compile('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')

compileOnly('com.github.GTNewHorizons:Railcraft:9.13.6:api') {transitive=false}
compileOnly('com.github.GTNewHorizons:Railcraft:9.14.0:api') {transitive=false}
compileOnly('com.github.GTNewHorizons:StorageDrawers:1.11.13-GTNH:api') {transitive=false}
compileOnly('com.github.GTNewHorizons:ForgeMultipart:1.2.7:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.2.7-GTNH:dev')
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.3.45-GTNH:dev')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.27:api') {transitive=false}
compile('com.github.GTNewHorizons:GTNHLib:0.0.4:dev')
compile('com.github.GTNewHorizons:GTNHLib:0.0.13:dev')

compileOnly('curse.maven:cofh-lib-220333:2388748')
compileOnly('curse.maven:minefactory-reloaded-66672:2366150')
}

27 changes: 24 additions & 3 deletions src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import java.util.ArrayList;
import java.util.List;

import com.gtnewhorizon.gtnhlib.GTNHLib;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
Expand Down Expand Up @@ -62,6 +61,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
private static final String TAG_Y_ORIGIN = "yOrigin";
private static final String TAG_Z_ORIGIN = "zOrigin";
private static final String TAG_MODE = "mode";
private Boolean recursion = false;

public ItemLokiRing() {
super(LibItemNames.LOKI_RING);
Expand All @@ -70,6 +70,8 @@ public ItemLokiRing() {

@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event) {
if(recursion) return;

EntityPlayer player = event.entityPlayer;
ItemStack lokiRing = getLokiRing(player);
if(lokiRing == null || player.worldObj.isRemote)
Expand Down Expand Up @@ -126,19 +128,38 @@ public void onPlayerInteract(PlayerInteractEvent event) {
}
}
} else if(heldItemStack != null && event.action == Action.RIGHT_CLICK_BLOCK && lookPos != null && isRingEnabled(lokiRing)) {
recursion = true;

for(ChunkCoordinates cursor : cursors) {
int x = lookPos.blockX + cursor.posX;
int y = lookPos.blockY + cursor.posY;
int z = lookPos.blockZ + cursor.posZ;
Item item = heldItemStack.getItem();
if(!player.worldObj.isAirBlock(x, y, z) && ManaItemHandler.requestManaExact(lokiRing, player, cost, true)) {
item.onItemUse(player.capabilities.isCreativeMode ? heldItemStack.copy() : heldItemStack, player, player.worldObj, x, y, z, lookPos.sideHit, (float) lookPos.hitVec.xCoord - x, (float) lookPos.hitVec.yCoord - y, (float) lookPos.hitVec.zCoord - z);
if(heldItemStack.stackSize == 0) {

float hitX = (float) (lookPos.hitVec.xCoord - lookPos.blockX);
float hitY = (float) (lookPos.hitVec.yCoord - lookPos.blockY);
float hitZ = (float) (lookPos.hitVec.zCoord - lookPos.blockZ);

Block markedBlock = player.worldObj.getBlock(x, y, z);
Boolean wasActivated = markedBlock.onBlockActivated(player.worldObj, x, y, z, player, lookPos.sideHit, hitX,hitY,hitZ);

if (heldItemStack.stackSize == 0 ) {
event.setCanceled(true);
recursion = false;
return;
}
if (!wasActivated) {
item.onItemUse(player.capabilities.isCreativeMode ? heldItemStack.copy() : heldItemStack, player, player.worldObj, x, y, z, lookPos.sideHit, (float) lookPos.hitVec.xCoord - x, (float) lookPos.hitVec.yCoord - y, (float) lookPos.hitVec.zCoord - z);
if(heldItemStack.stackSize == 0) {
event.setCanceled(true);
recursion = false;
return;
}
}
}
}
recursion = false;
}
}
public static void setMode(ItemStack stack, boolean state) {
Expand Down

0 comments on commit 876b183

Please sign in to comment.