-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed machines breaking when network contained a security terminal
- Loading branch information
1 parent
e5b98d3
commit 98e418e
Showing
5 changed files
with
85 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/com/soliddowant/gregtechenergistics/covers/PlayerPlacedCoverBehavior.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.soliddowant.gregtechenergistics.covers; | ||
|
||
import gregtech.api.cover.CoverBehavior; | ||
import gregtech.api.cover.ICoverable; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.util.EnumFacing; | ||
|
||
public abstract class PlayerPlacedCoverBehavior extends CoverBehavior { | ||
protected EntityPlayer placingPlayer; | ||
|
||
public PlayerPlacedCoverBehavior(ICoverable coverHolder, EnumFacing attachedSide) { | ||
super(coverHolder, attachedSide); | ||
} | ||
|
||
public EntityPlayer getPlacingPlayer() { | ||
return placingPlayer; | ||
} | ||
|
||
public void setPlacingPlayer(EntityPlayer player) { | ||
this.placingPlayer = player; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...in/java/com/soliddowant/gregtechenergistics/items/behaviors/PlayerCoverPlaceBehavior.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.soliddowant.gregtechenergistics.items.behaviors; | ||
|
||
import com.soliddowant.gregtechenergistics.covers.PlayerPlacedCoverBehavior; | ||
import gregtech.api.capability.GregtechTileCapabilities; | ||
import gregtech.api.cover.CoverBehavior; | ||
import gregtech.api.cover.CoverDefinition; | ||
import gregtech.api.cover.ICoverable; | ||
import gregtech.common.items.behaviors.CoverPlaceBehavior; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.EnumActionResult; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraft.util.EnumHand; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
|
||
public class PlayerCoverPlaceBehavior extends CoverPlaceBehavior { | ||
public PlayerCoverPlaceBehavior(CoverDefinition coverDefinition) { | ||
super(coverDefinition); | ||
} | ||
|
||
@Override | ||
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { | ||
TileEntity tileEntity = world.getTileEntity(pos); | ||
ICoverable coverable = tileEntity == null ? null : tileEntity.getCapability(GregtechTileCapabilities.CAPABILITY_COVERABLE, null); | ||
if (coverable == null) | ||
return EnumActionResult.PASS; | ||
|
||
EnumFacing coverSide = ICoverable.rayTraceCoverableSide(coverable, player); | ||
if (coverable.getCoverAtSide(coverSide) != null || !coverable.canPlaceCoverOnSide(coverSide)) | ||
return EnumActionResult.PASS; | ||
|
||
if (!world.isRemote) { | ||
ItemStack itemStack = player.getHeldItem(hand); | ||
boolean successfullyPlaced = coverable.placeCoverOnSide(coverSide, itemStack, coverDefinition); | ||
if (successfullyPlaced) { | ||
if(!player.capabilities.isCreativeMode) | ||
itemStack.shrink(1); | ||
|
||
CoverBehavior placedCoverBehavior = coverable.getCoverAtSide(coverSide); | ||
if(placedCoverBehavior instanceof PlayerPlacedCoverBehavior) | ||
((PlayerPlacedCoverBehavior) placedCoverBehavior).setPlacingPlayer(player); | ||
} | ||
|
||
return successfullyPlaced ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; | ||
} | ||
|
||
return EnumActionResult.SUCCESS; | ||
} | ||
} |