Skip to content

Commit

Permalink
Fixed issue #773 - Keys Burning, Added IItemInvulnerable interface to…
Browse files Browse the repository at this point in the history
… api package so other mods can use this when ExtraPlanets is installed
  • Loading branch information
MJRLegends committed Apr 24, 2024
1 parent a8f9ad1 commit 28a6404
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.mjr.extraplanets.api.item;

public interface IItemInvulnerable {

}
11 changes: 11 additions & 0 deletions src/main/java/com/mjr/extraplanets/handlers/MainHandlerServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.mjr.extraplanets.Config;
import com.mjr.extraplanets.Constants;
import com.mjr.extraplanets.ExtraPlanets;
import com.mjr.extraplanets.api.item.IItemInvulnerable;
import com.mjr.extraplanets.api.item.IModularArmor;
import com.mjr.extraplanets.api.item.IPressureSuit;
import com.mjr.extraplanets.api.item.IRadiationSuit;
Expand Down Expand Up @@ -50,6 +51,7 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.MobEffects;
Expand All @@ -62,6 +64,7 @@
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.CommandEvent;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
Expand Down Expand Up @@ -707,4 +710,12 @@ public void onWorldChange(PlayerChangedDimensionEvent event) {
}
}
}

@SubscribeEvent
public void onEntitySpawn(EntityJoinWorldEvent event) {
if (event.getEntity() instanceof EntityItem) {
if (((EntityItem)event.getEntity()).getItem().getItem() instanceof IItemInvulnerable)
event.getEntity().setEntityInvulnerable(true);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mjr.extraplanets.items.keys;

import com.mjr.extraplanets.ExtraPlanets;
import com.mjr.extraplanets.api.item.IItemInvulnerable;

import micdoodle8.mods.galacticraft.api.item.IKeyItem;
import micdoodle8.mods.galacticraft.core.items.ISortableItem;
Expand All @@ -14,7 +15,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ItemKeyT10 extends Item implements IKeyItem, ISortableItem {
public class ItemKeyT10 extends Item implements IKeyItem, ISortableItem, IItemInvulnerable {
public ItemKeyT10(String name) {
super();
this.setMaxStackSize(1);
Expand Down Expand Up @@ -61,4 +62,6 @@ public int getTier(ItemStack keyStack) {
public EnumSortCategoryItem getCategory(int meta) {
return EnumSortCategoryItem.GENERAL;
}


}
3 changes: 2 additions & 1 deletion src/main/java/com/mjr/extraplanets/items/keys/ItemKeyT4.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mjr.extraplanets.items.keys;

import com.mjr.extraplanets.ExtraPlanets;
import com.mjr.extraplanets.api.item.IItemInvulnerable;

import micdoodle8.mods.galacticraft.api.item.IKeyItem;
import micdoodle8.mods.galacticraft.core.items.ISortableItem;
Expand All @@ -14,7 +15,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ItemKeyT4 extends Item implements IKeyItem, ISortableItem {
public class ItemKeyT4 extends Item implements IKeyItem, ISortableItem, IItemInvulnerable {
public ItemKeyT4(String name) {
super();
this.setMaxStackSize(1);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/mjr/extraplanets/items/keys/ItemKeyT5.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mjr.extraplanets.items.keys;

import com.mjr.extraplanets.ExtraPlanets;
import com.mjr.extraplanets.api.item.IItemInvulnerable;

import micdoodle8.mods.galacticraft.api.item.IKeyItem;
import micdoodle8.mods.galacticraft.core.items.ISortableItem;
Expand All @@ -14,7 +15,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ItemKeyT5 extends Item implements IKeyItem, ISortableItem {
public class ItemKeyT5 extends Item implements IKeyItem, ISortableItem, IItemInvulnerable {
public ItemKeyT5(String name) {
super();
this.setMaxStackSize(1);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/mjr/extraplanets/items/keys/ItemKeyT6.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mjr.extraplanets.items.keys;

import com.mjr.extraplanets.ExtraPlanets;
import com.mjr.extraplanets.api.item.IItemInvulnerable;

import micdoodle8.mods.galacticraft.api.item.IKeyItem;
import micdoodle8.mods.galacticraft.core.items.ISortableItem;
Expand All @@ -14,7 +15,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ItemKeyT6 extends Item implements IKeyItem, ISortableItem {
public class ItemKeyT6 extends Item implements IKeyItem, ISortableItem, IItemInvulnerable {
public ItemKeyT6(String name) {
super();
this.setMaxStackSize(1);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/mjr/extraplanets/items/keys/ItemKeyT7.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mjr.extraplanets.items.keys;

import com.mjr.extraplanets.ExtraPlanets;
import com.mjr.extraplanets.api.item.IItemInvulnerable;

import micdoodle8.mods.galacticraft.api.item.IKeyItem;
import micdoodle8.mods.galacticraft.core.items.ISortableItem;
Expand All @@ -14,7 +15,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ItemKeyT7 extends Item implements IKeyItem, ISortableItem {
public class ItemKeyT7 extends Item implements IKeyItem, ISortableItem, IItemInvulnerable {
public ItemKeyT7(String name) {
super();
this.setMaxStackSize(1);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/mjr/extraplanets/items/keys/ItemKeyT8.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mjr.extraplanets.items.keys;

import com.mjr.extraplanets.ExtraPlanets;
import com.mjr.extraplanets.api.item.IItemInvulnerable;

import micdoodle8.mods.galacticraft.api.item.IKeyItem;
import micdoodle8.mods.galacticraft.core.items.ISortableItem;
Expand All @@ -14,7 +15,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ItemKeyT8 extends Item implements IKeyItem, ISortableItem {
public class ItemKeyT8 extends Item implements IKeyItem, ISortableItem, IItemInvulnerable {
public ItemKeyT8(String name) {
super();
this.setMaxStackSize(1);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/mjr/extraplanets/items/keys/ItemKeyT9.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mjr.extraplanets.items.keys;

import com.mjr.extraplanets.ExtraPlanets;
import com.mjr.extraplanets.api.item.IItemInvulnerable;

import micdoodle8.mods.galacticraft.api.item.IKeyItem;
import micdoodle8.mods.galacticraft.core.items.ISortableItem;
Expand All @@ -14,7 +15,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ItemKeyT9 extends Item implements IKeyItem, ISortableItem {
public class ItemKeyT9 extends Item implements IKeyItem, ISortableItem, IItemInvulnerable {
public ItemKeyT9(String name) {
super();
this.setMaxStackSize(1);
Expand Down

0 comments on commit 28a6404

Please sign in to comment.