Added Protection for Entities [1.12]

This commit is contained in:
Tschipp 2018-07-06 16:33:32 +02:00
parent 324b055dea
commit 66d7af98d8
5 changed files with 26 additions and 28 deletions

View File

@ -24,7 +24,7 @@ compileJava {
} }
minecraft { minecraft {
version = "1.12.2-14.23.2.2611" version = "1.12.2-14.23.4.2705"
runDir = "run" runDir = "run"
mappings = "snapshot_20171003" mappings = "snapshot_20171003"
@ -35,7 +35,6 @@ repositories {
maven { url 'http://maven.epoxide.org' } maven { url 'http://maven.epoxide.org' }
maven { url 'http://maven.latmod.com' }
} }
@ -44,10 +43,6 @@ dependencies {
deobfCompile "net.darkhax.gamestages:GameStages-1.12.2:2.0.91" deobfCompile "net.darkhax.gamestages:GameStages-1.12.2:2.0.91"
deobfCompile "com.feed_the_beast.mods:FTBLib:5.0.2.11"
deobfCompile "com.feed_the_beast.mods:FTBUtilities:5.0.2.11"
} }
processResources { processResources {

View File

@ -32,12 +32,12 @@ public class CarryOn {
public static CarryOn instance; public static CarryOn instance;
public static final String MODID = "carryon"; public static final String MODID = "carryon";
public static final String VERSION = "1.9"; public static final String VERSION = "1.9.1";
public static final String NAME = "Carry On"; public static final String NAME = "Carry On";
public static final String ACCEPTED_VERSIONS = "[1.12.2,1.13)"; public static final String ACCEPTED_VERSIONS = "[1.12.2,1.13)";
public static final String UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/"; public static final String UPDATE_JSON = "https://gist.githubusercontent.com/Tschipp/dccadee7c90d7a34e6e76a35d9d6fa2e/raw/";
public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn"); public static final Logger LOGGER = LogManager.getFormatterLogger("CarryOn");
public static final String DEPENDENCIES = "required-after:forge@[13.20.1.2386,);after:ftbu@[5.0.0.11,);after:gamestages@[2.0.91,)"; public static final String DEPENDENCIES = "required-after:forge@[13.20.1.2386,);after:gamestages@[2.0.91,)";
public static File CONFIGURATION_FILE; public static File CONFIGURATION_FILE;
public static SimpleNetworkWrapper network; public static SimpleNetworkWrapper network;

View File

@ -305,9 +305,7 @@ public class ItemEvents
} }
} }
} }
} }
} }
} }

View File

@ -4,28 +4,26 @@ import java.util.UUID;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import com.feed_the_beast.ftblib.lib.math.BlockPosContainer;
import com.feed_the_beast.ftbutilities.data.BlockInteractionType;
import com.feed_the_beast.ftbutilities.data.ClaimedChunks;
import net.darkhax.gamestages.GameStageHelper; import net.darkhax.gamestages.GameStageHelper;
import net.darkhax.gamestages.data.IStageData; import net.darkhax.gamestages.data.IStageData;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand; import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.player.AttackEntityEvent;
import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fml.common.Loader;
import tschipp.carryon.CarryOn; import tschipp.carryon.CarryOn;
import tschipp.carryon.common.config.CarryOnConfig; import tschipp.carryon.common.config.CarryOnConfig;
import tschipp.carryon.common.item.ItemTile; import tschipp.carryon.common.item.ItemTile;
@ -111,7 +109,7 @@ public class PickupHandler
CarryOnOverride override = ScriptChecker.inspectEntity(toPickUp); CarryOnOverride override = ScriptChecker.inspectEntity(toPickUp);
if (override != null) if (override != null)
{ {
return (ScriptChecker.fulfillsConditions(override, player)); return (ScriptChecker.fulfillsConditions(override, player)) && handleProtections((EntityPlayerMP) player, toPickUp);
} }
else else
{ {
@ -139,10 +137,10 @@ public class PickupHandler
IStageData stageData = GameStageHelper.getPlayerData(player); IStageData stageData = GameStageHelper.getPlayerData(player);
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp); String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
if (stageData.hasStage(condition)) if (stageData.hasStage(condition))
return true; return true && handleProtections((EntityPlayerMP) player, toPickUp);
} }
else else
return true; return true && handleProtections((EntityPlayerMP) player, toPickUp);
} }
} }
@ -184,10 +182,10 @@ public class PickupHandler
IStageData stageData = GameStageHelper.getPlayerData(player); IStageData stageData = GameStageHelper.getPlayerData(player);
String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp); String condition = CustomPickupOverrideHandler.getPickupCondition(toPickUp);
if (stageData.hasStage(condition)) if (stageData.hasStage(condition))
return true; return true && handleProtections((EntityPlayerMP) player, toPickUp);
} }
else else
return true; return true && handleProtections((EntityPlayerMP) player, toPickUp);
} }
} }
} }
@ -201,12 +199,6 @@ public class PickupHandler
private static boolean handleProtections(EntityPlayerMP player, World world, BlockPos pos, IBlockState state) private static boolean handleProtections(EntityPlayerMP player, World world, BlockPos pos, IBlockState state)
{ {
boolean breakable = true; boolean breakable = true;
if (Loader.isModLoaded("ftbu"))
{
BlockPosContainer container = new BlockPosContainer(world, pos, state);
breakable = ClaimedChunks.instance.canPlayerInteract((EntityPlayerMP) player, EnumHand.MAIN_HAND, container, BlockInteractionType.CNB_BREAK);
}
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, state, player); BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, state, player);
MinecraftForge.EVENT_BUS.post(event); MinecraftForge.EVENT_BUS.post(event);
@ -216,5 +208,18 @@ public class PickupHandler
return breakable; return breakable;
} }
private static boolean handleProtections(EntityPlayerMP player, Entity entity)
{
boolean canPickup = true;
AttackEntityEvent event = new AttackEntityEvent(player, entity);
MinecraftForge.EVENT_BUS.post(event);
if(event.isCanceled())
canPickup = false;
return canPickup;
}
} }

View File

@ -2,7 +2,7 @@
{ {
"modid" : "carryon", "modid" : "carryon",
"name" : "Carry On", "name" : "Carry On",
"version" : "1.9", "mcversion" : "1.12.2", "version" : "1.9.1", "mcversion" : "1.12.2",
"url" : "", "url" : "",
"credits" : "Tschipp, Purplicious_Cow, cy4n", "credits" : "Tschipp, Purplicious_Cow, cy4n",
"authorList" : ["Tschipp, Purplicious_Cow, cy4n"], "authorList" : ["Tschipp, Purplicious_Cow, cy4n"],