Search in sources :

Example 66 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project malmo by Microsoft.

the class RewardForTouchingBlockTypeImplementation method calculateReward.

private void calculateReward(MultidimensionalReward reward) {
    // Determine what blocks we are touching.
    // This code is largely cribbed from Entity, where it is used to fire the Block.onEntityCollidedWithBlock methods.
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    List<BlockPos> touchingBlocks = PositionHelper.getTouchingBlocks(player);
    for (BlockPos pos : touchingBlocks) {
        IBlockState iblockstate = player.world.getBlockState(pos);
        for (BlockMatcher bm : this.matchers) {
            if (bm.applies(pos) && bm.matches(pos, iblockstate)) {
                float reward_value = bm.reward();
                float adjusted_reward = adjustAndDistributeReward(reward_value, this.params.getDimension(), bm.spec.getDistribution());
                reward.add(this.params.getDimension(), adjusted_reward);
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP)

Example 67 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project Almura by AlmuraDev.

the class ClientboundMembershipSuccessPacketHandler method handleMessage.

@Override
public void handleMessage(ClientboundMembershipSuccessPacket message, RemoteConnection connection, Platform.Type side) {
    if (side.isClient()) {
        final Minecraft client = Minecraft.getMinecraft();
        if (PacketUtil.checkThreadAndEnqueue(client, message, this, connection, side)) {
            final EntityPlayerSP player = client.player;
            new MembershipAppliedGui(null, message.membership).display();
        }
    }
}
Also used : EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Minecraft(net.minecraft.client.Minecraft) MembershipAppliedGui(com.almuradev.almura.feature.membership.client.gui.MembershipAppliedGui)

Example 68 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project GregTech by GregTechCE.

the class UIFactory method initClientUI.

@SideOnly(Side.CLIENT)
public final void initClientUI(PacketBuffer serializedHolder, int windowId, List<PacketUIWidgetUpdate> initialWidgetUpdates) {
    E holder = readHolderFromSyncData(serializedHolder);
    Minecraft minecraft = Minecraft.getMinecraft();
    EntityPlayerSP entityPlayer = minecraft.player;
    ModularUI uiTemplate = createUITemplate(holder, entityPlayer);
    uiTemplate.initWidgets();
    ModularUIGui modularUIGui = new ModularUIGui(uiTemplate);
    modularUIGui.inventorySlots.windowId = windowId;
    for (PacketUIWidgetUpdate packet : initialWidgetUpdates) {
        modularUIGui.handleWidgetUpdate(packet);
    }
    minecraft.addScheduledTask(() -> {
        minecraft.displayGuiScreen(modularUIGui);
        minecraft.player.openContainer.windowId = windowId;
    });
}
Also used : PacketUIWidgetUpdate(gregtech.api.net.PacketUIWidgetUpdate) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) Minecraft(net.minecraft.client.Minecraft) ModularUIGui(gregtech.api.gui.impl.ModularUIGui) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 69 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project GregTech by GregTechCE.

the class EnchantmentTableTweaks method onGuiOpen.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public static void onGuiOpen(GuiOpenEvent event) {
    if (event.getGui() instanceof GuiContainer) {
        GuiContainer guiContainer = (GuiContainer) event.getGui();
        EntityPlayerSP playerSP = Minecraft.getMinecraft().player;
        onContainerOpen(playerSP, guiContainer.inventorySlots);
    }
}
Also used : GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 70 with EntityPlayerSP

use of net.minecraft.client.entity.EntityPlayerSP in project Galacticraft by micdoodle8.

the class TileEntityPlatform method updateClient.

@SideOnly(Side.CLIENT)
private void updateClient() {
    this.lightOn = false;
    if (this.colorTicks > 0) {
        if (--this.colorTicks == 0) {
            this.colorState = 0;
        }
    }
    IBlockState b = this.world.getBlockState(this.getPos());
    if (b.getBlock() == GCBlocks.platform && b.getValue(BlockPlatform.CORNER) == BlockPlatform.EnumCorner.NW) {
        // Scan area for player entities and light up
        if (this.detection == null) {
            this.detection = new AxisAlignedBB(this.getPos().getX() + 0.9D, this.getPos().getY() + 0.75D, this.getPos().getZ() + 0.9D, this.getPos().getX() + 1.1D, this.getPos().getY() + 1.85D, this.getPos().getZ() + 1.1D);
        }
        final List<Entity> list = this.world.getEntitiesWithinAABB(EntityPlayer.class, detection);
        if (list.size() > 0) {
            // Light up the platform
            this.lightOn = true;
            // If this player is within the box
            EntityPlayerSP p = FMLClientHandler.instance().getClientPlayerEntity();
            GCPlayerStatsClient stats = GCPlayerStatsClient.get(p);
            if (list.contains(p) && !stats.getPlatformControlled() && p.getRidingEntity() == null) {
                if (p.movementInput.sneak) {
                    int canDescend = this.checkNextPlatform(-1);
                    if (canDescend == -1) {
                        this.colorState = 1;
                        this.colorTicks = 16;
                    } else if (canDescend > 0) {
                        TileEntity te = this.world.getTileEntity(this.pos.down(canDescend));
                        if (te instanceof TileEntityPlatform) {
                            TileEntityPlatform tep = (TileEntityPlatform) te;
                            stats.startPlatformAscent(this, tep, this.pos.getY() - canDescend + (this.world.provider instanceof IZeroGDimension ? 0.97D : (double) BlockPlatform.HEIGHT));
                            this.startMove(tep);
                            tep.startMove(this);
                        }
                    }
                } else if (p.movementInput.jump) {
                    int canAscend = this.checkNextPlatform(1);
                    if (canAscend == -1) {
                        this.colorState = 1;
                        this.colorTicks = 16;
                    } else if (canAscend > 0) {
                        TileEntity te = this.world.getTileEntity(this.pos.up(canAscend));
                        if (te instanceof TileEntityPlatform) {
                            p.motionY = 0D;
                            TileEntityPlatform tep = (TileEntityPlatform) te;
                            stats.startPlatformAscent(tep, this, this.pos.getY() + canAscend + BlockPlatform.HEIGHT + 0.01D);
                            this.startMove(tep);
                            tep.startMove(this);
                        }
                    }
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) TileEntity(net.minecraft.tileentity.TileEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) GCPlayerStatsClient(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) IZeroGDimension(micdoodle8.mods.galacticraft.api.world.IZeroGDimension) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)158 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)31 Minecraft (net.minecraft.client.Minecraft)29 ItemStack (net.minecraft.item.ItemStack)29 BlockPos (net.minecraft.util.math.BlockPos)27 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)23 Entity (net.minecraft.entity.Entity)21 EntityPlayer (net.minecraft.entity.player.EntityPlayer)13 TileEntity (net.minecraft.tileentity.TileEntity)13 WorldClient (net.minecraft.client.multiplayer.WorldClient)11 IBlockState (net.minecraft.block.state.IBlockState)10 Tessellator (net.minecraft.client.renderer.Tessellator)10 GCPlayerStatsClient (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient)8 ArrayList (java.util.ArrayList)6 Block (net.minecraft.block.Block)6 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)6 Vec3d (net.minecraft.util.math.Vec3d)6 World (net.minecraft.world.World)6 UUID (java.util.UUID)5 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)5