Search in sources :

Example 1 with TileEntityTurretGun

use of blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretGun in project ImmersiveEngineering by BluSunrize.

the class GuiTurret method initGui.

@Override
public void initGui() {
    super.initGui();
    Keyboard.enableRepeatEvents(true);
    this.nameField = new GuiTextField(0, this.fontRendererObj, guiLeft + 11, guiTop + 88, 58, 12);
    this.nameField.setTextColor(-1);
    this.nameField.setDisabledTextColour(-1);
    this.nameField.setEnableBackgroundDrawing(false);
    this.nameField.setMaxStringLength(30);
    this.buttonList.clear();
    this.buttonList.add(new GuiReactiveList(this, 0, guiLeft + 10, guiTop + 10, 60, 72, tile.targetList.toArray(new String[tile.targetList.size()])).setPadding(0, 0, 2, 2).setFormatting(1, false));
    this.buttonList.add(new GuiButtonIE(1, guiLeft + 74, guiTop + 84, 24, 16, I18n.format(Lib.GUI_CONFIG + "turret.add"), "immersiveengineering:textures/gui/turret.png", 176, 65));
    this.buttonList.add(new GuiButtonCheckbox(2, guiLeft + 74, guiTop + 10, I18n.format(Lib.GUI_CONFIG + "turret.blacklist"), !tile.whitelist));
    this.buttonList.add(new GuiButtonCheckbox(3, guiLeft + 74, guiTop + 26, I18n.format(Lib.GUI_CONFIG + "turret.animals"), tile.attackAnimals));
    this.buttonList.add(new GuiButtonCheckbox(4, guiLeft + 74, guiTop + 42, I18n.format(Lib.GUI_CONFIG + "turret.players"), tile.attackPlayers));
    this.buttonList.add(new GuiButtonCheckbox(5, guiLeft + 74, guiTop + 58, I18n.format(Lib.GUI_CONFIG + "turret.neutrals"), tile.attackNeutrals));
    if (tile instanceof TileEntityTurretChem)
        this.buttonList.add(new GuiButtonState(6, guiLeft + 135, guiTop + 68, 14, 14, null, ((TileEntityTurretChem) tile).ignite, "immersiveengineering:textures/gui/turret.png", 176, 51, 0));
    else if (tile instanceof TileEntityTurretGun)
        this.buttonList.add(new GuiButtonState(6, guiLeft + 134, guiTop + 31, 16, 16, null, ((TileEntityTurretGun) tile).expelCasings, "immersiveengineering:textures/gui/turret.png", 176, 81, 0));
}
Also used : GuiReactiveList(blusunrize.immersiveengineering.client.gui.elements.GuiReactiveList) GuiButtonIE(blusunrize.immersiveengineering.client.gui.elements.GuiButtonIE) TileEntityTurretGun(blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretGun) GuiButtonState(blusunrize.immersiveengineering.client.gui.elements.GuiButtonState) GuiButtonCheckbox(blusunrize.immersiveengineering.client.gui.elements.GuiButtonCheckbox) GuiTextField(net.minecraft.client.gui.GuiTextField) TileEntityTurretChem(blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretChem)

Example 2 with TileEntityTurretGun

use of blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretGun in project ImmersiveEngineering by BluSunrize.

the class GuiTurret method actionPerformed.

