Search in sources :

Example 6 with TileEntityScreen

use of micdoodle8.mods.galacticraft.core.tile.TileEntityScreen in project Galacticraft by micdoodle8.

the class TileEntityScreen method joinDown.

private void joinDown() {
    int meta = this.getBlockMetadata();
    // EnumFacing side = EnumFacing.getFront(this.getRight(meta));
    EnumFacing side = getFront().rotateY();
    BlockVec3 vec = new BlockVec3(this);
    for (int x = -this.connectionsLeft; x <= this.connectionsRight; x++) {
        TileEntity tile;
        BlockVec3 newVec = vec.clone().modifyPositionFromSide(side, x);
        if (x == 0) {
            tile = this;
        } else {
            tile = newVec.getTileEntity(this.worldObj);
        }
        if (tile instanceof TileEntityScreen && tile.getBlockMetadata() == meta && !tile.isInvalid()) {
            TileEntityScreen screenTile = (TileEntityScreen) tile;
            // screenTile.connectedDown = true;
            screenTile.setConnectedDown(true);
            TileEntity te2 = newVec.getTileEntityOnSide(this.worldObj, 0);
            if (te2 instanceof TileEntityScreen && te2.getBlockMetadata() == meta && !te2.isInvalid()) {
                screenTile.tryConnectDown((TileEntityScreen) te2);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 7 with TileEntityScreen

use of micdoodle8.mods.galacticraft.core.tile.TileEntityScreen in project Galacticraft by micdoodle8.

the class TickHandlerClient method onClientTick.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientTick(ClientTickEvent event) {
    final Minecraft minecraft = FMLClientHandler.instance().getClient();
    final WorldClient world = minecraft.theWorld;
    final EntityPlayerSP player = minecraft.thePlayer;
    if (teleportingGui != null) {
        if (minecraft.currentScreen != teleportingGui) {
            minecraft.currentScreen = teleportingGui;
        }
    }
    if (menuReset) {
        TickHandlerClient.resetClient();
        menuReset = false;
    }
    if (event.phase == Phase.START && player != null) {
        if (ClientProxyCore.playerHead == null && player.getGameProfile() != null) {
            Map<Type, MinecraftProfileTexture> map = minecraft.getSkinManager().loadSkinFromCache(player.getGameProfile());
            if (map.containsKey(Type.SKIN)) {
                ClientProxyCore.playerHead = minecraft.getSkinManager().loadSkin((MinecraftProfileTexture) map.get(Type.SKIN), Type.SKIN);
            } else {
                ClientProxyCore.playerHead = DefaultPlayerSkin.getDefaultSkin(EntityPlayer.getUUID(player.getGameProfile()));
            }
        }
        TickHandlerClient.tickCount++;
        if (!GalacticraftCore.proxy.isPaused()) {
            Iterator<FluidNetwork> it = TickHandlerClient.fluidNetworks.iterator();
            while (it.hasNext()) {
                FluidNetwork network = it.next();
                if (network.getTransmitters().size() == 0) {
                    it.remove();
                } else {
                    network.clientTick();
                }
            }
        }
        if (TickHandlerClient.tickCount % 20 == 0) {
            if (updateJEIhiding) {
                updateJEIhiding = false;
                if (CompressorRecipes.steelIngotsPresent) {
                    // Update JEI to hide the ingot compressor recipe for GC steel in hard mode
                    GalacticraftJEI.updateHiddenSteel(ConfigManagerCore.hardMode && !ConfigManagerCore.challengeRecipes);
                }
                // Update JEI to hide adventure mode recipes when not in adventure mode
                GalacticraftJEI.updateHiddenAdventure(!ConfigManagerCore.challengeRecipes);
            }
            for (List<Footprint> fpList : FootprintRenderer.footprints.values()) {
                Iterator<Footprint> fpIt = fpList.iterator();
                while (fpIt.hasNext()) {
                    Footprint fp = fpIt.next();
                    fp.age += 20;
                    if (fp.age >= Footprint.MAX_AGE) {
                        fpIt.remove();
                    }
                }
            }
            if (player.inventory.armorItemInSlot(3) != null && player.inventory.armorItemInSlot(3).getItem() instanceof ItemSensorGlasses) {
                ClientProxyCore.valueableBlocks.clear();
                for (int i = -4; i < 5; i++) {
                    int x = MathHelper.floor_double(player.posX + i);
                    for (int j = -4; j < 5; j++) {
                        int y = MathHelper.floor_double(player.posY + j);
                        for (int k = -4; k < 5; k++) {
                            int z = MathHelper.floor_double(player.posZ + k);
                            BlockPos pos = new BlockPos(x, y, z);
                            IBlockState state = player.worldObj.getBlockState(pos);
                            final Block block = state.getBlock();
                            if (block.getMaterial() != Material.air) {
                                int metadata = block.getMetaFromState(state);
                                boolean isDetectable = false;
                                for (BlockMetaList blockMetaList : ClientProxyCore.detectableBlocks) {
                                    if (blockMetaList.getBlock() == block && blockMetaList.getMetaList().contains(metadata)) {
                                        isDetectable = true;
                                        break;
                                    }
                                }
                                if (isDetectable || (block instanceof IDetectableResource && ((IDetectableResource) block).isValueable(state))) {
                                    ClientProxyCore.valueableBlocks.add(new BlockVec3(x, y, z));
                                }
                            }
                        }
                    }
                }
                TileEntityOxygenSealer nearestSealer = TileEntityOxygenSealer.getNearestSealer(world, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ));
                if (nearestSealer != null && !nearestSealer.sealed) {
                    ClientProxyCore.leakTrace = nearestSealer.getLeakTraceClient();
                } else {
                    ClientProxyCore.leakTrace = null;
                }
            } else {
                ClientProxyCore.leakTrace = null;
            }
            if (world != null) {
                if (MapUtil.resetClientFlag.getAndSet(false)) {
                    MapUtil.resetClientBody();
                }
            }
        }
        if (ClientProxyCore.leakTrace != null)
            this.spawnLeakParticles();
        if (world != null && TickHandlerClient.spaceRaceGuiScheduled && minecraft.currentScreen == null && ConfigManagerCore.enableSpaceRaceManagerPopup) {
            player.openGui(GalacticraftCore.instance, GuiIdsCore.SPACE_RACE_START, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
            TickHandlerClient.spaceRaceGuiScheduled = false;
        }
        if (world != null && TickHandlerClient.checkedVersion) {
            ThreadVersionCheck.startCheck();
            TickHandlerClient.checkedVersion = false;
        }
        boolean inSpaceShip = false;
        if (player.ridingEntity instanceof EntitySpaceshipBase) {
            inSpaceShip = true;
            EntitySpaceshipBase rocket = (EntitySpaceshipBase) player.ridingEntity;
            if (rocket.prevRotationPitch != rocket.rotationPitch || rocket.prevRotationYaw != rocket.rotationYaw)
                GalacticraftCore.packetPipeline.sendToServer(new PacketRotateRocket(player.ridingEntity));
        }
        if (world != null) {
            if (world.provider instanceof WorldProviderSurface) {
                if (world.provider.getSkyRenderer() == null && inSpaceShip && player.ridingEntity.posY > Constants.OVERWORLD_SKYPROVIDER_STARTHEIGHT) {
                    world.provider.setSkyRenderer(new SkyProviderOverworld());
                } else if (world.provider.getSkyRenderer() instanceof SkyProviderOverworld && player.posY <= Constants.OVERWORLD_SKYPROVIDER_STARTHEIGHT) {
                    world.provider.setSkyRenderer(null);
                }
            } else if (world.provider instanceof WorldProviderSpaceStation) {
                if (world.provider.getSkyRenderer() == null) {
                    ((WorldProviderSpaceStation) world.provider).createSkyProvider();
                }
            } else if (world.provider instanceof WorldProviderMoon) {
                if (world.provider.getSkyRenderer() == null) {
                    world.provider.setSkyRenderer(new SkyProviderMoon());
                }
                if (world.provider.getCloudRenderer() == null) {
                    world.provider.setCloudRenderer(new CloudRenderer());
                }
            }
        }
        if (inSpaceShip) {
            final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.ridingEntity;
            boolean hasChanged = false;
            if (minecraft.gameSettings.keyBindLeft.isKeyDown()) {
                ship.turnYaw(-1.0F);
                hasChanged = true;
            }
            if (minecraft.gameSettings.keyBindRight.isKeyDown()) {
                ship.turnYaw(1.0F);
                hasChanged = true;
            }
            if (minecraft.gameSettings.keyBindForward.isKeyDown()) {
                if (ship.getLaunched()) {
                    ship.turnPitch(-0.7F);
                    hasChanged = true;
                }
            }
            if (minecraft.gameSettings.keyBindBack.isKeyDown()) {
                if (ship.getLaunched()) {
                    ship.turnPitch(0.7F);
                    hasChanged = true;
                }
            }
            if (hasChanged) {
                GalacticraftCore.packetPipeline.sendToServer(new PacketRotateRocket(ship));
            }
        }
        if (world != null) {
            List entityList = world.loadedEntityList;
            for (Object e : entityList) {
                if (e instanceof IEntityNoisy) {
                    IEntityNoisy vehicle = (IEntityNoisy) e;
                    if (vehicle.getSoundUpdater() == null) {
                        ISound noise = vehicle.setSoundUpdater(FMLClientHandler.instance().getClient().thePlayer);
                        if (noise != null) {
                            FMLClientHandler.instance().getClient().getSoundHandler().playSound(noise);
                        }
                    }
                }
            }
        }
        if (FMLClientHandler.instance().getClient().currentScreen instanceof GuiCelestialSelection) {
            player.motionY = 0;
        }
        if (world != null && world.provider instanceof IGalacticraftWorldProvider && OxygenUtil.noAtmosphericCombustion(world.provider) && ((IGalacticraftWorldProvider) world.provider).shouldDisablePrecipitation()) {
            world.setRainStrength(0.0F);
        }
        boolean isPressed = KeyHandlerClient.spaceKey.isPressed();
        if (!isPressed) {
            ClientProxyCore.lastSpacebarDown = false;
        }
        if (player.ridingEntity != null && isPressed && !ClientProxyCore.lastSpacebarDown) {
            GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_IGNITE_ROCKET, GCCoreUtil.getDimensionID(player.worldObj), new Object[] {}));
            ClientProxyCore.lastSpacebarDown = true;
        }
        if (!(this.screenConnectionsUpdateList.isEmpty())) {
            HashSet<TileEntityScreen> updateListCopy = (HashSet<TileEntityScreen>) screenConnectionsUpdateList.clone();
            screenConnectionsUpdateList.clear();
            for (TileEntityScreen te : updateListCopy) {
                if (te.getWorld().getBlockState(te.getPos()).getBlock() == GCBlocks.screen) {
                    if (te.refreshOnUpdate) {
                        te.refreshConnections(true);
                    }
                    te.getWorld().markBlockRangeForRenderUpdate(te.getPos(), te.getPos());
                }
            }
        }
    } else if (event.phase == Phase.END) {
        if (world != null) {
            for (GalacticraftPacketHandler handler : packetHandlers) {
                handler.tick(world);
            }
        }
    }
}
Also used : TileEntityOxygenSealer(micdoodle8.mods.galacticraft.core.tile.TileEntityOxygenSealer) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) IEntityNoisy(micdoodle8.mods.galacticraft.api.entity.IEntityNoisy) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) GalacticraftPacketHandler(micdoodle8.mods.galacticraft.core.network.GalacticraftPacketHandler) IDetectableResource(micdoodle8.mods.galacticraft.api.block.IDetectableResource) ISound(net.minecraft.client.audio.ISound) WorldProviderSpaceStation(micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation) WorldProviderMoon(micdoodle8.mods.galacticraft.core.dimension.WorldProviderMoon) BlockPos(net.minecraft.util.BlockPos) PacketRotateRocket(micdoodle8.mods.galacticraft.core.network.PacketRotateRocket) BlockMetaList(micdoodle8.mods.galacticraft.core.wrappers.BlockMetaList) ItemSensorGlasses(micdoodle8.mods.galacticraft.core.items.ItemSensorGlasses) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3) TileEntityScreen(micdoodle8.mods.galacticraft.core.tile.TileEntityScreen) EntitySpaceshipBase(micdoodle8.mods.galacticraft.api.prefab.entity.EntitySpaceshipBase) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) WorldProviderSurface(net.minecraft.world.WorldProviderSurface) IBlockState(net.minecraft.block.state.IBlockState) FluidNetwork(micdoodle8.mods.galacticraft.core.fluid.FluidNetwork) MinecraftProfileTexture(com.mojang.authlib.minecraft.MinecraftProfileTexture) Minecraft(net.minecraft.client.Minecraft) WorldClient(net.minecraft.client.multiplayer.WorldClient) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) BlockMetaList(micdoodle8.mods.galacticraft.core.wrappers.BlockMetaList) Type(com.mojang.authlib.minecraft.MinecraftProfileTexture.Type) GuiCelestialSelection(micdoodle8.mods.galacticraft.core.client.gui.screen.GuiCelestialSelection) Block(net.minecraft.block.Block) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with TileEntityScreen

