Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ sourceSets.main {
compileClasspath += files("lib")
java.srcDirs "src/base", "src/mod"
resources.srcDirs "src/resources"
output.resourcesDir = output.classesDir
}

processResources {
Expand Down
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Tue Nov 12 17:22:07 CET 2019
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
8 changes: 4 additions & 4 deletions src/mod/gcewing/sg/SGCraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@
import gcewing.sg.generator.GeneratorAddressRegistry;
import gcewing.sg.interfaces.IIntegration;
import gcewing.sg.interfaces.SoundSource;
import gcewing.sg.item.SGChevronUpgradeItem;
import gcewing.sg.item.SGIrisUpgradeItem;
import gcewing.sg.item.SGPegasusUpgradeItem;
import gcewing.sg.item.SGRingItem;
import gcewing.sg.item.*;
import gcewing.sg.network.GuiNetworkHandler;
import gcewing.sg.network.SGChannel;
import gcewing.sg.generator.NaquadahOreWorldGen;
Expand Down Expand Up @@ -125,6 +122,7 @@ public class SGCraft extends BaseMod<SGCraftClient> {

public static Item naquadah, naquadahIngot, sgCoreCrystal, sgControllerCrystal, sgChevronUpgrade, sgIrisUpgrade, sgIrisBlade, pegasus_upgrade;
public static Item tollan_phase_shift_device;
public static Item admin_upgrade;

public static Block ic2PowerUnit;
public static Item ic2Capacitor;
Expand Down Expand Up @@ -312,6 +310,8 @@ protected void registerItems() {

pegasus_upgrade = addItem(new SGPegasusUpgradeItem(), "pegasus_upgrade");

admin_upgrade = addItem(new SGAdminUpgradeItem(), "admin_upgrade");

if (isModLoaded("malisiscore")) {
new GuiNetworkHandler(Info.modID+"-GUI");

Expand Down
41 changes: 39 additions & 2 deletions src/mod/gcewing/sg/block/SGBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,20 @@
import net.minecraft.util.math.*;
import net.minecraft.world.*;


public abstract class SGBlock<TE extends TileEntity> extends BaseBlock<TE> implements ISGBlock {

public SGBlock(Material material, Class<TE> teClass) {
super(material, teClass);
}

@Override
@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {

if(requiresAdminToBreak(world,pos) && ! isOperator(player)) {
return false; //Prevents the gate from being broken by non-admin when the requiresAdminToBreak field is true
}

if (!player.capabilities.isCreativeMode) {
if (!canPlayerBreakGeneratedGates(world, pos)) {
return false; // Prevents gates from being broken when we don't want them to be.
Expand All @@ -37,7 +43,15 @@ public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, Ent
}
return super.removedByPlayer(state, world, pos, player, willHarvest);
}


@Override
public void onBlockExploded(World world, BlockPos pos, Explosion explosion) {
if(takesBlastDamage(world,pos)) {
super.onBlockExploded(world, pos, explosion);
}
return;
}

boolean isConnected(World world, BlockPos pos) {
SGBaseTE bte = getBaseTE(world, pos);
return bte != null && bte.isConnected();
Expand All @@ -50,4 +64,27 @@ boolean canPlayerBreakGeneratedGates(World world, BlockPos pos) {
}
return true;
}

boolean takesBlastDamage(World world, BlockPos pos) {
SGBaseTE bte = getBaseTE(world, pos);
if(bte != null) {
return bte.takesBlastDamage;
}
return true;
}

boolean requiresAdminToBreak(World world, BlockPos pos) {
SGBaseTE bte = getBaseTE(world, pos);
if(bte != null) {
return bte.requiresAdminToBreak;
}
return false;
}

private boolean isOperator(EntityPlayer player) {
return player.canUseCommand(4, "") ||
player.canUseCommand(3, "") ||
player.canUseCommand(2, "") ||
player.canUseCommand(1, "");
}
}
29 changes: 29 additions & 0 deletions src/mod/gcewing/sg/item/SGAdminUpgradeItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package gcewing.sg.item;

import gcewing.sg.interfaces.ISGBlock;
import gcewing.sg.tileentity.SGBaseTE;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
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 SGAdminUpgradeItem extends Item {
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
Block block = worldIn.getBlockState(pos).getBlock();
if(!(block instanceof ISGBlock)) {
return EnumActionResult.FAIL;
}

SGBaseTE SGBaseTE = ((ISGBlock) block).getBaseTE(worldIn,pos);
if(SGBaseTE == null) {
return EnumActionResult.FAIL;
}

return SGBaseTE.applyAdminUpgrade(player.getHeldItem(hand), player);
}
}
45 changes: 45 additions & 0 deletions src/mod/gcewing/sg/tileentity/SGBaseTE.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ public static void registerSounds(SGCraft mod) {
public boolean allowRedstoneInput = true;
public boolean canPlayerBreakGate = false;

public boolean takesBlastDamage;
public boolean requiresAdminToBreak;

// Access Control Lists
private List<PlayerAccessData> playerAccessData;
private List<GateAccessData> gateAccessData;
Expand Down Expand Up @@ -296,7 +299,11 @@ public SGBaseTE() {
this.useDHDFuelSource = cfg.getBoolean("dhd", "useDHDFuelSource", this.useDHDFuelSource);
this.allowRedstoneOutput = cfg.getBoolean("stargate", "allowRedstoneOutput", this.allowRedstoneOutput);
this.allowRedstoneInput = cfg.getBoolean("iris", "allowRedstoneInput", this.allowRedstoneInput);

this.canPlayerBreakGate = cfg.getBoolean("stargate", "canPlayerBreakGate", this.canPlayerBreakGate);

this.takesBlastDamage = cfg.getBoolean("stargate","takesBlastDamage",this.takesBlastDamage);
this.requiresAdminToBreak = cfg.getBoolean("stargate","requiresAdminToBreak",this.requiresAdminToBreak);
}

public static void configure(BaseConfiguration cfg) {
Expand Down Expand Up @@ -334,6 +341,9 @@ public static void configure(BaseConfiguration cfg) {
cfg.getBoolean("iris", "allowRedstoneInput", true);
cfg.getBoolean("stargate", "canPlayerBreakGate", false);

cfg.getBoolean("stargate","takesBlastDamage",true);
cfg.getBoolean("stargate","requiresAdminToBreak", false);

// Global static config values
minutesOpenPerFuelItem = cfg.getInteger("stargate", "minutesOpenPerFuelItem", minutesOpenPerFuelItem);
chunkLoadingRange = cfg.getInteger("options", "chunkLoadingRange", chunkLoadingRange);
Expand Down Expand Up @@ -646,6 +656,20 @@ public void readFromNBT(NBTTagCompound nbt) {
} else {
this.canPlayerBreakGate = cfg.getBoolean("stargate", "canPlayerBreakGate", this.canPlayerBreakGate);
}

if(nbt.hasKey("takesBlastDamage") && !SGCraft.forceSGBaseTEUpdate) {
this.takesBlastDamage = nbt.getBoolean("takesBlastDamage");
}
else {
this.takesBlastDamage = cfg.getBoolean("stargate","takesBlastDamage", this.takesBlastDamage);
}

if(nbt.hasKey("requiresAdminToBreak") && !SGCraft.forceSGBaseTEUpdate) {
this.requiresAdminToBreak = nbt.getBoolean("requiresAdminToBreak");
}
else {
this.requiresAdminToBreak = cfg.getBoolean("stargate","requiresAdminToBreak", this.requiresAdminToBreak);
}
}

protected String getStringOrNull(NBTTagCompound nbt, String name) {
Expand Down Expand Up @@ -736,6 +760,9 @@ public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
nbt.setBoolean("allowRedstoneInput", this.allowRedstoneInput);
nbt.setBoolean("canPlayerBreakGate", this.canPlayerBreakGate);

nbt.setBoolean("takesBlastDamage",this.takesBlastDamage);
nbt.setBoolean("requiresAdminToBreak",this.requiresAdminToBreak);

return nbt;
}

Expand Down Expand Up @@ -2785,6 +2812,24 @@ public EnumActionResult applyPegasusUpgrade(ItemStack stack, EntityPlayer player
return EnumActionResult.SUCCESS;
}

public EnumActionResult applyAdminUpgrade(ItemStack stack, EntityPlayer player)
{
if(!getWorld().isRemote) {
if (!(requiresAdminToBreak && !takesBlastDamage && !canPlayerBreakGate)) {
takesBlastDamage = false;
canPlayerBreakGate = false;
requiresAdminToBreak = true;
stack.shrink(1);
markChanged();
sendBasicMsg(player,"adminUpgradeSuccess");
return EnumActionResult.SUCCESS;
}
sendErrorMsg(player,"adminUpgradeFail");
}

return EnumActionResult.SUCCESS;
}

public double[][][] getEventHorizonGrid() {
if (ehGrid == null) {
int m = SGBaseTERenderer.ehGridRadialSize;
Expand Down
6 changes: 5 additions & 1 deletion src/resources/assets/sgcraft/lang/de_DE.lang
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,8 @@ sgcraft.gui.gdo.label.remoteGateControl=Entfernte Iriskontrolle

sgcraft.gui.zpmConsole.label.availablePower=Verfügbare Energie

item.sgcraft:pegasus_upgrade.name=Pegasus Typ Erweiterungskristall
item.sgcraft:pegasus_upgrade.name=Pegasus Typ Erweiterungskristall

item.sgcraft:admin_upgrade.name=Admin Erweiterungskristall
message.sgcraft:adminUpgradeSuccess=Admin Erweiterung erfolgreich Installiert!
message.sgcraft:adminUpgradeFail=Admin Erweiterung ist berreits installiert.
4 changes: 4 additions & 0 deletions src/resources/assets/sgcraft/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,7 @@ sgcraft.gui.gdo.label.remoteGateControl=Remote Gate Control
sgcraft.gui.zpmConsole.label.availablePower=Available Power

item.sgcraft:pegasus_upgrade.name=Pegasus Type Upgrade Crystal

item.sgcraft:admin_upgrade.name=Admin Upgrade Crystal
message.sgcraft:adminUpgradeSuccess=Admin Upgrade has been installed!
message.sgcraft:adminUpgradeFail=Admin Upgrade already installed.
6 changes: 6 additions & 0 deletions src/resources/assets/sgcraft/models/item/admin_upgrade.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "sgcraft:items/admin_upgrade"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.