@Override
protected void actionPerformed(GuiButton button) {
    NBTTagCompound tag = new NBTTagCompound();
    int listOffset = -1;
    if (button.id == 0) {
        int rem = ((GuiReactiveList) button).selectedOption;
        tile.targetList.remove(rem);
        tag.setInteger("remove", rem);
        listOffset = ((GuiReactiveList) button).getOffset() - 1;
    } else if (button.id == 1 && !this.nameField.getText().isEmpty()) {
        String name = this.nameField.getText();
        if (!tile.targetList.contains(name)) {
            listOffset = ((GuiReactiveList) buttonList.get(0)).getMaxOffset();
            tag.setString("add", name);
            tile.targetList.add(name);
        }
        this.nameField.setText("");
    } else if (button.id == 2) {
        tile.whitelist = !((GuiButtonState) button).state;
        tag.setBoolean("whitelist", tile.whitelist);
    } else if (button.id == 3) {
        tile.attackAnimals = ((GuiButtonState) button).state;
        tag.setBoolean("attackAnimals", tile.attackAnimals);
    } else if (button.id == 4) {
        tile.attackPlayers = ((GuiButtonState) button).state;
        tag.setBoolean("attackPlayers", tile.attackPlayers);
    } else if (button.id == 5) {
        tile.attackNeutrals = ((GuiButtonState) button).state;
        tag.setBoolean("attackNeutrals", tile.attackNeutrals);
    } else if (button.id == 6 && tile instanceof TileEntityTurretChem) {
        ((TileEntityTurretChem) tile).ignite = ((GuiButtonState) button).state;
        tag.setBoolean("ignite", ((TileEntityTurretChem) tile).ignite);
    } else if (button.id == 6 && tile instanceof TileEntityTurretGun) {
        ((TileEntityTurretGun) tile).expelCasings = ((GuiButtonState) button).state;
        tag.setBoolean("expelCasings", ((TileEntityTurretGun) tile).expelCasings);
    }
    if (!tag.hasNoTags()) {
        ImmersiveEngineering.packetHandler.sendToServer(new MessageTileSync(tile, tag));
        this.initGui();
        if (listOffset >= 0)
            ((GuiReactiveList) this.buttonList.get(0)).setOffset(listOffset);
    }
}
Also used : GuiReactiveList(blusunrize.immersiveengineering.client.gui.elements.GuiReactiveList) TileEntityTurretGun(blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretGun) GuiButtonState(blusunrize.immersiveengineering.client.gui.elements.GuiButtonState) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityTurretChem(blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretChem) MessageTileSync(blusunrize.immersiveengineering.common.util.network.MessageTileSync)

Example 3 with TileEntityTurretGun

use of blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretGun in project ImmersiveEngineering by BluSunrize.

the class TileRenderTurret method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntityTurret tile, double x, double y, double z, float partialTicks, int destroyStage) {
    if (tile.isDummy() || !tile.getWorld().isBlockLoaded(tile.getPos(), false))
        return;
    //Grab model + correct eextended state
    final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockPos blockPos = tile.getPos();
    IBlockState state = getWorld().getBlockState(blockPos);
    if (state.getBlock() != IEContent.blockMetalDevice1)
        return;
    state = state.getBlock().getActualState(state, getWorld(), blockPos);
    IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
    //Initialize Tesselator and VertexBuffer
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer worldRenderer = tessellator.getBuffer();
    //Outer GL Wrapping, initial translation
    GlStateManager.pushMatrix();
    GlStateManager.translate(x + .5, y + 0.9375, z + .5);
    ClientUtils.bindAtlas();
    GlStateManager.rotate(tile.rotationYaw, 0, 1, 0);
    GlStateManager.rotate(tile.rotationPitch, tile.facing.getFrontOffsetZ(), 0, -tile.facing.getFrontOffsetX());
    renderModelPart(blockRenderer, tessellator, worldRenderer, tile.getWorld(), state, model, tile.getPos(), "gun");
    if (tile instanceof TileEntityTurretGun) {
        if (((TileEntityTurretGun) tile).cycleRender > 0) {
            float cycle = 0;
            if (((TileEntityTurretGun) tile).cycleRender > 3)
                cycle = (((TileEntityTurretGun) tile).cycleRender - 5) / 2f;
            else
                cycle = ((TileEntityTurretGun) tile).cycleRender / 3f;
            GlStateManager.translate(0, 0, cycle * .3125);
        }
        renderModelPart(blockRenderer, tessellator, worldRenderer, tile.getWorld(), state, model, tile.getPos(), "action");
    }
    GlStateManager.popMatrix();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) TileEntityTurretGun(blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretGun) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Aggregations

TileEntityTurretGun (blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretGun)3 GuiButtonState (blusunrize.immersiveengineering.client.gui.elements.GuiButtonState)2 GuiReactiveList (blusunrize.immersiveengineering.client.gui.elements.GuiReactiveList)2 TileEntityTurretChem (blusunrize.immersiveengineering.common.blocks.metal.TileEntityTurretChem)2 GuiButtonCheckbox (blusunrize.immersiveengineering.client.gui.elements.GuiButtonCheckbox)1 GuiButtonIE (blusunrize.immersiveengineering.client.gui.elements.GuiButtonIE)1 MessageTileSync (blusunrize.immersiveengineering.common.util.network.MessageTileSync)1 IBlockState (net.minecraft.block.state.IBlockState)1 GuiTextField (net.minecraft.client.gui.GuiTextField)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 BlockPos (net.minecraft.util.math.BlockPos)1