Search in sources :

Example 11 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class EventsCommon method onRightClickBlock.

@SubscribeEvent()
public void onRightClickBlock(RightClickBlock event) {
    if (!event.getWorld().isRemote) {
        ItemStack stack = event.getItemStack();
        if (stack != null && stack.getItem() instanceof ItemNameTag) {
            BlockPos posAt = event.getPos();
            EntityPlayer player = event.getEntityPlayer();
            World world = event.getWorld();
            PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, posAt);
            if (wrapper != null) {
                wrapper.setCustomNameTag(stack.getDisplayName());
                --stack.stackSize;
                event.setCanceled(true);
            }
        }
    }
}
Also used : ItemNameTag(net.minecraft.item.ItemNameTag) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 12 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class EventsCommon method onBlockBreak.

@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent event) {
    if (!event.getWorld().isRemote) {
        PhysicsWrapperEntity physObj = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(event.getWorld(), event.getPos());
        if (physObj != null) {
            if (ValkyrienWarfareMod.runAirshipPermissions && !(physObj.wrapping.creator.equals(event.getPlayer().entityUniqueID.toString()) || physObj.wrapping.allowedUsers.contains(event.getPlayer().entityUniqueID.toString()))) {
                event.getPlayer().addChatMessage(new TextComponentString("You need to be added to the airship to do that!" + (physObj.wrapping.creator == null || physObj.wrapping.creator.trim().isEmpty() ? " Try using \"/airshipSettings claim\"!" : "")));
                event.setCanceled(true);
                return;
            }
            if (physObj.wrapping.shipType == ShipType.Oribtal) {
            //Do not let it break
            }
        }
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 13 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class KeyHandler method playerTick.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void playerTick(PlayerTickEvent event) {
    if (event.side == Side.SERVER)
        return;
    if (event.phase == Phase.START) {
        if (ClientPilotingManager.isPlayerPilotingShip()) {
            // if(airshipDismount.isKeyDown()){
            // PilotShipManager.dismountPlayer();
            // }else{
            Entity player = Minecraft.getMinecraft().thePlayer;
            //				player.setPosition(player.posX, player.posY, player.posZ);
            ClientPilotingManager.sendPilotKeysToServer();
        // }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 14 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Witchworks by Um-Mitternacht.

the class EnergyHUD method onTick.

@SubscribeEvent
public void onTick(TickEvent.ClientTickEvent event) {
    if (event.phase == TickEvent.Phase.END && Minecraft.getMinecraft().player != null) {
        Optional<IEnergy> optional = EnergyHandler.getEnergy(Minecraft.getMinecraft().player);
        if (optional.isPresent()) {
            IEnergy energy = optional.get();
            if (oldEnergy != energy.get()) {
                oldEnergy = energy.get();
                renderTime = 60;
                visible = 1F;
            }
            if (renderTime > 0 && energy.get() == energy.getMax()) {
                if (ENERGY_HUD.hide && renderTime < 20) {
                    visible -= 0.05F;
                    visible = MathHelper.clamp(visible, 0F, 1F);
                }
                renderTime--;
            }
            if (!reverse) {
                barAlpha += 0.05F;
                if (barAlpha > 1F) {
                    barAlpha = 1F;
                    reverse = true;
                }
            } else {
                barAlpha -= 0.05F;
                if (barAlpha < 0F) {
                    barAlpha = 0;
                    reverse = false;
                }
            }
        }
    }
}
Also used : IEnergy(com.witchworks.common.core.capability.energy.IEnergy) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 15 with SubscribeEvent

use of net.minecraftforge.fml.common.eventhandler.SubscribeEvent in project Witchworks by Um-Mitternacht.

the class EnergyHUD method renderOverlay.

@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Post event) {
    if (event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR && renderTime > 0) {
        Minecraft mc = Minecraft.getMinecraft();
        Optional<IEnergy> optional = EnergyHandler.getEnergy(mc.player);
        if (optional.isPresent()) {
            IEnergy energy = optional.get();
            ScaledResolution res = event.getResolution();
            GlStateManager.pushMatrix();
            GlStateManager.enableBlend();
            float filled = (float) energy.get() / (float) energy.getMax();
            int heightEnd = ENERGY_HUD.heightEnd;
            int heightStart = ENERGY_HUD.heightStart;
            int width = ENERGY_HUD.width;
            int heightUsed = heightEnd - heightStart;
            int heightFilled = (int) ((heightUsed - 28) * filled);
            int posX = ENERGY_HUD.x;
            int posY = res.getScaledHeight() - ENERGY_HUD.y;
            int startPosX = posX - heightEnd;
            if (ENERGY_HUD.hide)
                GlStateManager.color(1F, 1F, 1F, visible);
            mc.getTextureManager().bindTexture(ResourceLocations.ENERGY_BACKGROUND[0]);
            Gui.drawModalRectWithCustomSizedTexture(startPosX - 4, posY + 14, 0F, heightUsed - 28, width, heightFilled, width, heightUsed - 28);
            GlStateManager.pushMatrix();
            GlStateManager.color(1F, 1F, 1F, visible == 1F ? barAlpha : visible);
            mc.getTextureManager().bindTexture(ResourceLocations.ENERGY_BACKGROUND[1]);
            Gui.drawModalRectWithCustomSizedTexture(startPosX - 4, posY + 14, 0F, heightUsed - 28, width, heightFilled, width, heightUsed - 28);
            GlStateManager.popMatrix();
            if (ENERGY_HUD.hide)
                GlStateManager.color(1F, 1F, 1F, visible);
            mc.getTextureManager().bindTexture(ResourceLocations.ENERGY);
            Gui.drawModalRectWithCustomSizedTexture(startPosX - 4, posY, 0F, 0F, width, heightUsed, width, heightUsed);
            int textColor = 0x990066;
            if (ENERGY_HUD.hide) {
                int alpha = (int) (visible * 255);
                textColor = alpha << 24 | 0x990066;
            }
            mc.fontRenderer.drawStringWithShadow("E: " + energy.get(), startPosX, posY - 15, textColor);
            GlStateManager.disableBlend();
            GlStateManager.popMatrix();
        }
    }
}
Also used : IEnergy(com.witchworks.common.core.capability.energy.IEnergy) ScaledResolution(net.minecraft.client.gui.ScaledResolution) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1135 ItemStack (net.minecraft.item.ItemStack)316 EntityPlayer (net.minecraft.entity.player.EntityPlayer)314 World (net.minecraft.world.World)196 BlockPos (net.minecraft.util.math.BlockPos)179 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)136 IBlockState (net.minecraft.block.state.IBlockState)120 ResourceLocation (net.minecraft.util.ResourceLocation)102 Entity (net.minecraft.entity.Entity)93 Block (net.minecraft.block.Block)86 EntityLivingBase (net.minecraft.entity.EntityLivingBase)84 Minecraft (net.minecraft.client.Minecraft)72 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)66 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)64 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)55 Item (net.minecraft.item.Item)53 EntityItem (net.minecraft.entity.item.EntityItem)48 TileEntity (net.minecraft.tileentity.TileEntity)46 TextComponentString (net.minecraft.util.text.TextComponentString)42 Random (java.util.Random)37