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);
}
}
}
}
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();
}
}
}
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;
});
}
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);
}
}
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);
}
}
}
}
}
}
}
Aggregations