diff --git a/build.gradle b/build.gradle index a8dce1eb..2bf34126 100644 --- a/build.gradle +++ b/build.gradle @@ -87,6 +87,7 @@ sourceSets.main { compileClasspath += files("lib") java.srcDirs "src/base", "src/mod" resources.srcDirs "src/resources" + output.resourcesDir = output.classesDir } processResources { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bf3de218..8a2bb43a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/src/mod/gcewing/sg/SGCraft.java b/src/mod/gcewing/sg/SGCraft.java index 0131a9eb..7969f75f 100644 --- a/src/mod/gcewing/sg/SGCraft.java +++ b/src/mod/gcewing/sg/SGCraft.java @@ -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; @@ -125,6 +122,7 @@ public class SGCraft extends BaseMod { 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; @@ -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"); diff --git a/src/mod/gcewing/sg/block/SGBlock.java b/src/mod/gcewing/sg/block/SGBlock.java index 8a29652d..2db36442 100644 --- a/src/mod/gcewing/sg/block/SGBlock.java +++ b/src/mod/gcewing/sg/block/SGBlock.java @@ -16,14 +16,20 @@ import net.minecraft.util.math.*; import net.minecraft.world.*; + public abstract class SGBlock extends BaseBlock implements ISGBlock { public SGBlock(Material material, Class 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. @@ -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(); @@ -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, ""); + } } diff --git a/src/mod/gcewing/sg/item/SGAdminUpgradeItem.java b/src/mod/gcewing/sg/item/SGAdminUpgradeItem.java new file mode 100644 index 00000000..4a44df94 --- /dev/null +++ b/src/mod/gcewing/sg/item/SGAdminUpgradeItem.java @@ -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); + } +} diff --git a/src/mod/gcewing/sg/tileentity/SGBaseTE.java b/src/mod/gcewing/sg/tileentity/SGBaseTE.java index 90885507..9de38063 100644 --- a/src/mod/gcewing/sg/tileentity/SGBaseTE.java +++ b/src/mod/gcewing/sg/tileentity/SGBaseTE.java @@ -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; private List gateAccessData; @@ -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) { @@ -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); @@ -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) { @@ -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; } @@ -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; diff --git a/src/resources/assets/sgcraft/lang/de_DE.lang b/src/resources/assets/sgcraft/lang/de_DE.lang index c9df036b..d3d62f44 100644 --- a/src/resources/assets/sgcraft/lang/de_DE.lang +++ b/src/resources/assets/sgcraft/lang/de_DE.lang @@ -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 \ No newline at end of file +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. \ No newline at end of file diff --git a/src/resources/assets/sgcraft/lang/en_US.lang b/src/resources/assets/sgcraft/lang/en_US.lang index 27d7ff41..c3d434dc 100644 --- a/src/resources/assets/sgcraft/lang/en_US.lang +++ b/src/resources/assets/sgcraft/lang/en_US.lang @@ -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. diff --git a/src/resources/assets/sgcraft/models/item/admin_upgrade.json b/src/resources/assets/sgcraft/models/item/admin_upgrade.json new file mode 100644 index 00000000..a00a29d5 --- /dev/null +++ b/src/resources/assets/sgcraft/models/item/admin_upgrade.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "sgcraft:items/admin_upgrade" + } +} \ No newline at end of file diff --git a/src/resources/assets/sgcraft/textures/items/admin_upgrade.png b/src/resources/assets/sgcraft/textures/items/admin_upgrade.png new file mode 100644 index 00000000..1a20d171 Binary files /dev/null and b/src/resources/assets/sgcraft/textures/items/admin_upgrade.png differ