Skip to content

Commit

Permalink
Fix stabilizer block check for Node Linker. (#32)
Browse files Browse the repository at this point in the history
* Fix stabilizer block check for Node Linker.

* Formatting
  • Loading branch information
AbdielKavash authored Apr 22, 2024
1 parent 95357da commit 123c940
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Add your dependencies here

dependencies {
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.148:dev') {transitive=false}
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.45.155:dev') {transitive=false}

compile('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compile('com.github.GTNewHorizons:CodeChickenLib:1.2.1:dev')
Expand Down
25 changes: 18 additions & 7 deletions src/main/java/tb/common/tile/TileNodeLinker.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Collection;
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
Expand Down Expand Up @@ -152,23 +153,33 @@ public void updateEntity() {
} else instability = 0;
}

// Spotless messes this initialization up very badly. It is much clearer to read this way.
// spotless:off
private static final Block STABILIZER_BLOCK =
OreDictionary.doesOreNameExist("blockIchorium") && !OreDictionary.getOres("blockIchorium").isEmpty()
? Block.getBlockFromItem(OreDictionary.getOres("blockIchorium").get(0).getItem())
: null;
// spotless:on

private boolean hasStabilizerBlock() {
return STABILIZER_BLOCK != null
&& this.worldObj.getBlock(this.xCoord, this.yCoord + 1, this.zCoord) == STABILIZER_BLOCK;
}

public boolean instabilityCheck() {
if (this.worldObj.rand.nextInt(50) <= this.instability) {
int rnd = this.worldObj.rand.nextInt(this.instability);
if (rnd == 49) {
// if a block of Ichorium is above dont explode or harm node
if (!OreDictionary.doesOreNameExist("blockIchorium")
|| (OreDictionary.getOres("blockIchorium") != null && !(OreDictionary.getOres("blockIchorium")
.contains(new ItemStack(this.worldObj.getBlock(this.xCoord, this.yCoord + 1, this.zCoord))))))
if (!hasStabilizerBlock()) {
instability -= explodeTransmitter();
}
} else {
if (rnd >= 45) {
// if a block of Ichorium is above dont explode or harm node
if (!OreDictionary.doesOreNameExist("blockIchorium")
|| (OreDictionary.getOres("blockIchorium") != null && !(OreDictionary.getOres("blockIchorium")
.contains(
new ItemStack(this.worldObj.getBlock(this.xCoord, this.yCoord + 1, this.zCoord))))))
if (!hasStabilizerBlock()) {
instability -= harmTransmitter();
}
} else {
if (rnd >= 31) {
instability -= wisp();
Expand Down

0 comments on commit 123c940

Please sign in to comment.