Improvements
This commit is contained in:
parent
1b97e5a62a
commit
6056562326
|
|
@ -55,8 +55,8 @@ public class Configs {
|
|||
@Comment("Use Whitelist instead of Blacklist for Entities")
|
||||
public boolean useWhitelistEntities=false;
|
||||
|
||||
@Comment("Whether the player can break blocks while carrying or not")
|
||||
public boolean breakBlocksWhileCarrying=false;
|
||||
@Comment("Whether the player can hit blocks and entities while carrying or not")
|
||||
public boolean hitWhileCarrying=false;
|
||||
|
||||
@Comment("Whether the player drops the carried object when hit or not")
|
||||
public boolean dropCarriedWhenHit=false;
|
||||
|
|
|
|||
|
|
@ -22,10 +22,12 @@ import net.minecraft.world.GameRules;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.player.AttackEntityEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent.BreakSpeed;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent.StartTracking;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
|
@ -170,7 +172,7 @@ public class ItemEvents
|
|||
public void harvestSpeed(BreakSpeed event)
|
||||
{
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
if (player != null && !CarryOnConfig.settings.breakBlocksWhileCarrying)
|
||||
if (player != null && !CarryOnConfig.settings.hitWhileCarrying)
|
||||
{
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
||||
|
|
@ -178,6 +180,30 @@ public class ItemEvents
|
|||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void attackEntity(AttackEntityEvent event)
|
||||
{
|
||||
EntityPlayer player = event.getEntityPlayer();
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (!stack.isEmpty() && !CarryOnConfig.settings.hitWhileCarrying && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void harvestSpeed(BreakEvent event)
|
||||
{
|
||||
EntityPlayer player = event.getPlayer();
|
||||
if (player != null && !CarryOnConfig.settings.hitWhileCarrying)
|
||||
{
|
||||
ItemStack stack = player.getHeldItemMainhand();
|
||||
if (!stack.isEmpty() && (stack.getItem() == RegistrationHandler.itemTile || stack.getItem() == RegistrationHandler.itemEntity))
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void playerAttack(LivingAttackEvent event)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user