use of micdoodle8.mods.galacticraft.core.tile.TileEntityScreen in project Galacticraft by micdoodle8.

the class TileEntityScreen method canJoinUp.

private boolean canJoinUp() {
    int meta = this.getBlockMetadata();
    TileEntity te = new BlockVec3(this).getTileEntityOnSide(this.worldObj, 1);
    if (!(te instanceof TileEntityScreen)) {
        return false;
    }
    TileEntityScreen screenTile = (TileEntityScreen) te;
    if (screenTile.getBlockMetadata() != meta) {
        return false;
    }
    if (screenTile.connectionsLeft != this.connectionsLeft) {
        return false;
    }
    if (screenTile.connectionsRight != this.connectionsRight) {
        return false;
    }
    if (this.connectionsLeft + this.connectionsRight > 0) {
        return true;
    }
    if (this.connectionsDown > 0) {
        return false;
    }
    if (screenTile.connectionsUp > 0) {
        return false;
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 9 with TileEntityScreen

use of micdoodle8.mods.galacticraft.core.tile.TileEntityScreen in project Galacticraft by micdoodle8.

the class TileEntityScreen method canJoinRight.

private boolean canJoinRight() {
    int meta = this.getBlockMetadata();
    TileEntity te = new BlockVec3(this).getTileEntityOnSide(this.worldObj, this.getRight(meta));
    if (!(te instanceof TileEntityScreen)) {
        return false;
    }
    TileEntityScreen screenTile = (TileEntityScreen) te;
    if (screenTile.getBlockMetadata() != meta) {
        return false;
    }
    if (screenTile.connectionsUp != this.connectionsUp) {
        return false;
    }
    if (screenTile.connectionsDown != this.connectionsDown) {
        return false;
    }
    if (this.connectionsUp + this.connectionsDown > 0) {
        return true;
    }
    if (this.connectionsLeft > 0) {
        return false;
    }
    if (screenTile.connectionsRight > 0) {
        return false;
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 10 with TileEntityScreen

use of micdoodle8.mods.galacticraft.core.tile.TileEntityScreen in project Galacticraft by micdoodle8.

the class TileEntityScreen method breakScreen.

/**
 * Call when a screen (which maybe part of a multiscreen) is either
 * broken or rotated.
 *
 * @param state The state of the screen prior to breaking or rotation
 */
public void breakScreen(IBlockState state) {
    BlockVec3 vec = new BlockVec3(this);
    int meta = state.getBlock().getMetaFromState(state);
    TileEntity tile;
    EnumFacing facingRight = getFacing(state).rotateY();
    int left = this.connectionsLeft;
    int right = this.connectionsRight;
    int up = this.connectionsUp;
    int down = this.connectionsDown;
    boolean doUp = this.connectedUp;
    boolean doDown = this.connectedDown;
    boolean doLeft = this.connectedLeft;
    boolean doRight = this.connectedRight;
    for (int x = -left; x <= right; x++) {
        for (int z = -up; z <= down; z++) {
            if (x == 0 && z == 0) {
                this.resetToSingle();
            } else {
                BlockVec3 newVec = vec.clone().modifyPositionFromSide(facingRight, x).modifyPositionFromSide(EnumFacing.DOWN, z);
                tile = newVec.getTileEntity(this.worldObj);
                if (tile instanceof TileEntityScreen && tile.getBlockMetadata() == meta) {
                    ((TileEntityScreen) tile).resetToSingle();
                }
            }
        }
    }
    // TODO  Try to generate largest screen possible out of remaining blocks
    this.setConnectedDown(false);
    this.setConnectedUp(false);
    this.setConnectedLeft(false);
    this.setConnectedRight(false);
    if (doUp) {
        tile = vec.getTileEntityOnSide(this.worldObj, 1);
        if (tile instanceof TileEntityScreen && tile.getBlockMetadata() == meta && !tile.isInvalid()) {
            if (doLeft) {
                ((TileEntityScreen) tile).setConnectedLeft(true);
            }
            if (doRight) {
                ((TileEntityScreen) tile).setConnectedRight(true);
            }
            ((TileEntityScreen) tile).setConnectedUp(true);
            // if (doLeft) ((TileEntityScreen)tile).connectedLeft = true;
            // if (doRight) ((TileEntityScreen)tile).connectedRight = true;
            // ((TileEntityScreen)tile).connectedUp = true;
            ((TileEntityScreen) tile).refreshConnections(true);
        }
    }
    if (doDown) {
        tile = vec.getTileEntityOnSide(this.worldObj, 0);
        if (tile instanceof TileEntityScreen && tile.getBlockMetadata() == meta && !tile.isInvalid()) {
            if (doLeft) {
                ((TileEntityScreen) tile).setConnectedLeft(true);
            }
            if (doRight) {
                ((TileEntityScreen) tile).setConnectedRight(true);
            }
            ((TileEntityScreen) tile).setConnectedDown(true);
            // if (doLeft) ((TileEntityScreen)tile).connectedLeft = true;
            // if (doRight) ((TileEntityScreen)tile).connectedRight = true;
            // ((TileEntityScreen)tile).connectedDown = true;
            ((TileEntityScreen) tile).refreshConnections(true);
        }
    }
    if (doLeft) {
        tile = vec.getTileEntityOnSide(this.worldObj, this.getLeft(meta));
        if (tile instanceof TileEntityScreen && tile.getBlockMetadata() == meta && !tile.isInvalid()) {
            if (doUp) {
                ((TileEntityScreen) tile).setConnectedUp(true);
            }
            if (doDown) {
                ((TileEntityScreen) tile).setConnectedDown(true);
            }
            ((TileEntityScreen) tile).setConnectedLeft(true);
            // if (doUp) ((TileEntityScreen)tile).connectedUp = true;
            // if (doDown) ((TileEntityScreen)tile).connectedDown = true;
            // ((TileEntityScreen)tile).connectedLeft = true;
            ((TileEntityScreen) tile).refreshConnections(true);
        }
    }
    if (doRight) {
        tile = vec.getTileEntityOnSide(this.worldObj, this.getRight(meta));
        if (tile instanceof TileEntityScreen && tile.getBlockMetadata() == meta && !tile.isInvalid()) {
            if (doUp) {
                ((TileEntityScreen) tile).setConnectedUp(true);
            }
            if (doDown) {
                ((TileEntityScreen) tile).setConnectedDown(true);
            }
            ((TileEntityScreen) tile).setConnectedRight(true);
            // if (doUp) ((TileEntityScreen)tile).connectedUp = true;
            // if (doDown) ((TileEntityScreen)tile).connectedDown = true;
            // ((TileEntityScreen)tile).connectedRight = true;
            ((TileEntityScreen) tile).refreshConnections(true);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnumFacing(net.minecraft.util.EnumFacing) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Aggregations

BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)13 TileEntity (net.minecraft.tileentity.TileEntity)12 EnumFacing (net.minecraft.util.EnumFacing)5 IBlockState (net.minecraft.block.state.IBlockState)2 MinecraftProfileTexture (com.mojang.authlib.minecraft.MinecraftProfileTexture)1 Type (com.mojang.authlib.minecraft.MinecraftProfileTexture.Type)1 ArrayList (java.util.ArrayList)1 IDetectableResource (micdoodle8.mods.galacticraft.api.block.IDetectableResource)1 IEntityNoisy (micdoodle8.mods.galacticraft.api.entity.IEntityNoisy)1 EntitySpaceshipBase (micdoodle8.mods.galacticraft.api.prefab.entity.EntitySpaceshipBase)1 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)1 GuiCelestialSelection (micdoodle8.mods.galacticraft.core.client.gui.screen.GuiCelestialSelection)1 DrawGameScreen (micdoodle8.mods.galacticraft.core.client.screen.DrawGameScreen)1 WorldProviderMoon (micdoodle8.mods.galacticraft.core.dimension.WorldProviderMoon)1 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)1 FluidNetwork (micdoodle8.mods.galacticraft.core.fluid.FluidNetwork)1 ItemSensorGlasses (micdoodle8.mods.galacticraft.core.items.ItemSensorGlasses)1 GalacticraftPacketHandler (micdoodle8.mods.galacticraft.core.network.GalacticraftPacketHandler)1 PacketRotateRocket (micdoodle8.mods.galacticraft.core.network.PacketRotateRocket)1 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)1