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