aboutsummaryrefslogtreecommitdiff
path: root/src/Java
diff options
context:
space:
mode:
authorkorneel vandamme <krampus.sack.never@gmail.com>2020-02-23 20:06:54 +0100
committerkorneel vandamme <krampus.sack.never@gmail.com>2020-02-23 20:06:54 +0100
commitb0bdee4b66ba7e22f67554520abfaa986a3f47df (patch)
tree645748bdeefd2cc6bfa6f54f56d755f17c8d6813 /src/Java
parent52cec59a102e3b18f8cca75e98c2d797bac4d19f (diff)
downloadGT5-Unofficial-b0bdee4b66ba7e22f67554520abfaa986a3f47df.tar.gz
GT5-Unofficial-b0bdee4b66ba7e22f67554520abfaa986a3f47df.tar.bz2
GT5-Unofficial-b0bdee4b66ba7e22f67554520abfaa986a3f47df.zip
attempt fix for safe making all gt machine sunbreakble
Diffstat (limited to 'src/Java')
-rw-r--r--src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java42
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java29
2 files changed, 32 insertions, 39 deletions
diff --git a/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java
index cfc274a3d6..956d045b3e 100644
--- a/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java
+++ b/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java
@@ -1,20 +1,19 @@
package gtPlusPlus.core.handler.events;
+import java.util.List;
import java.util.UUID;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
-
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
-
+import net.minecraft.world.ChunkPosition;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
-import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.metatileentity.BaseMetaTileEntity;
-
import gtPlusPlus.core.util.minecraft.PlayerUtils;
import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines.GregtechMetaSafeBlockBase;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
+import net.minecraftforge.event.world.ExplosionEvent;
public class PickaxeBlockBreakEventHandler {
@SubscribeEvent
@@ -22,31 +21,54 @@ public class PickaxeBlockBreakEventHandler {
try{
final TileEntity entity = event.world.getTileEntity(event.x, event.y, event.z);
if (entity != null){
- final EntityPlayer playerInternal = event.getPlayer();
- if ((entity instanceof BaseMetaTileEntity) && !(BaseMetaPipeEntity.class.isInstance(entity))){
+ if (entity instanceof BaseMetaTileEntity) {
+ final EntityPlayer playerInternal = event.getPlayer();
final IMetaTileEntity X = ((BaseMetaTileEntity)entity).getMetaTileEntity();
- //final Block ThisBlock = X.getBaseMetaTileEntity().getBlock(event.x, event.y, event.z);
- if (X instanceof GregtechMetaSafeBlockBase){
+ if(X instanceof GregtechMetaSafeBlockBase) {
final UUID ownerUUID = ((GregtechMetaSafeBlockBase)X).ownerUUID;
final UUID accessorUUID = playerInternal.getUniqueID();
if (((GregtechMetaSafeBlockBase)X).bUnbreakable){
if (accessorUUID == ownerUUID){
PlayerUtils.messagePlayer(playerInternal, "Since you own this block, it has been destroyed.");
- event.setCanceled(false);
}
else {
- event.setCanceled(true);
PlayerUtils.messagePlayer(playerInternal, "Since you do not own this block, it has not been destroyed.");
+ event.setCanceled(true);
}
}
}
}
+
}
}
catch (final NullPointerException e) {
//System.out.print("Caught a NullPointerException involving Safe Blocks. Cause: "+e.getCause());
}
}
+
+ @SubscribeEvent
+ public void onExplode(ExplosionEvent.Detonate event) {
+ try {
+ @SuppressWarnings("unchecked")
+ List<ChunkPosition> pos = event.explosion.affectedBlockPositions;
+ for(int i = 0;i<pos.size();i++) {
+ ChunkPosition blockpos = (ChunkPosition) pos.get(i);
+ TileEntity entity = event.world.getTileEntity(blockpos.chunkPosX, blockpos.chunkPosY, blockpos.chunkPosZ);
+ if (entity != null){
+ if (entity instanceof BaseMetaTileEntity) {
+ final IMetaTileEntity X = ((BaseMetaTileEntity)entity).getMetaTileEntity();
+ if (X instanceof GregtechMetaSafeBlockBase) {
+ pos.remove(i);
+ }
+ }
+ }
+ }
+ }
+ catch (final NullPointerException e) {
+
+ }
+
+ }
@SubscribeEvent
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java
index 9f331496b7..34b3e86c70 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java
@@ -278,35 +278,6 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered
}
}
- @Override
- public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) {
- /*if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isUniversalEnergyStored(getMinimumStoredEU()) && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0 || mSuccess > 0)) {
- */
- if (aBaseMetaTileEntity.isServerSide() && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || ((aTimer % 200) == 0) || (this.mSuccess > 0))) {
- this.value_last = this.value_current;
- this.value_current = this.bUnbreakable;
- if (this.value_last != this.value_current){
- Logger.WARNING("VALUE CHANGE - Ticking for a moment.");
- if (this.bUnbreakable == true){
- //Xasda.setmTileEntity((BaseMetaTileEntity) aBaseMetaTileEntity);
- //Utils.LOG_ERROR("Safe is Indestructible.");
- this.getBaseMetaTileEntity().getBlock(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()).setResistance(Float.MAX_VALUE);
- this.getBaseMetaTileEntity().getBlock(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()).setBlockUnbreakable();
- }
- else {
- //Xasda.setmTileEntity((BaseMetaTileEntity) aBaseMetaTileEntity);
- //Utils.LOG_ERROR("Safe is not Indestructible.");
- this.getBaseMetaTileEntity().getBlock(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()).setResistance(1F);
- this.getBaseMetaTileEntity().getBlock(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()).setHardness(2);
-
- }
- }
- else {
-
- }
-
- }
- }
@Override
public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, final ItemStack aStack) {